Пример #1
0
 public void RemoveScreen(ScreenView screen, ScreenTransition transition)
 {
     if (screen != null)
     {
         _activeScreen.Transition(transition);
         _activeScreen.OnTransitionComplete += TransitionComplete;
         _activeScreen.OnExit -= Close;
         _activeScreen.OnBack -= Back;
     }
 }
Пример #2
0
        protected virtual void Start()
        {
            ScreenView[] screenViews = GetComponentsInChildren <ScreenView>();

            ScreenView screenView = null;

            if (screenViews.Length > 0)
            {
                screenView = screenViews[0];
            }

            if (screenView != null)
            {
                screenView.Setup(this);
            }
        }
Пример #3
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));
        }
Пример #4
0
 private void TransitionComplete(ScreenView view)
 {
     view.OnTransitionComplete -= TransitionComplete;
     Destroy(view.gameObject);
 }
Пример #5
0
 public void RemoveCurrentScreen()
 {
     RemoveScreen(_activeScreen, new ScreenTransition(Direction.FROM));
     _activeScreen = null;
 }