protected void OnActiveSceneChanged(Scene oldScene, Scene newScene)
        {
            isLoading       = false;
            loadingProgress = 0f;

            SubScene newSceneSubScene = UnityVersionHandler.GetSceneInstance <SubScene> (newScene);

            if (newSceneSubScene)
            {
                // New active scene is a sub-scene
                newSceneSubScene.MakeMain();
            }

            if (!string.IsNullOrEmpty(oldScene.name))
            {
                SceneInfo oldSceneInfo = GetSceneInfo(oldScene.buildIndex);
                if (oldSceneInfo != null)
                {
                    MultiSceneChecker multiSceneChecker = MultiSceneChecker.GetSceneInstance(oldScene);
                    if (multiSceneChecker != null)
                    {
                        // Register as a subscene
                        GameObject subSceneOb = new GameObject();
                        UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(subSceneOb, oldScene);
                        SubScene oldSubScene = subSceneOb.AddComponent <SubScene> ();
                        oldSubScene.Initialise(multiSceneChecker);
                    }
                }
            }
        }
Exemple #2
0
        /**
         * <summary>Syncs the component with the correct scene.</summary>
         * <param name = "_multiSceneChecker">The MultiSceneChecker component in the scene for which this component is to sync with.</param>
         */
        public void Initialise(MultiSceneChecker _multiSceneChecker)
        {
            Scene scene = _multiSceneChecker.gameObject.scene;

            kickStarter = _multiSceneChecker.GetComponent <KickStarter>();

            sceneIndex      = scene.buildIndex;
            gameObject.name = "SubScene " + sceneIndex;

            localVariables = _multiSceneChecker.GetComponent <LocalVariables>();
            sceneSettings  = _multiSceneChecker.GetComponent <SceneSettings>();

            UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(gameObject, scene);

            kickStarter = _multiSceneChecker.GetComponent <KickStarter> ();
            _multiSceneChecker.gameObject.SetActive(false);

            mainCamera = UnityVersionHandler.GetOwnSceneInstance <MainCamera> (gameObject);
            if (mainCamera)
            {
                mainCamera.gameObject.SetActive(false);
            }

            Player ownPlayer = UnityVersionHandler.GetOwnSceneInstance <Player> (gameObject);

            if (ownPlayer)
            {
                ownPlayer.gameObject.SetActive(false);
            }
            if (sceneSettings.OverridesCameraPerspective())
            {
                ACDebug.LogError("The added scene (" + scene.name + ", " + scene.buildIndex + ") overrides the default camera perspective - this feature should not be used in conjunction with multiple-open scenes.", gameObject);
            }
            KickStarter.sceneChanger.RegisterSubScene(this);
        }
Exemple #3
0
        /**
         * <summary>Syncs the component with the correct scene.</summary>
         * <param name = "_multiSceneChecker">The MultiSceneChecker component in the scene for which this component is to sync with.</param>
         */
        public void Initialise(MultiSceneChecker _multiSceneChecker)
        {
                        #if UNITY_5_3 || UNITY_5_4 || UNITY_5_3_OR_NEWER
            UnityEngine.SceneManagement.Scene scene = _multiSceneChecker.gameObject.scene;
            gameObject.name = "SubScene " + scene.buildIndex;

            kickStarter = _multiSceneChecker.GetComponent <KickStarter>();

            sceneInfo = new SceneInfo(scene.name, scene.buildIndex);

            localVariables = _multiSceneChecker.GetComponent <LocalVariables>();
            sceneSettings  = _multiSceneChecker.GetComponent <SceneSettings>();

            UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(gameObject, scene);

            kickStarter = UnityVersionHandler.GetOwnSceneInstance <KickStarter> (gameObject);
            if (kickStarter != null)
            {
                kickStarter.gameObject.SetActive(false);
            }

            mainCamera = UnityVersionHandler.GetOwnSceneInstance <MainCamera> (gameObject);
            if (mainCamera != null)
            {
                mainCamera.gameObject.SetActive(false);
            }

            Player ownPlayer = UnityVersionHandler.GetOwnSceneInstance <Player> (gameObject);
            if (ownPlayer != null)
            {
                ownPlayer.gameObject.SetActive(false);
            }

            KickStarter.sceneChanger.RegisterSubScene(this);
                        #endif
        }
