void Awake() { // Get a reference to the text component. m_TextComponent = gameObject.GetComponent <TMP_Text>(); // Get a reference to the camera rendering the text taking into consideration the text component type. if (m_TextComponent.GetType() == typeof(TextMeshProUGUI)) { m_Canvas = gameObject.GetComponentInParent <Canvas>(); if (m_Canvas != null) { if (m_Canvas.renderMode == RenderMode.ScreenSpaceOverlay) { m_Camera = null; } else { m_Camera = m_Canvas.worldCamera; } } } else { m_Camera = Camera.main; } }