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);
        }
示例#2
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();
            }
        }
示例#4
0
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            AdventureCreator window = (AdventureCreator)EditorWindow.GetWindow(typeof(AdventureCreator));

            window.GetReferences();
            UnityVersionHandler.SetWindowTitle(window, "AC Game Editor");
        }
示例#5
0
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            AdventureCreator window = (AdventureCreator)EditorWindow.GetWindow(typeof(AdventureCreator));

            window.GetReferences();
            window.titleContent.text = "AC Game Editor";
        }
 private void OnEnable()
 {
     if (AdvGame.GetReferences())
     {
         if (AdvGame.GetReferences().actionsManager)
         {
             actionsManager = AdvGame.GetReferences().actionsManager;
             AdventureCreator.RefreshActions();
         }
     }
 }
 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);
 }
示例#8
0
 private void OnEnable()
 {
     if (AdvGame.GetReferences())
     {
         if (AdvGame.GetReferences().actionsManager)
         {
             actionsManager = AdvGame.GetReferences().actionsManager;
             AdventureCreator.RefreshActions();
         }
         else
         {
             ACDebug.LogError("An Actions Manager is required - please use the Game Editor window to create one.");
         }
     }
     else
     {
         ACDebug.LogError("A References file is required - please use the Game Editor window to create one.");
     }
 }
        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();

            AdventureCreator.Init();
        }
示例#10
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);
        }
        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
            {
                ScriptableObject t = CustomAssetUtility.CreateAsset <SceneManager> ("SceneManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager");
                references.sceneManager = (SceneManager)t;

                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;
                }

                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;
                }

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

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

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

                references.speechManager.ClearLanguages();

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

                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]);
                        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);
                            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)
                        {
                            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 newCanvasPath = "Assets/" + gameName + "/UI/" + defaultMenu.canvas.name + ".prefab";

                                GameObject canvasObInScene = (GameObject)PrefabUtility.InstantiatePrefab(defaultMenu.canvas.gameObject);
                                PrefabUtility.DisconnectPrefabInstance(canvasObInScene);
                                GameObject canvasObNewPrefab = PrefabUtility.CreatePrefab(newCanvasPath, canvasObInScene);

                                newMenu.canvas = canvasObNewPrefab.GetComponent <Canvas>();
                                DestroyImmediate(canvasObInScene);

                                newMenu.rectTransform = null;
                            }

                            foreach (MenuElement newElement in newMenu.elements)
                            {
                                AssetDatabase.AddObjectToAsset(newElement, references.menuManager);
                                newElement.hideFlags = HideFlags.HideInHierarchy;
                            }
                            AssetDatabase.AddObjectToAsset(newMenu, references.menuManager);
                            newMenu.hideFlags = HideFlags.HideInHierarchy;

                            references.menuManager.menus.Add(newMenu);
                        }

                        EditorUtility.SetDirty(references.menuManager);
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_MenuManager asset to copy from!");
                    }
                }

                CreateManagerPackage(gameName);

                AssetDatabase.SaveAssets();
                if (GameObject.FindObjectOfType <KickStarter>() == null)
                {
                    bool initScene = EditorUtility.DisplayDialog("Setup 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--;
            }
        }
