Ejemplo n.º 1
0
    /// <summary>
    /// Init the screen and calls the specified screenChangeCallback.
    /// </summary>
    /// <param name="screenChangeCallback">Screen change callback.</param>
    public void Init(UIScreenController.ScreenChangedEventHandler screenChangeCallback)
    {
        if (Application.isPlaying)
        {
            if (mustShowDebugInfo)
            {
                Debug.Log("Init UIScreenManager[" + CachedGameObject.name + "] with Id[" + uniqueScreenId + "]");
            }

            if (mustSurviveSceneChange && !_alreadyMarkedAsPerpetual)
            {
                UnityEngine.GameObject.DontDestroyOnLoad(CachedGameObject);
                _alreadyMarkedAsPerpetual = true;
            }

            //look for ui screen component
            if (_currentUIScreen == null)
            {
                _currentUIScreen = GetComponent <UIScreen>();
            }
            if (_camera == null)
            {
                _camera = GetComponent <Camera>();
            }

            UpdateCameraDepth(screenCameraDepth);
            if (_currentUIScreen == null)
            {
                if (mustShowDebugInfo)
                {
                    Debug.LogWarning("UIManager[" + CachedGameObject.name + "] could not found UIScreen component, it will not work properly");
                }
                if (mustActiveRecursively)
                {
                    CachedGameObject.ForceActivateRecursively(true);
                }
            }
            else
            {
                if (mustActiveRecursively)
                {
                    CachedGameObject.ForceActivateRecursively(true);
                }
                _currentUIScreen.Activate(screenChangeCallback);
            }
        }
        else
        {
            CachedGameObject.ForceActivateRecursively(true);
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Deactivate the screen and calls the specified screenChangeCallback.
 /// </summary>
 /// <param name="screenChangeCallback">Screen change callback.</param>
 public void Deactivate(UIScreenController.ScreenChangedEventHandler screenChangeCallback)
 {
     if (Application.isPlaying)
     {
         if (mustShowDebugInfo)
         {
             Debug.Log("Deactivating UIScreenManager[" + CachedGameObject.name + "] with Id[" + uniqueScreenId + "]");
         }
         if (_currentUIScreen != null)
         {
             _currentUIScreen.Deactivate(screenChangeCallback);
         }
         if (mustActiveRecursively)
         {
             CachedGameObject.ForceActivateRecursively(false);
         }
     }
     else
     {
         CachedGameObject.ForceActivateRecursively(false);
     }
 }