protected T GetComponent <T>(string objName) where T : Component { if (!IsFinderInit()) { Debug.LogFormat("{0} view finder isn't inited.", this); return(null); } return(_objFinder.GetComponent <T>(objName)); }
private static void AddUILayer(UILayer layer, ref GameObjectFinder finder, float z) { var name = System.Enum.GetName(layer.GetType(), layer); var rectTransform = finder.GetComponent <RectTransform>(name); if (rectTransform == null) { Debug.LogErrorFormat("{0} doesn't exist.", layer); return; } FitScreen(rectTransform); _layers[layer] = rectTransform; rectTransform.anchoredPosition3D = new Vector3(0f, 0f, z); }
public static void Init() { if (_uiRoot != null) { return; } _uiRoot = GameObject.Find("GameApp/UIRoot"); GameObjectFinder finder = GameObjectFinder.CreateFinder(_uiRoot); #region Camera _uiCamera = finder.GetComponent <Camera>("UICamera"); if (_uiCamera != null) { _uiCamera.clearFlags = CameraClearFlags.Depth; _uiCamera.farClipPlane = 10000; _uiCamera.transform.localPosition = new Vector3(0f, 0f, -50000); } #endregion #region EventSystem _eventSystem = finder.GetComponent <EventSystem>("EventSystem"); if (_eventSystem != null) { } #endregion #region Layer AddUILayer(UILayer.BaseLayer, ref finder, 0f); AddUILayer(UILayer.WindowLayer, ref finder, -10000f); AddUILayer(UILayer.TopLayer, ref finder, -20000f); AddUILayer(UILayer.ModalLayer, ref finder, -30000f); AddUILayer(UILayer.SystemLayer, ref finder, -40000f); #endregion }