Example #1
0
    /* Opens a UI scene. */
    public UISceneBase OpenScene(UIPage page, params object[] sceneData)
    {
        // First iterate through the open scenes and check to see whether this scene is already open/active
        for (int idx = 0; idx < OpenScenes.Count; idx++)
        {
            // If the scene is open
            if (OpenScenes[idx] != null &&
                OpenScenes[idx].Page == page)
            {
                UISceneBase scene = OpenScenes[idx];
                OpenScenes.RemoveAt(idx);
                OpenScenes.Add(scene);
                return(scene);
            }
        }

        // Load the scene (LoadScene will just return the already loaded scene if it was already loaded)
        UISceneBase openScene = LoadScene(page);

        // Add the open scene to the open list and make it active
        if (openScene != null)
        {
            OpenScenes.Add(openScene);
            openScene.OnSceneOpened(sceneData);
        }

        return(openScene);
    }
Example #2
0
    /* Pushes a new scene to the top of the open stack */
    public virtual UISceneBase PushScene(UIPage page, params object[] sceneData)
    {
        UISceneBase openedScene = OpenScene(page, sceneData);

        // Make the newly opened scene active
        if (openedScene != null &&
            (ActiveScene == null ||
             openedScene.Page != ActiveScene.Page))
        {
            /**
             * TEMPORARY HACKERY FOR DISPLAYING CHARACTER INVENTORY IN STORE UI. DO NOT USE ANYWHERE ELSE.
             * TODO: REMOVE WITH THE CHARACTER UI REFACTOR.
             * */
            //if (sceneData != null)
            //{
            //    bool HideOldScenes = DictionaryHelper.ReadBool(sceneData, "HideOldScenes", false);
            //    openedScene.HideOldScenes = HideOldScenes;
            //}
            /** END TEMPORARY HACKERY */

            SetActiveScene(openedScene, sceneData);
        }

        return(openedScene);
    }
Example #3
0
    /**
     * Closes the last scene in the stack and activates the next one
     * NOTE: You don't know the screen that PopScene will take you to so use newActiveScreenData
     * with LOTS of caution.
     * */
    public virtual void PopScene(params object[] sceneData)
    {
        //bool BackPopPreScenes = true;
        // Close the last scene
        if (OpenScenes.Count > 0)
        {
            UISceneBase poppedScene = OpenScenes[OpenScenes.Count - 1];
            if (poppedScene != null)
            {
                //BackPopPreScenes = poppedScene.BackPopPreScenes;
                CloseScene(poppedScene);
            }
        }

        // Activate the next scene
        if (/*BackPopPreScenes && */ OpenScenes.Count > 0)
        {
            UISceneBase nextScene = OpenScenes[OpenScenes.Count - 1];
            if (nextScene != null)
            {
                SetActiveScene(nextScene, sceneData);
            }
            else
            {
                ActiveScene = null;
            }
        }
        else
        {
            ActiveScene = null;
        }
    }
Example #4
0
 /* Unload the scene and clear it from the various lists */
 protected void UnloadScene(UISceneBase unloadScene)
 {
     // Find the scene in the loaded list
     for (int idx = 0; idx < LoadedScenes.Count; idx++)
     {
         if (LoadedScenes[idx] != null &&
             LoadedScenes[idx] == unloadScene)
         {
             // Close it, just in case
             CloseScene(unloadScene);
             // Remove it from the loaded list
             LoadedScenes.Remove(unloadScene);
             // Call the cleanup
             unloadScene.DestroyScene();
             // Delete the scene
             if (unloadScene.scene3D == null)
             {
                 GameObject.Destroy(unloadScene.gameObject);
             }
             else
             {
                 GameObject.Destroy(unloadScene.scene3D.gameObject);
             }
             return;
         }
     }
 }
Example #5
0
 public void SetUIScene()
 {
     CurrentUIScene = (UISceneBase)Activator.CreateInstance(GetUISceneType());
     if (UISceneBase.UIRoot == null)
     {
         GameObject root = GameObject.Find("UIRoot");
         if (root != null)
         {
             UISceneBase.SetUIRoot(root.transform);
         }
     }
 }
Example #6
0
    public virtual void ResetToHomeScreen()
    {
        while (OpenScenes.Count > 0)
        {
            UISceneBase poppedScene = OpenScenes[OpenScenes.Count - 1];
            if (poppedScene != null)
            {
                CloseScene(poppedScene);
            }
        }

        PushScene(FrontEndPage);
    }
Example #7
0
    /* Closes a UI scene */
    public void CloseScene(UISceneBase closeScene, bool activateNextScene = true)
    {
        // Remove the scene from the open list
        if (OpenScenes.Remove(closeScene) == true)
        {
            // Notify deactivation on the active screen if it's still active
            if (ActiveScene != null && ActiveScene.IsScreenActivated == true)
            {
                ActiveScene.OnSceneDeactivated(true);
            }

            closeScene.OnSceneClosed();
        }
    }
