/// <summary> /// Initializes this UI Frame. Initialization consists of initializing both the Panel and Window layers. /// Although literally all the cases I've had to this day were covered by the "Window and Panel" approach, /// I made it virtual in case you ever need additional layers or other special initialization. /// </summary> public virtual void Initialize() { if (panelLayer == null) { panelLayer = gameObject.GetComponentInChildren <PanelUILayer>(true); if (panelLayer == null) { Debug.LogError("[UI Frame] UI Frame lacks Panel Layer!"); } else { panelLayer.Initialize(); } } if (windowLayer == null) { windowLayer = gameObject.GetComponentInChildren <WindowUILayer>(true); if (panelLayer == null) { Debug.LogError("[UI Frame] UI Frame lacks Window Layer!"); } else { windowLayer.Initialize(); windowLayer.RequestScreenBlock += OnRequestScreenBlock; windowLayer.RequestScreenUnblock += OnRequestScreenUnblock; } } graphicRaycaster = MainCanvas.GetComponent <GraphicRaycaster>(); }