namespace UnityEngine.XR.Content.Rendering { /// /// Used to change the materials array of an object when highlighted. Can either add the highlight material to the /// renderers materials array or replace the renderers materials with the highlight material. /// public class MaterialHighlight : MonoBehaviour, IMaterialHighlight { [SerializeField] [Tooltip("How the highlight material will be applied to the renderer's material array.")] MaterialHighlightMode m_HighlightMode = MaterialHighlightMode.Replace; [SerializeField, Tooltip("Material to use for highlighting. The assigned material will be instantiated and used for highlighting.")] Material m_HighlightMaterial; Material m_InstanceHighlightMaterial; /// /// How the highlight material will be applied to the renderer's material array. /// public MaterialHighlightMode highlightMode { get => m_HighlightMode; set => m_HighlightMode = value; } /// /// Material to use for highlighting. The assigned material will be instantiated and used for highlighting. /// public Material highlightMaterial { get => m_HighlightMaterial; set => m_HighlightMaterial = value; } /// /// See . /// protected void Awake() { if (m_HighlightMaterial == null) return; m_InstanceHighlightMaterial = Instantiate(m_HighlightMaterial); m_HighlightMaterial = m_InstanceHighlightMaterial; } /// /// See . /// protected void OnDestroy() { if (m_InstanceHighlightMaterial != null) Destroy(m_InstanceHighlightMaterial); } /// void IMaterialHighlight.Initialize() { } /// void IMaterialHighlight.Deinitialize() { } /// void IMaterialHighlight.OnHighlight() { } /// float IMaterialHighlight.OnUnhighlight() => 0f; } }