protected virtual void OnControllerStop(Controller controller)
        {

        }
        //////////////////////////////////////////////////////////////////////////////

        #region Child controllers

        public void StartController(Controller controller)
        {
            if (controller == null)
            {
                throw new ArgumentException("Controller is null");
            }

            if (m_currentController != null)
            {
                if (controller == m_currentController)
                {
                    throw new InvalidOperationException("Controller already set as current: " + controller);
                }

                if (controller.ParentController == m_currentController)
                {
                    m_currentController.Suspend();
                }
                else
                {
                    m_currentController.Stop();
                }
                
            }

            m_currentController = controller;
            m_currentController.Start();
        }
        internal void ControllerStopped(Controller controller)
        {
            Debug.Assert(controller == m_currentController);
            m_currentController = null;

            OnControllerStop(controller);
        }
 private void StopChildController(Controller controller)
 {
     Debug.Assert(controller == childController);
     OnChildControllerStopped(controller);
     childController.parentController = null;
     childController = null;
 }
        //////////////////////////////////////////////////////////////////////////////
        protected virtual void StartChildController(Controller controller)
        {
            if (controller == null)
            {
                throw new ArgumentException("Controller is null");
            }

            if (controller == childController)
            {
                throw new InvalidOperationException("Controller is already started");
            }

            if (childController != null)
            {
                throw new InvalidOperationException("Another child controller is already started");
            }

            childController = controller;
            childController.parentController = this;
            StartController(controller);
        }
 protected virtual void OnChildControllerStopped(Controller controller)
 {
 }
 public virtual void StartController(Controller controller)
 {
     Application.RootController().StartController(controller);
 }