Example #1
0
        protected void CheckRequiredManagerPackage(ManagerPackage requiredManagerPackage)
        {
            if (requiredManagerPackage == null)
            {
                return;
            }

                        #if UNITY_EDITOR
            if ((requiredManagerPackage.sceneManager && requiredManagerPackage.sceneManager != KickStarter.sceneManager) ||
                (requiredManagerPackage.settingsManager && requiredManagerPackage.settingsManager != KickStarter.settingsManager) ||
                (requiredManagerPackage.actionsManager && requiredManagerPackage.actionsManager != KickStarter.actionsManager) ||
                (requiredManagerPackage.variablesManager && requiredManagerPackage.variablesManager != KickStarter.variablesManager) ||
                (requiredManagerPackage.inventoryManager && requiredManagerPackage.inventoryManager != KickStarter.inventoryManager) ||
                (requiredManagerPackage.speechManager && requiredManagerPackage.speechManager != KickStarter.speechManager) ||
                (requiredManagerPackage.cursorManager && requiredManagerPackage.cursorManager != KickStarter.cursorManager) ||
                (requiredManagerPackage.menuManager && requiredManagerPackage.menuManager != KickStarter.menuManager))
            {
                if (requiredManagerPackage.settingsManager)
                {
                    if (requiredManagerPackage.settingsManager.name == "Demo_SettingsManager" && UnityVersionHandler.GetCurrentSceneName() == "Basement")
                    {
                        ACDebug.LogWarning("The demo scene's required Manager asset files are not all loaded - please stop the game, and choose 'Adventure Creator -> Getting started -> Load 3D Demo managers from the top toolbar, and re-load the scene.", requiredManagerPackage);
                        return;
                    }
                    else if (requiredManagerPackage.settingsManager.name == "Demo2D_SettingsManager" && UnityVersionHandler.GetCurrentSceneName() == "Park")
                    {
                        ACDebug.LogWarning("The 2D demo scene's required Manager asset files are not all loaded - please stop the game, and choose 'Adventure Creator -> Getting started -> Load 2D Demo managers from the top toolbar, and re-load the scene.", requiredManagerPackage);
                        return;
                    }
                }

                ACDebug.LogWarning("This scene's required Manager asset files are not all loaded - please find the asset file '" + requiredManagerPackage.name + "' and click 'Assign managers' in its Inspector.", requiredManagerPackage);
            }
                        #endif
        }
        public override void OnInspectorGUI()
        {
            ManagerPackage _target = (ManagerPackage)target;

            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Manager asset files", EditorStyles.boldLabel);
            _target.sceneManager     = (SceneManager)EditorGUILayout.ObjectField("Scene manager:", _target.sceneManager, typeof(SceneManager), false);
            _target.settingsManager  = (SettingsManager)EditorGUILayout.ObjectField("Settings manager:", _target.settingsManager, typeof(SettingsManager), false);
            _target.actionsManager   = (ActionsManager)EditorGUILayout.ObjectField("Actions manager:", _target.actionsManager, typeof(ActionsManager), false);
            _target.variablesManager = (VariablesManager)EditorGUILayout.ObjectField("Variables manager:", _target.variablesManager, typeof(VariablesManager), false);
            _target.inventoryManager = (InventoryManager)EditorGUILayout.ObjectField("Inventory manager:", _target.inventoryManager, typeof(InventoryManager), false);
            _target.speechManager    = (SpeechManager)EditorGUILayout.ObjectField("Speech manager:", _target.speechManager, typeof(SpeechManager), false);
            _target.cursorManager    = (CursorManager)EditorGUILayout.ObjectField("Cursor manager:", _target.cursorManager, typeof(CursorManager), false);
            _target.menuManager      = (MenuManager)EditorGUILayout.ObjectField("Menu manager:", _target.menuManager, typeof(MenuManager), false);
            CustomGUILayout.EndVertical();

            EditorGUILayout.Space();

            if (GUILayout.Button("Assign managers"))
            {
                Undo.RecordObject(AdvGame.GetReferences(), "Assign managers");
                _target.AssignManagers();
                AdventureCreator.RefreshActions();
                AdventureCreator.Init();
            }

            EditorUtility.SetDirty(_target);
        }