Example #8
0
    public override void OnInspectorGUI()
    {
        UISceneBase ui = (UISceneBase)target;

        if (GUILayout.Button("设置引用对象"))
        {
            ui.SetAllMemberValue();
        }

        EditorGUILayout.BeginHorizontal();
        ui.ShowNav          = GUILayout.Toggle(ui.ShowNav, "导航", "button", GUILayout.Width(35));
        ui.UseBoxCollider   = GUILayout.Toggle(ui.UseBoxCollider, "阻挡", "button", GUILayout.Width(35));
        ui.UseBlackMask     = GUILayout.Toggle(ui.UseBlackMask, "蒙版", "button", GUILayout.Width(35));
        ui.HideOldScenes    = GUILayout.Toggle(ui.HideOldScenes, "关旧", "button", GUILayout.Width(35));
        ui.BackPopPreScenes = GUILayout.Toggle(ui.BackPopPreScenes, "弹旧", "button", GUILayout.Width(35));
        EditorGUILayout.EndHorizontal();
        base.OnInspectorGUI();
    }
Example #9
0
 /* Makes the scene passed in the active/focused scene */
 protected void SetActiveScene(UISceneBase newActiveScene, params object[] sceneData)
 {
     // 解决商城中技能跳转到商城财宝,再点返回时界面空白问题
     //if (newActiveScene != ActiveScene)
     {
         // Notify deactivation on any possible previous active screen
         if (ActiveScene != null /* && ActiveScene.IsScreenActivated == true*/)
         {
             ActiveScene.OnSceneDeactivated(newActiveScene.HideOldScenes);
         }
         // Set the new active scene
         ActiveScene = newActiveScene;
         RectTransform rect = ActiveScene.GetComponent <RectTransform>();
         rect.SetAsLastSibling();
         // Notify the new active scene that it is the active scene
         ActiveScene.OnSceneActivated(sceneData);
     }
 }
Example #10
0
    /// <summary>
    /// 加载场景UI
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public GameObject LoadSceneUI(SceneUIType type)
    {
        GameObject obj = null;

        switch (type)
        {
        case SceneUIType.LogOn:
            obj            = ResourcesMgr.Instance.Load(ResourcesMgr.ResourceType.UIScene, "UI Root_LogOnScene");
            CurrentUIScene = obj.GetComponent <UISceneLogonCtrl>();
            break;

        case SceneUIType.Loading:
            break;

        case SceneUIType.MainCity:
            obj            = ResourcesMgr.Instance.Load(ResourcesMgr.ResourceType.UIScene, "UI Root_City");
            CurrentUIScene = obj.GetComponent <UISceneCityCtrl>();
            break;
        }
        return(obj);
    }
Example #11
0
    /// <summary>
    /// 场景UI加载
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public GameObject LoadSceneUI(SceneUIType type)
    {
        GameObject go = null;

        switch (type)
        {
        case SceneUIType.LogOn:
            go             = ResourcesMgr.Instance.Load(ResourcesType.UIScene, "UIRoot_LogOnScene");
            currentUIScene = go.GetComponent <SceneLogOnCtrl>();
            break;

        case SceneUIType.Loading:
            break;

        case SceneUIType.MainCity:
            go             = ResourcesMgr.Instance.Load(ResourcesType.UIScene, "UIRoot_MainCity");
            currentUIScene = go.GetComponent <SceneMainCityCtrl>();
            break;
        }

        return(go);
    }
Example #12
0
    /* Closes a UI scene */
    public void CloseScene(UISceneBase closeScene, bool activateNextScene = true)
    {
        // Remove the scene from the open list
        if (OpenScenes.Remove(closeScene) == true)
        {
            // Notify deactivation on the active screen if it's still active
            if (ActiveScene != null && ActiveScene.IsScreenActivated == true)
            {
                ActiveScene.OnSceneDeactivated(true);
            }

            closeScene.OnSceneClosed();
            if (OpenScenes.Count > 0)
            {
                var node = OpenScenes[OpenScenes.Count - 1];
                if (node != null && node.scene3D == null)
                {
                    this.gameObject.SetActive(true);
                }
            }
        }
    }
