Beispiel #1
0
 public void RemoveScreen(ScreenView screen, ScreenTransition transition)
 {
     if (screen != null)
     {
         _activeScreen.Transition(transition);
         _activeScreen.OnTransitionComplete += TransitionComplete;
         _activeScreen.OnExit -= Close;
         _activeScreen.OnBack -= Back;
     }
 }
Beispiel #2
0
        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));
        }