Example #3
0
        static void Demo3D()
        {
            ManagerPackage package = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/ManagerPackage.asset", typeof(ManagerPackage)) as ManagerPackage;

            package.AssignManagers();
            AdventureCreator.RefreshActions();
        }
        static void Demo3D()
        {
            ManagerPackage package = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/ManagerPackage.asset", typeof(ManagerPackage)) as ManagerPackage;

            if (package != null)
            {
                package.AssignManagers();
                AdventureCreator.RefreshActions();

                if (!ACInstaller.IsInstalled())
                {
                    ACInstaller.DoInstall();
                }

                if (UnityVersionHandler.GetCurrentSceneName() != "Basement")
                {
                                        #if UNITY_5_3 || UNITY_5_4 || UNITY_5_3_OR_NEWER
                    bool canProceed = EditorUtility.DisplayDialog("Open demo scene", "Would you like to open the 3D Demo scene, Basement, now?", "Yes", "No");
                    if (canProceed)
                    {
                        if (UnityVersionHandler.SaveSceneIfUserWants())
                        {
                            UnityEditor.SceneManagement.EditorSceneManager.OpenScene("Assets/AdventureCreator/Demo/Scenes/Basement.unity");
                        }
                    }
                                        #else
                    ACDebug.Log("3D Demo managers loaded - you can now run the 3D Demo scene in 'Assets/AdventureCreator/Demo/Scenes/Basement.unity'");
                                        #endif
                }

                AdventureCreator.Init();
            }
        }
 public static bool OnOpenAsset(int instanceID, int line)
 {
     if (Selection.activeObject is ManagerPackage)
     {
         ManagerPackage managerPackage = (ManagerPackage)Selection.activeObject as ManagerPackage;
         Undo.RecordObject(AdvGame.GetReferences(), "Assign managers");
         managerPackage.AssignManagers();
         AdventureCreator.RefreshActions();
         return(true);
     }
     return(false);
 }
Example #6
0
        private void CreateManagerPackage(string folder)
        {
            ManagerPackage managerPackage = CustomAssetUtility.CreateAsset <ManagerPackage> ("ManagerPackage", folder);

            AssetDatabase.RenameAsset("Assets/" + folder + "/ManagerPackage.asset", folder + "_ManagerPackage");

            managerPackage.sceneManager     = references.sceneManager;
            managerPackage.settingsManager  = references.settingsManager;
            managerPackage.actionsManager   = references.actionsManager;
            managerPackage.variablesManager = references.variablesManager;

            managerPackage.inventoryManager = references.inventoryManager;
            managerPackage.speechManager    = references.speechManager;
            managerPackage.cursorManager    = references.cursorManager;
            managerPackage.menuManager      = references.menuManager;

            EditorUtility.SetDirty(managerPackage);
            AssetDatabase.SaveAssets();
        }
Example #7
0
        private ManagerPackage CreateManagerPackage(string folder, SceneManager sceneManager, SettingsManager settingsManager, ActionsManager actionsManager, VariablesManager variablesManager, InventoryManager inventoryManager, SpeechManager speechManager, CursorManager cursorManager, MenuManager menuManager)
        {
            ManagerPackage managerPackage = CustomAssetUtility.CreateAsset <ManagerPackage> ("ManagerPackage", folder);

            AssetDatabase.RenameAsset("Assets/" + folder + "/ManagerPackage.asset", folder + "_ManagerPackage");

            managerPackage.sceneManager     = sceneManager;
            managerPackage.settingsManager  = settingsManager;
            managerPackage.actionsManager   = actionsManager;
            managerPackage.variablesManager = variablesManager;

            managerPackage.inventoryManager = inventoryManager;
            managerPackage.speechManager    = speechManager;
            managerPackage.cursorManager    = cursorManager;
            managerPackage.menuManager      = menuManager;

            managerPackage.AssignManagers();
            EditorUtility.SetDirty(managerPackage);
            AssetDatabase.SaveAssets();

            AdventureCreator.Init();

            return(managerPackage);
        }