示例#12
0
        private void Finish()
        {
            if (!references)
            {
                GetReferences();
            }

            if (!references)
            {
                return;
            }

            string managerPath = gameName + "/Managers";

            try
            {
                System.IO.Directory.CreateDirectory(Application.dataPath + "/" + managerPath);
            }
            catch
            {
                Debug.LogWarning("Could not create directory: " + Application.dataPath + "/" + managerPath);
                pageNumber--;
                return;
            }

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

                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.movementMethod    = movementMethod;
                references.settingsManager.inputMethod       = inputMethod;
                references.settingsManager.interactionMethod = interactionMethod;
                references.settingsManager.hotspotDetection  = hotspotDetection;
                references.settingsManager.movingTurning     = movingTurning;
                if (cameraPerspective == CameraPerspective.TwoPointFiveD)
                {
                    references.settingsManager.forceAspectRatio = true;
                }

                t = CustomAssetUtility.CreateAsset <ActionsManager> ("ActionsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager");
                references.actionsManager = (ActionsManager)t;
                AdventureCreator.RefreshActions();
                ActionsManager demoActionsManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager;
                if (demoActionsManager != null)
                {
                    references.actionsManager.defaultClass = demoActionsManager.defaultClass;
                }

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

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

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

                references.speechManager.ClearLanguages();

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

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

                if (wizardMenu != WizardMenu.Blank)
                {
                    CursorManager demoCursorManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_CursorManager.asset", typeof(CursorManager)) as CursorManager;
                    if (demoCursorManager != null)
                    {
                        foreach (CursorIcon demoIcon in demoCursorManager.cursorIcons)
                        {
                            CursorIcon newIcon = new CursorIcon();
                            newIcon.Copy(demoIcon);
                            references.cursorManager.cursorIcons.Add(newIcon);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Cannot find Demo_CursorManager asset to copy from!");
                    }
                    references.cursorManager.allowMainCursor = true;

                    CursorIconBase pointerIcon = new CursorIconBase();
                    pointerIcon.Copy(demoCursorManager.pointerIcon);
                    references.cursorManager.pointerIcon = pointerIcon;
                    EditorUtility.SetDirty(references.cursorManager);

                    MenuManager demoMenuManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_MenuManager.asset", typeof(MenuManager)) as MenuManager;
                    if (demoMenuManager != null)
                    {
                        references.menuManager.drawOutlines = demoMenuManager.drawOutlines;
                        references.menuManager.drawInEditor = demoMenuManager.drawInEditor;
                        references.menuManager.pauseTexture = demoMenuManager.pauseTexture;

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

                        foreach (Menu demoMenu in demoMenuManager.menus)
                        {
                            Menu newMenu = ScriptableObject.CreateInstance <Menu>();
                            newMenu.Copy(demoMenu);

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

                                if (demoMenu.canvas)
                                {
                                    string oldCanvasPath = AssetDatabase.GetAssetPath(demoMenu.canvas);
                                    string newCanvasPath = "Assets/" + gameName + "/UI/" + demoMenu.canvas.name + ".prefab";
                                    if (AssetDatabase.CopyAsset(oldCanvasPath, newCanvasPath))
                                    {
                                        AssetDatabase.ImportAsset(newCanvasPath);
                                        newMenu.canvas = (Canvas)AssetDatabase.LoadAssetAtPath(newCanvasPath, typeof(Canvas));
                                    }
                                }
                            }

                            newMenu.hideFlags = HideFlags.HideInHierarchy;
                            references.menuManager.menus.Add(newMenu);
                            EditorUtility.SetDirty(references.menuManager);
                            foreach (MenuElement newElement in newMenu.elements)
                            {
                                newElement.hideFlags = HideFlags.HideInHierarchy;
                                AssetDatabase.AddObjectToAsset(newElement, references.menuManager);
                            }
                            AssetDatabase.AddObjectToAsset(newMenu, references.menuManager);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Cannot find Demo_MenuManager asset to copy from!");
                    }
                }

                CreateManagerPackage(gameName);

                AssetDatabase.SaveAssets();
                references.sceneManager.InitialiseObjects();
                pageNumber = 0;
            }
            catch
            {
                Debug.LogWarning("Could not create Manager. Does the subdirectory " + Resource.managersDirectory + " exist?");
                pageNumber--;
            }
        }
示例#13
0
        private void OnGUI()
        {
            GUILayout.BeginVertical(CustomStyles.thinBox, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

            GUILayout.Label(GetTitle(), CustomStyles.managerHeader);
            if (GetTitle() != "")
            {
                EditorGUILayout.Separator();
                GUILayout.Space(10f);
            }

            if (references == null)
            {
                GetReferences();
            }
            if (references == null)
            {
                AdventureCreator.MissingReferencesGUI();
                GUILayout.EndHorizontal();
                return;
            }

            ShowPage();

            GUILayout.Space(15f);
            GUILayout.BeginHorizontal();
            if (pageNumber < 1)
            {
                if (pageNumber < 0)
                {
                    pageNumber = 0;
                }
                GUI.enabled = false;
            }
            if (pageNumber < numPages)
            {
                if (GUILayout.Button("Previous", EditorStyles.miniButtonLeft))
                {
                    pageNumber--;
                }
            }
            else
            {
                if (GUILayout.Button("Restart", EditorStyles.miniButtonLeft))
                {
                    pageNumber = 0;
                    gameName   = "";
                }
            }
            GUI.enabled = true;
            if (pageNumber < numPages - 1)
            {
                if (pageNumber == 1 && gameName == "")
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Next", EditorStyles.miniButtonRight))
                {
                    pageNumber++;
                    if (pageNumber == numPages - 1)
                    {
                        Process();
                        return;
                    }
                }
                GUI.enabled = true;
            }
            else
            {
                if (pageNumber == numPages)
                {
                    if (GUILayout.Button("Close", EditorStyles.miniButtonRight))
                    {
                        NewGameWizardWindow window = (NewGameWizardWindow)EditorWindow.GetWindow(typeof(NewGameWizardWindow));
                        pageNumber = 0;
                        window.Close();
                        return;
                    }
                }
                else
                {
                    if (GUILayout.Button("Finish", EditorStyles.miniButtonRight))
                    {
                        pageNumber++;
                        Finish();
                        return;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUI.Label(pageRect, "Page " + (pageNumber + 1) + " of " + (numPages + 1));

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
        }
示例#14
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--;
            }
        }