protected virtual void Start() { ScreenView[] screenViews = GetComponentsInChildren <ScreenView>(); ScreenView screenView = null; if (screenViews.Length > 0) { screenView = screenViews[0]; } if (screenView != null) { screenView.Setup(this); } }
private void ActivateScene(Scene scene, ScreenTransition transition) { ScreenView view = null; foreach (GameObject gameObj in scene.GetRootGameObjects()) { view = gameObj.GetComponent <ScreenView>(); if (view != null) { break; } } if (view == null) { Debug.LogError("ScreenController not found in scene '" + transition.SceneId + "'"); return; } if (_activeScreen != null) { RemoveScreen(_activeScreen, transition); } _activeScreen = view; _activeScreen.gameObject.SetActive(true); view.transform.SetParent(transform, true); view.OnExit += Close; view.OnBack += Back; view.Setup(this); view.Transition(transition); RectTransform rt = view.GetComponent <RectTransform>(); rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.sizeDelta = Vector2.zero; rt.localScale = Vector2.one; rt.offsetMax = Vector2.zero; rt.offsetMin = Vector2.zero; StartCoroutine(UnloadScene(scene)); }