Example #8
0
        private void Finish()
        {
            if (!references)
            {
                GetReferences();
            }

            if (!references)
            {
                return;
            }

            string managerPath = gameName + "/Managers";

            try
            {
                System.IO.Directory.CreateDirectory(Application.dataPath + "/" + managerPath);
            }
            catch (System.Exception e)
            {
                ACDebug.LogError("Wizard aborted - Could not create directory: " + Application.dataPath + "/" + managerPath + ". Please make sure the Assets direcrory is writeable, and that the intended game name contains no special characters.");
                Debug.LogException(e, this);
                pageNumber--;
                return;
            }

            try
            {
                ShowProgress(0f);

                ScriptableObject t = CustomAssetUtility.CreateAsset <SceneManager> ("SceneManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager");
                references.sceneManager = (SceneManager)t;

                ShowProgress(0.1f);

                t = CustomAssetUtility.CreateAsset <SettingsManager> ("SettingsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager");
                references.settingsManager = (SettingsManager)t;

                references.settingsManager.saveFileName      = gameName;
                references.settingsManager.cameraPerspective = cameraPerspective;
                references.settingsManager.movingTurning     = movingTurning;
                references.settingsManager.movementMethod    = movementMethod;
                references.settingsManager.inputMethod       = inputMethod;
                references.settingsManager.interactionMethod = interactionMethod;
                references.settingsManager.hotspotDetection  = hotspotDetection;
                if (cameraPerspective == CameraPerspective.TwoPointFiveD)
                {
                    references.settingsManager.forceAspectRatio = true;
                }

                ShowProgress(0.2f);

                t = CustomAssetUtility.CreateAsset <ActionsManager> ("ActionsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager");
                references.actionsManager = (ActionsManager)t;
                AdventureCreator.RefreshActions();
                ActionsManager defaultActionsManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager;
                if (defaultActionsManager != null)
                {
                    references.actionsManager.defaultClass     = defaultActionsManager.defaultClass;
                    references.actionsManager.defaultClassName = defaultActionsManager.defaultClassName;
                }

                ShowProgress(0.3f);

                t = CustomAssetUtility.CreateAsset <VariablesManager> ("VariablesManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager");
                references.variablesManager = (VariablesManager)t;

                ShowProgress(0.4f);

                t = CustomAssetUtility.CreateAsset <InventoryManager> ("InventoryManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager");
                references.inventoryManager = (InventoryManager)t;

                ShowProgress(0.5f);

                t = CustomAssetUtility.CreateAsset <SpeechManager> ("SpeechManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager");
                references.speechManager = (SpeechManager)t;
                references.speechManager.ClearLanguages();

                ShowProgress(0.6f);

                t = CustomAssetUtility.CreateAsset <CursorManager> ("CursorManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager");
                references.cursorManager = (CursorManager)t;

                ShowProgress(0.7f);

                t = CustomAssetUtility.CreateAsset <MenuManager> ("MenuManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager");
                references.menuManager = (MenuManager)t;

                CursorManager defaultCursorManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_CursorManager.asset", typeof(CursorManager)) as CursorManager;
                if (wizardMenu == WizardMenu.Blank)
                {
                    if (defaultCursorManager != null)
                    {
                        CursorIcon useIcon = new CursorIcon();
                        useIcon.Copy(defaultCursorManager.cursorIcons[0], false);
                        references.cursorManager.cursorIcons.Add(useIcon);
                        EditorUtility.SetDirty(references.cursorManager);
                    }
                }
                else
                {
                    if (defaultCursorManager != null)
                    {
                        foreach (CursorIcon defaultIcon in defaultCursorManager.cursorIcons)
                        {
                            CursorIcon newIcon = new CursorIcon();
                            newIcon.Copy(defaultIcon, false);
                            references.cursorManager.cursorIcons.Add(newIcon);
                        }

                        CursorIconBase pointerIcon = new CursorIconBase();
                        pointerIcon.Copy(defaultCursorManager.pointerIcon);
                        references.cursorManager.pointerIcon = pointerIcon;
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_CursorManager asset to copy from!");
                    }

                    references.cursorManager.allowMainCursor = true;
                    EditorUtility.SetDirty(references.cursorManager);

                    MenuManager defaultMenuManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_MenuManager.asset", typeof(MenuManager)) as MenuManager;
                    if (defaultMenuManager != null)
                    {
                                                #if UNITY_EDITOR
                        references.menuManager.drawOutlines = defaultMenuManager.drawOutlines;
                        references.menuManager.drawInEditor = defaultMenuManager.drawInEditor;
                                                #endif
                        references.menuManager.pauseTexture = defaultMenuManager.pauseTexture;

                        if (wizardMenu != WizardMenu.Blank)
                        {
                            System.IO.Directory.CreateDirectory(Application.dataPath + "/" + gameName + "/UI");
                        }

                        foreach (Menu defaultMenu in defaultMenuManager.menus)
                        {
                            float progress = (float)defaultMenuManager.menus.IndexOf(defaultMenu) / (float)defaultMenuManager.menus.Count;
                            ShowProgress((progress * 0.3f) + 0.7f);

                            Menu newMenu = ScriptableObject.CreateInstance <Menu>();
                            newMenu.Copy(defaultMenu, true, true);
                            newMenu.Recalculate();

                            if (wizardMenu == WizardMenu.DefaultAC)
                            {
                                newMenu.menuSource = MenuSource.AdventureCreator;
                            }
                            else if (wizardMenu == WizardMenu.DefaultUnityUI)
                            {
                                newMenu.menuSource = MenuSource.UnityUiPrefab;
                            }

                            if (defaultMenu.canvas)
                            {
                                string oldPath = AssetDatabase.GetAssetPath(defaultMenu.canvas.gameObject);
                                string newPath = "Assets/" + gameName + "/UI/" + defaultMenu.canvas.name + ".prefab";

                                if (AssetDatabase.CopyAsset(oldPath, newPath))
                                {
                                    AssetDatabase.ImportAsset(newPath);
                                    GameObject canvasObNewPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(newPath, typeof(GameObject));
                                    newMenu.canvas = canvasObNewPrefab.GetComponent <Canvas>();
                                }
                                else
                                {
                                    newMenu.canvas = null;
                                    ACDebug.LogWarning("Could not copy asset " + oldPath + " to " + newPath, defaultMenu.canvas.gameObject);
                                }
                                newMenu.rectTransform = null;
                            }

                            foreach (MenuElement newElement in newMenu.elements)
                            {
                                if (newElement != null)
                                {
                                    AssetDatabase.AddObjectToAsset(newElement, references.menuManager);
                                    newElement.hideFlags = HideFlags.HideInHierarchy;
                                }
                                else
                                {
                                    ACDebug.LogWarning("Null element found in " + newMenu.title + " - the interface may not be set up correctly.");
                                }
                            }

                            if (newMenu != null)
                            {
                                AssetDatabase.AddObjectToAsset(newMenu, references.menuManager);
                                newMenu.hideFlags = HideFlags.HideInHierarchy;

                                references.menuManager.menus.Add(newMenu);
                            }
                            else
                            {
                                ACDebug.LogWarning("Unable to create new Menu from original '" + defaultMenu.title + "'");
                            }
                        }

                        EditorUtility.SetDirty(references.menuManager);

                                                #if CAN_USE_TIMELINE
                        if (references.speechManager != null)
                        {
                            references.speechManager.previewMenuName = "Subtitles";
                            EditorUtility.SetDirty(references.speechManager);
                        }
                                                #endif
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_MenuManager asset to copy from!");
                    }
                }

                EditorUtility.ClearProgressBar();
                ManagerPackage newManagerPackage = CreateManagerPackage(gameName);

                AssetDatabase.SaveAssets();

                if (newManagerPackage == null || !newManagerPackage.IsFullyAssigned())
                {
                    EditorUtility.DisplayDialog("Wizard failed", "The New Game Wizard failed to generate a new 'Manager Package' file with all eight Managers assigned. Pleae verify that your Assets directory is writable and try again.", "OK");
                }
                else if (GameObject.FindObjectOfType <KickStarter>() == null)
                {
                    bool initScene = EditorUtility.DisplayDialog("Organise scene?", "Process complete.  Would you like to organise the scene objects to begin working?  This can be done at any time within the Scene Manager.", "Yes", "No");
                    if (initScene)
                    {
                        references.sceneManager.InitialiseObjects();
                    }
                }
            }
            catch (System.Exception e)
            {
                ACDebug.LogWarning("Could not create Manager. Does the subdirectory " + managerPath + " exist?");
                Debug.LogException(e, this);
                pageNumber--;
            }
        }