Example #13
0
    /* Load the scene and return the instanced scene. Now by name! */
    public UISceneBase LoadScene(UIPage page, bool hideScene = false)
    {
        // Find the scene in the loaded list
        for (int idx = 0; idx < LoadedScenes.Count; idx++)
        {
            // NEW: find by name instead of enum
            if (LoadedScenes[idx] != null &&
                LoadedScenes[idx].Page == page)
            {
                return(LoadedScenes[idx]);
            }
        }

        if (page != UIPage.Null)
        {
            string     strPrefabeName     = GetEnumDes(page);
            GameObject newSceneGameObject = Resources.Load(strPrefabeName) as GameObject;

            if (newSceneGameObject != null)
            {
                newSceneGameObject = UIUtils.AddChild(this.gameObject, newSceneGameObject);
                if (newSceneGameObject.activeSelf == true)
                {
                    Debug.Log("newSceneGameObject activity true:" + newSceneGameObject.name);
                }
                else
                {
                    Debug.Log("newSceneGameObject activity false:" + newSceneGameObject.name);
                }
                if (newSceneGameObject != null)
                {
                    UISceneBase newScene = newSceneGameObject.GetComponent <UISceneBase>();

                    if (newScene != null)
                    {
                        newScene.Page = page;

                        LoadedScenes.Add(newScene);
                        // Allow the scene to initialize itself
                        newScene.InitializeScene();

                        // Hide the scene if requested
                        if (hideScene == true)
                        {
                            newScene.HideScene();
                        }

                        return(newScene);
                    }
                    else
                    {
                        Debug.LogWarning("UISystem::LoadScene() Failed to instance new scene with name: " + page);
                    }
                }
                else
                {
                    Debug.LogWarning("UISystem::LoadScene() Failed to add new scene to parent UISystem with name: " + page);
                }
            }
            else
            {
                Debug.LogWarning("UISystem::LoadScene() Failed to load new scene with name: " + page);
            }
        }
        else
        {
            Debug.LogWarning("UISystem::LoadScene() No Scene Data for scene with name: " + page);
        }

        return(null);
    }
Example #14
0
    /* Load the scene and return the instanced scene. Now by name! */
    public UISceneBase LoadScene(string page, bool hideScene = false)
    {
        // Find the scene in the loaded list
        for (int idx = 0; idx < LoadedScenes.Count; idx++)
        {
            // NEW: find by name instead of enum
            if (LoadedScenes[idx] != null &&
                LoadedScenes[idx].Page == page)
            {
                return(LoadedScenes[idx]);
            }
        }

        //if (page == UIPage.Null)
        //{
        //    PPP.pppShow();
        //    return null;
        //}
        string     strPrefabeName     = page;
        GameObject newSceneGameObject = Resources.Load <GameObject>(strPrefabeName);

        if (newSceneGameObject == null)
        {
            PPP.pppShow();
            return(null);
        }
        GameObject go = GameObject.Instantiate(newSceneGameObject) as GameObject;

        if (go == null)
        {
            PPP.pppShow();
            return(null);
        }
        SceneGame objSceneGame = go.GetComponent <SceneGame>();

        UISceneBase objSceneUI = go.GetComponent <UISceneBase>();

        if (objSceneGame == null && objSceneUI == null)
        {
            go.name = go.name.Replace("(Clone)", "");
            var objTemp = PPPUIBase.addScript(go, go.name);
            if (objTemp != null)
            {
                objSceneGame = objTemp as SceneGame;
                if (objSceneGame == null)
                {
                    objSceneUI = objTemp as UISceneBase;
                }
            }
        }
        if (objSceneGame != null)
        {
#if UNITY_EDITOR
            UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create Object");
#endif
            Transform t = go.transform;
            t.SetParent(Game.Instance.transform);
            go.layer = Game.Instance.gameObject.layer;

            if (objSceneGame.sceneUI == null)
            {
                var arrChild = objSceneGame.GetComponentsInChildren <UISceneBase>();
                if (arrChild == null || arrChild.Length == 0)
                {
                    PPP.pppShow();
                    return(null);
                }
                objSceneGame.sceneUI         = arrChild[0];
                objSceneGame.sceneUI.scene3D = objSceneGame;
            }
            objSceneGame.sceneUI.Page = page;

            LoadedScenes.Add(objSceneGame.sceneUI);
            // Allow the scene to initialize itself
            objSceneGame.sceneUI.InitializeScene();

            if (hideScene == true)
            {
                objSceneGame.sceneUI.HideScene();
            }
            return(objSceneGame.sceneUI);
        }
        else if (objSceneUI != null)
        {
#if UNITY_EDITOR
            UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create Object");
#endif
            Transform t = go.transform;
            t.SetParent(this.gameObject.transform);
            t.localPosition = Vector3.zero;
            t.localRotation = Quaternion.identity;
            t.localScale    = Vector3.one;
            go.layer        = this.gameObject.layer;

            objSceneUI.Page = page;

            LoadedScenes.Add(objSceneUI);
            // Allow the scene to initialize itself
            objSceneUI.InitializeScene();

            if (hideScene == true)
            {
                objSceneUI.HideScene();
            }
            return(objSceneUI);
        }
        else
        {
            PPP.pppShow();
        }
        return(null);
    }