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); SceneManager newSceneManager = CustomAssetUtility.CreateAsset <SceneManager> ("SceneManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager"); references.sceneManager = newSceneManager; ShowProgress(0.1f); SettingsManager newSettingsManager = CustomAssetUtility.CreateAsset <SettingsManager> ("SettingsManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager"); newSettingsManager.saveFileName = gameName; newSettingsManager.cameraPerspective = cameraPerspective; newSettingsManager.movingTurning = movingTurning; newSettingsManager.movementMethod = movementMethod; newSettingsManager.inputMethod = inputMethod; newSettingsManager.interactionMethod = interactionMethod; newSettingsManager.hotspotDetection = hotspotDetection; if (cameraPerspective == CameraPerspective.TwoPointFiveD) { newSettingsManager.forceAspectRatio = true; } references.settingsManager = newSettingsManager; ShowProgress(0.2f); ActionsManager newActionsManager = CustomAssetUtility.CreateAsset <ActionsManager> ("ActionsManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager"); ActionsManager defaultActionsManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager; if (defaultActionsManager != null) { newActionsManager.defaultClass = defaultActionsManager.defaultClass; newActionsManager.defaultClassName = defaultActionsManager.defaultClassName; } references.actionsManager = newActionsManager; AdventureCreator.RefreshActions(); ShowProgress(0.3f); VariablesManager newVariablesManager = CustomAssetUtility.CreateAsset <VariablesManager> ("VariablesManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager"); references.variablesManager = newVariablesManager; ShowProgress(0.4f); InventoryManager newInventoryManager = CustomAssetUtility.CreateAsset <InventoryManager> ("InventoryManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager"); references.inventoryManager = newInventoryManager; ShowProgress(0.5f); SpeechManager newSpeechManager = CustomAssetUtility.CreateAsset <SpeechManager> ("SpeechManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager"); newSpeechManager.ClearLanguages(); references.speechManager = newSpeechManager; ShowProgress(0.6f); CursorManager newCursorManager = CustomAssetUtility.CreateAsset <CursorManager> ("CursorManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager"); references.cursorManager = newCursorManager; ShowProgress(0.7f); MenuManager newMenuManager = CustomAssetUtility.CreateAsset <MenuManager> ("MenuManager", managerPath); AssetDatabase.RenameAsset("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager"); references.menuManager = (MenuManager)newMenuManager; 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); newCursorManager.cursorIcons.Add(useIcon); EditorUtility.SetDirty(newCursorManager); } } else { if (defaultCursorManager != null) { foreach (CursorIcon defaultIcon in defaultCursorManager.cursorIcons) { CursorIcon newIcon = new CursorIcon(); newIcon.Copy(defaultIcon, false); newCursorManager.cursorIcons.Add(newIcon); } CursorIconBase pointerIcon = new CursorIconBase(); pointerIcon.Copy(defaultCursorManager.pointerIcon); newCursorManager.pointerIcon = pointerIcon; newCursorManager.lookCursor_ID = defaultCursorManager.lookCursor_ID; } else { ACDebug.LogWarning("Cannot find Default_CursorManager asset to copy from!"); } newCursorManager.allowMainCursor = true; EditorUtility.SetDirty(newCursorManager); MenuManager defaultMenuManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_MenuManager.asset", typeof(MenuManager)) as MenuManager; if (defaultMenuManager != null) { #if UNITY_EDITOR newMenuManager.drawOutlines = defaultMenuManager.drawOutlines; newMenuManager.drawInEditor = defaultMenuManager.drawInEditor; #endif newMenuManager.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 (newMenu.pauseWhenEnabled) { bool autoSelectUI = (inputMethod == InputMethod.KeyboardOrController); newMenu.autoSelectFirstVisibleElement = autoSelectUI; } 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, newMenuManager); 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, newMenuManager); newMenu.hideFlags = HideFlags.HideInHierarchy; newMenuManager.menus.Add(newMenu); } else { ACDebug.LogWarning("Unable to create new Menu from original '" + defaultMenu.title + "'"); } } EditorUtility.SetDirty(newMenuManager); if (newSpeechManager != null) { newSpeechManager.previewMenuName = "Subtitles"; EditorUtility.SetDirty(newSpeechManager); } } else { ACDebug.LogWarning("Cannot find Default_MenuManager asset to copy from!"); } } EditorUtility.ClearProgressBar(); ManagerPackage newManagerPackage = CreateManagerPackage(gameName, newSceneManager, newSettingsManager, newActionsManager, newVariablesManager, newInventoryManager, newSpeechManager, newCursorManager, newMenuManager); 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. Check your '/Assets/" + gameName + "/Managers' directory - the Managers may have been created, and just need assigning in the ManagerPackage asset Inspector, found in '/Assets/" + gameName + "'.", "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) { newSceneManager.InitialiseObjects(); } } } catch (System.Exception e) { ACDebug.LogWarning("Could not create Manager. Does the subdirectory " + managerPath + " exist?"); Debug.LogException(e, this); pageNumber--; } }