Exemple #4
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            string sceneName = MultiSceneChecker.EditActiveScene();

            if (sceneName != "")
            {
                EditorGUILayout.LabelField("Editing scene: '" + sceneName + "'", CustomStyles.subHeader);
                EditorGUILayout.Space();
            }

            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();

            string label = (vars.Count > 0) ? ("Global (" + vars.Count + ")") : "Global";

            if (GUILayout.Toggle(showGlobalTab, label, "toolbarbutton"))
            {
                SetTab(0);
            }

            label = (KickStarter.localVariables != null && KickStarter.localVariables.localVars.Count > 0) ? ("Local (" + KickStarter.localVariables.localVars.Count + ")") : "Local";
            if (GUILayout.Toggle(showLocalTab, label, "toolbarbutton"))
            {
                SetTab(1);
            }

            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSettings = CustomGUILayout.ToggleHeader(showSettings, "Editor settings");
            if (showSettings)
            {
                updateRuntime = CustomGUILayout.Toggle("Show realtime values?", updateRuntime, "AC.KickStarter.variablesManager.updateRuntime");
                filter        = EditorGUILayout.TextField("Filter by name:", filter);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            if (showGlobalTab)
            {
                varPresets = ShowPresets(varPresets, vars, VariableLocation.Global);

                if (Application.isPlaying && updateRuntime && KickStarter.runtimeVariables != null)
                {
                    ShowVarList(KickStarter.runtimeVariables.globalVars, VariableLocation.Global, false);
                }
                else
                {
                    ShowVarList(vars, VariableLocation.Global, true);

                    foreach (VarPreset varPreset in varPresets)
                    {
                        varPreset.UpdateCollection(vars);
                    }
                }
            }
            else if (showLocalTab)
            {
                if (KickStarter.localVariables != null)
                {
                    KickStarter.localVariables.varPresets = ShowPresets(KickStarter.localVariables.varPresets, KickStarter.localVariables.localVars, VariableLocation.Local);

                    if (Application.isPlaying && updateRuntime)
                    {
                        ShowVarList(KickStarter.localVariables.localVars, VariableLocation.Local, false);
                    }
                    else
                    {
                        ShowVarList(KickStarter.localVariables.localVars, VariableLocation.Local, true);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("Local variables", CustomStyles.subHeader);
                    EditorGUILayout.HelpBox("A GameEngine prefab must be present in the scene before Local variables can be defined", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            if (selectedVar != null && (!Application.isPlaying || !updateRuntime))
            {
                int i = selectedVar.id;
                if (vars.Contains(selectedVar))
                {
                    ShowVarGUI(VariableLocation.Global, varPresets, "AC.GlobalVariables.GetVariable (" + i + ")");
                }
                else if (KickStarter.localVariables != null && KickStarter.localVariables.localVars.Contains(selectedVar))
                {
                    ShowVarGUI(VariableLocation.Local, KickStarter.localVariables.varPresets, "AC.LocalVariables.GetVariable (" + i + ")");
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(this);

                if (KickStarter.localVariables != null)
                {
                    UnityVersionHandler.CustomSetDirty(KickStarter.localVariables);
                }
            }
        }
Exemple #5
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            string sceneName = MultiSceneChecker.EditActiveScene();

            if (sceneName != "")
            {
                EditorGUILayout.LabelField("Editing scene: '" + sceneName + "'", EditorStyles.boldLabel);
                EditorGUILayout.Space();
            }

            if (icon == null)
            {
                icon = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof(Texture2D));
            }

            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(showGlobal, "Global", "toolbarbutton"))
            {
                SetTab(0);
            }
            if (GUILayout.Toggle(showLocal, "Local", "toolbarbutton"))
            {
                SetTab(1);
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            updateRuntime = EditorGUILayout.Toggle("Show realtime values?", updateRuntime);
            filter        = EditorGUILayout.TextField("Filter by name:", filter);
            EditorGUILayout.Space();

            if (showGlobal)
            {
                varPresets = ShowPresets(varPresets, vars, VariableLocation.Global);

                if (Application.isPlaying && updateRuntime && KickStarter.runtimeVariables != null)
                {
                    ShowVarList(KickStarter.runtimeVariables.globalVars, VariableLocation.Global, false);
                }
                else
                {
                    ShowVarList(vars, VariableLocation.Global, true);

                    foreach (VarPreset varPreset in varPresets)
                    {
                        varPreset.UpdateCollection(vars);
                    }
                }
            }
            else if (showLocal)
            {
                if (KickStarter.localVariables != null)
                {
                    KickStarter.localVariables.varPresets = ShowPresets(KickStarter.localVariables.varPresets, KickStarter.localVariables.localVars, VariableLocation.Local);

                    if (Application.isPlaying && updateRuntime)
                    {
                        ShowVarList(KickStarter.localVariables.localVars, VariableLocation.Local, false);
                    }
                    else
                    {
                        ShowVarList(KickStarter.localVariables.localVars, VariableLocation.Local, true);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("Local variables", EditorStyles.boldLabel);
                    EditorGUILayout.HelpBox("A GameEngine prefab must be present in the scene before Local variables can be defined", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            if (selectedVar != null && (!Application.isPlaying || !updateRuntime))
            {
                if (vars.Contains(selectedVar))
                {
                    ShowVarGUI(VariableLocation.Global, varPresets);
                }
                else if (KickStarter.localVariables != null && KickStarter.localVariables.localVars.Contains(selectedVar))
                {
                    ShowVarGUI(VariableLocation.Local, KickStarter.localVariables.varPresets);
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(this);

                if (KickStarter.localVariables != null)
                {
                    EditorUtility.SetDirty(KickStarter.localVariables);
                }
            }
        }