public override void OnInspectorGUI() { _target = (Variables)target; ShowSettings(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showVariablesList = CustomGUILayout.ToggleHeader(showVariablesList, "Component variables"); if (showVariablesList) { selectedVar = VariablesManager.ShowVarList(selectedVar, _target.vars, VariableLocation.Component, varFilter, _target.filter, typeFilter, !Application.isPlaying, _target); } EditorGUILayout.EndVertical(); if (selectedVar != null) { EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showProperties = CustomGUILayout.ToggleHeader(showProperties, "Variable '" + selectedVar.label + "' properties"); if (showProperties) { VariablesManager.ShowVarGUI(selectedVar, VariableLocation.Component, !Application.isPlaying, null, string.Empty, _target); } EditorGUILayout.EndVertical(); } UnityVersionHandler.CustomSetDirty(_target); }
private GVar GetVariable() { switch (location) { case VariableLocation.Global: VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; if (variablesManager != null) { return(variablesManager.GetVariable(variableID)); } return(null); case VariableLocation.Local: return(LocalVariables.GetVariable(variableID)); case VariableLocation.Component: if (variables != null) { return(variables.GetVariable(variableID)); } break; } return(null); }
public bool IsTranslatable () { if (setVarMethodString == SetVarMethodString.EnteredHere && setParameterID < 0) { GVar variable = null; if (location == VariableLocation.Global) { VariablesManager variablesManager = AdvGame.GetReferences ().variablesManager; if (variablesManager != null) { variable = variablesManager.GetVariable (variableID); } } else { variable = LocalVariables.GetVariable (variableID); } if (variable != null && variable.type == VariableType.String) { return true; } } return false; }
public void _Init(VariablesManager _variablesManager) { variablesManager = _variablesManager; exportColumns.Clear(); exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.Location)); exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.SceneName)); exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.Label)); exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.Type)); exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.InitialValue)); }
override public void ShowGUI(List <ActionParameter> parameters) { if (isAssetFile) { location = VariableLocation.Global; } else { location = (VariableLocation)EditorGUILayout.EnumPopup("Source:", location); } if (isAssetFile && getVarMethod == GetVarMethod.LocalVariable) { EditorGUILayout.HelpBox("Local Variables cannot be referenced by Asset-based Actions.", MessageType.Warning); } if (location == VariableLocation.Global) { if (AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, ParameterType.GlobalVariable); if (parameterID >= 0) { variableID = ShowVarGUI(parameters, variablesManager.vars, variableID, false); } else { variableID = ShowVarGUI(parameters, variablesManager.vars, variableID, true); } } } else if (location == VariableLocation.Local) { if (localVariables) { parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, ParameterType.LocalVariable); if (parameterID >= 0) { variableID = ShowVarGUI(parameters, localVariables.localVars, variableID, false); } else { variableID = ShowVarGUI(parameters, localVariables.localVars, variableID, true); } } else { EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info); } } }
/** * Clears the internal Manager references. Call this when changing the assigned Managers, so that other Inspectors/Editors get updated to reflect this */ public static void ClearManagerCache() { sceneManagerPrefab = null; settingsManagerPrefab = null; actionsManagerPrefab = null; variablesManagerPrefab = null; inventoryManagerPrefab = null; speechManagerPrefab = null; cursorManagerPrefab = null; menuManagerPrefab = null; }
private void TransferFromManager() { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; globalVars.Clear(); foreach (GVar assetVar in variablesManager.vars) { globalVars.Add(new GVar(assetVar)); } } }
/** * <summary>Initialises the window.</summary> */ public static void Init(VariablesManager _variablesManager) { if (_variablesManager == null) { return; } VarExportWizardWindow window = EditorWindow.GetWindowWithRect <VarExportWizardWindow> (new Rect(0, 0, 350, 500), true, "Variables exporter", true); UnityVersionHandler.SetWindowTitle(window, "Variables exporter"); window.position = new Rect(300, 200, 350, 500); window._Init(_variablesManager); }
/** * <summary>Initialises the window.</summary> */ public static void Init(VariablesManager _variablesManager) { if (_variablesManager == null) { return; } VarExportWizardWindow window = (VarExportWizardWindow)EditorWindow.GetWindow(typeof(VarExportWizardWindow)); UnityVersionHandler.SetWindowTitle(window, "Variables exporter"); window.position = new Rect(300, 200, 350, 500); window._Init(_variablesManager); }
public static int GlobalVariableGUI(string label, int variableID) { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; // Create a string List of the field's names (for the PopUp box) List <string> labelList = new List <string>(); int i = 0; int variableNumber = -1; if (variablesManager.vars.Count > 0) { foreach (GVar _var in variablesManager.vars) { labelList.Add(_var.label); // If a GlobalVar variable has been removed, make sure selected variable is still valid if (_var.id == variableID) { variableNumber = i; } i++; } if (variableNumber == -1) { // Wasn't found (variable was deleted?), so revert to zero Debug.LogWarning("Previously chosen variable no longer exists!"); variableNumber = 0; variableID = 0; } variableNumber = EditorGUILayout.Popup(label, variableNumber, labelList.ToArray()); variableID = variablesManager.vars [variableNumber].id; } else { EditorGUILayout.HelpBox("No global variables exist!", MessageType.Info); variableID = -1; } } else { EditorGUILayout.HelpBox("No Variables Manager exists!", MessageType.Info); variableID = -1; } return(variableID); }
/** Downloads variables from the Global Manager to the scene. */ public void TransferFromManager() { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; globalVars.Clear(); foreach (GVar assetVar in variablesManager.vars) { GVar newVar = new GVar(assetVar); newVar.CreateRuntimeTranslations(); globalVars.Add(newVar); } } }
private GVar GetVariable() { if (location == VariableLocation.Global) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; if (variablesManager != null) { return(variablesManager.GetVariable(variableID)); } return(null); } else { return(LocalVariables.GetVariable(variableID)); } }
/** * <summary>Unsets the values of all script variables, so that they can be re-assigned to the correct scene if multiple scenes are open.</summary> */ public void ClearVariables() { playerPrefab = null; mainCameraPrefab = null; persistentEnginePrefab = null; gameEnginePrefab = null; // Managers sceneManagerPrefab = null; settingsManagerPrefab = null; actionsManagerPrefab = null; variablesManagerPrefab = null; inventoryManagerPrefab = null; speechManagerPrefab = null; cursorManagerPrefab = null; menuManagerPrefab = null; // PersistentEngine components optionsComponent = null; runtimeInventoryComponent = null; runtimeVariablesComponent = null; playerMenusComponent = null; stateHandlerComponent = null; sceneChangerComponent = null; saveSystemComponent = null; levelStorageComponent = null; runtimeLanguagesComponent = null; actionListAssetManagerComponent = null; // GameEngine components menuSystemComponent = null; dialogComponent = null; playerInputComponent = null; playerInteractionComponent = null; playerMovementComponent = null; playerCursorComponent = null; playerQTEComponent = null; sceneSettingsComponent = null; navigationManagerComponent = null; actionListManagerComponent = null; localVariablesComponent = null; menuPreviewComponent = null; eventManagerComponent = null; SetGameEngine(); }
protected void TransferFromManager() { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; globalVars.Clear(); foreach (GVar assetVar in variablesManager.vars) { globalVars.Add(new GVar(assetVar)); } foreach (GVar _var in globalVars) { _var.CreateRuntimeTranslations(); } } }
public void _Init(VariableLocation _variableLocation, bool _allScenes, Variables _variables) { variableLocation = _variableLocation; variablesManager = KickStarter.variablesManager; variables = _variables; allScenes = _allScenes; exportColumns.Clear(); exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.Location)); if (variableLocation == VariableLocation.Local) { exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.SceneName)); } exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.Label)); exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.Type)); exportColumns.Add(new ExportColumn(ExportColumn.ColumnType.InitialValue)); }
private void UpdateSelf() { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; globalVars.Clear(); foreach (GVar assetVar in variablesManager.vars) { globalVars.Add(new GVar(assetVar)); } // Options Variables if (GetComponent <Options>() && GetComponent <Options>().optionsData != null && GetComponent <Options>().optionsData.linkedVariables != "") { SaveSystem.AssignVariables(GetComponent <Options>().optionsData.linkedVariables, true); } } }
private void OnGUI() { if (AdvGame.GetReferences().settingsManager == null) { EditorGUILayout.HelpBox("A Settings Manager must be assigned before this window can display correctly.", MessageType.Warning); return; } SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; sceneAttributes = settingsManager.sceneAttributes; EditorGUILayout.HelpBox("Values for attributes defined here can be set in the Scene Manager, and checked using the 'Scene: Check attribute' Action.", MessageType.Info); EditorGUILayout.Space(); CreateAttributesGUI(); if (selectedSceneAttribute != null && sceneAttributes.Contains(selectedSceneAttribute)) { EditorGUILayout.Space(); string apiPrefix = "AC.KickStarter.variablesManager.GetProperty (" + selectedSceneAttribute.id + ")"; EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Inventory property '" + selectedSceneAttribute.label + "' properties", CustomStyles.subHeader); EditorGUILayout.Space(); selectedSceneAttribute.label = CustomGUILayout.TextField("Name:", selectedSceneAttribute.label, apiPrefix + ".label"); selectedSceneAttribute.type = (VariableType)CustomGUILayout.EnumPopup("Type:", selectedSceneAttribute.type, apiPrefix + ".type"); if (selectedSceneAttribute.type == VariableType.PopUp) { selectedSceneAttribute.popUps = VariablesManager.PopupsGUI(selectedSceneAttribute.popUps); } EditorGUILayout.EndVertical(); } settingsManager.sceneAttributes = sceneAttributes; if (GUI.changed) { EditorUtility.SetDirty(settingsManager); } }
public static void ShowLocalParametersGUI(List <ActionParameter> localParameters, List <ActionParameter> assetParameters, bool isAssetFile) { int numParameters = assetParameters.Count; if (numParameters < localParameters.Count) { localParameters.RemoveRange(numParameters, localParameters.Count - numParameters); } else if (numParameters > localParameters.Count) { if (numParameters > localParameters.Capacity) { localParameters.Capacity = numParameters; } for (int i = localParameters.Count; i < numParameters; i++) { ActionParameter newParameter = new ActionParameter(ActionListEditor.GetParameterIDArray(localParameters)); localParameters.Add(newParameter); } } for (int i = 0; i < numParameters; i++) { string label = assetParameters[i].label; localParameters[i].parameterType = assetParameters[i].parameterType; if (assetParameters[i].parameterType == ParameterType.String) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(label + ":", GUILayout.Width(145f)); EditorStyles.textField.wordWrap = true; localParameters[i].stringValue = EditorGUILayout.TextArea(localParameters[i].stringValue, GUILayout.MaxWidth(400f)); EditorGUILayout.EndHorizontal(); } else if (assetParameters[i].parameterType == ParameterType.Float) { localParameters[i].floatValue = EditorGUILayout.FloatField(label + ":", localParameters[i].floatValue); } else if (assetParameters[i].parameterType == ParameterType.Integer) { localParameters[i].intValue = EditorGUILayout.IntField(label + ":", localParameters[i].intValue); } else if (assetParameters[i].parameterType == ParameterType.Boolean) { BoolValue boolValue = BoolValue.False; if (localParameters[i].intValue == 1) { boolValue = BoolValue.True; } boolValue = (BoolValue)EditorGUILayout.EnumPopup(label + ":", boolValue); if (boolValue == BoolValue.True) { localParameters[i].intValue = 1; } else { localParameters[i].intValue = 0; } } else if (assetParameters[i].parameterType == ParameterType.GlobalVariable) { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; localParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", variablesManager.vars, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("A Variables Manager is required to pass Global Variables.", MessageType.Warning); } } else if (assetParameters[i].parameterType == ParameterType.InventoryItem) { if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; localParameters[i].intValue = ActionRunActionList.ShowInvItemSelectorGUI(label + ":", inventoryManager.items, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Inventory items.", MessageType.Warning); } } else if (assetParameters[i].parameterType == ParameterType.LocalVariable) { if (KickStarter.localVariables) { localParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", KickStarter.localVariables.localVars, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("A GameEngine prefab is required to pass Local Variables.", MessageType.Warning); } } if (assetParameters[i].parameterType == ParameterType.GameObject) { if (isAssetFile) { // ID localParameters[i].intValue = EditorGUILayout.IntField(label + " (ID):", localParameters[i].intValue); localParameters[i].gameObject = null; } else { // Gameobject localParameters[i].gameObject = (GameObject)EditorGUILayout.ObjectField(label + ":", localParameters[i].gameObject, typeof(GameObject), true); localParameters[i].intValue = 0; if (localParameters[i].gameObject != null && localParameters[i].gameObject.GetComponent <ConstantID>() == null) { localParameters[i].gameObject.AddComponent <ConstantID>(); } } } else if (assetParameters[i].parameterType == ParameterType.UnityObject) { localParameters[i].objectValue = (Object)EditorGUILayout.ObjectField(label + ":", localParameters[i].objectValue, typeof(Object), true); } } }
private void SetParametersGUI(List <ActionParameter> externalParameters, List <ActionParameter> ownParameters) { setParameters = EditorGUILayout.Toggle("Set parameters?", setParameters); if (!setParameters) { return; } SyncLists(externalParameters, localParameters); EditorGUILayout.BeginVertical("Button"); for (int i = 0; i < externalParameters.Count; i++) { string label = externalParameters[i].label; int linkedID = parameterIDs[i]; localParameters[i].parameterType = externalParameters[i].parameterType; if (externalParameters[i].parameterType == ParameterType.GameObject) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.GameObject); if (linkedID < 0) { if (isAssetFile) { localParameters[i].gameObject = (GameObject)EditorGUILayout.ObjectField(label + ":", localParameters[i].gameObject, typeof(GameObject), true); if (localParameters[i].gameObject != null) { if (PrefabUtility.GetPrefabType(localParameters[i].gameObject) != PrefabType.Prefab) { localParameters[i].intValue = FieldToID(localParameters[i].gameObject, localParameters[i].intValue); localParameters[i].gameObject = IDToField(localParameters[i].gameObject, localParameters[i].intValue, true); } } else { localParameters[i].intValue = EditorGUILayout.IntField(label + " (ID #):", localParameters[i].intValue); } } else { // Gameobject localParameters[i].gameObject = (GameObject)EditorGUILayout.ObjectField(label + ":", localParameters[i].gameObject, typeof(GameObject), true); localParameters[i].intValue = 0; if (localParameters[i].gameObject != null && localParameters[i].gameObject.GetComponent <ConstantID>() == null) { localParameters[i].gameObject.AddComponent <ConstantID>(); } } } } else if (externalParameters[i].parameterType == ParameterType.UnityObject) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.UnityObject); if (linkedID < 0) { localParameters[i].objectValue = (Object)EditorGUILayout.ObjectField(label + ":", localParameters[i].objectValue, typeof(Object), true); } } else if (externalParameters[i].parameterType == ParameterType.GlobalVariable) { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.GlobalVariable); if (linkedID < 0) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; localParameters[i].intValue = ShowVarSelectorGUI(label + ":", variablesManager.vars, localParameters[i].intValue); } } else { EditorGUILayout.HelpBox("A Variables Manager is required to pass Global Variables.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.InventoryItem) { if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.InventoryItem); if (linkedID < 0) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; localParameters[i].intValue = ShowInvItemSelectorGUI(label + ":", inventoryManager.items, localParameters[i].intValue); } } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Inventory items.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.LocalVariable) { if (KickStarter.localVariables) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.LocalVariable); if (linkedID < 0) { localParameters[i].intValue = ShowVarSelectorGUI(label + ":", KickStarter.localVariables.localVars, localParameters[i].intValue); } } else { EditorGUILayout.HelpBox("A GameEngine prefab is required to pass Local Variables.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.String) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.String); if (linkedID < 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(label + ":", GUILayout.Width(145f)); EditorStyles.textField.wordWrap = true; localParameters[i].stringValue = EditorGUILayout.TextArea(localParameters[i].stringValue, GUILayout.MaxWidth(400f)); EditorGUILayout.EndHorizontal(); } } else if (externalParameters[i].parameterType == ParameterType.Float) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Float); if (linkedID < 0) { localParameters[i].floatValue = EditorGUILayout.FloatField(label + ":", localParameters[i].floatValue); } } else if (externalParameters[i].parameterType == ParameterType.Integer) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Integer); if (linkedID < 0) { localParameters[i].intValue = EditorGUILayout.IntField(label + ":", localParameters[i].intValue); } } else if (externalParameters[i].parameterType == ParameterType.Vector3) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Vector3); if (linkedID < 0) { localParameters[i].vector3Value = EditorGUILayout.Vector3Field(label + ":", localParameters[i].vector3Value); } } else if (externalParameters[i].parameterType == ParameterType.Boolean) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Boolean); if (linkedID < 0) { BoolValue boolValue = BoolValue.False; if (localParameters[i].intValue == 1) { boolValue = BoolValue.True; } boolValue = (BoolValue)EditorGUILayout.EnumPopup(label + ":", boolValue); if (boolValue == BoolValue.True) { localParameters[i].intValue = 1; } else { localParameters[i].intValue = 0; } } } parameterIDs[i] = linkedID; } EditorGUILayout.EndVertical(); }
override public void ShowGUI (List<ActionParameter> parameters) { if (isAssetFile) { location = VariableLocation.Global; } else { location = (VariableLocation) EditorGUILayout.EnumPopup ("Source:", location); } if (location == VariableLocation.Global) { if (!variablesManager) { variablesManager = AdvGame.GetReferences ().variablesManager; } if (variablesManager) { ShowVarGUI (variablesManager.vars, parameters, ParameterType.GlobalVariable); } } else if (location == VariableLocation.Local) { if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>()) { localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>(); } if (localVariables) { ShowVarGUI (localVariables.localVars, parameters, ParameterType.LocalVariable); } } }
private void Awake() { // Test for key imports References references = (References)Resources.Load(Resource.references); if (references) { SceneManager sceneManager = AdvGame.GetReferences().sceneManager; SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; SpeechManager speechManager = AdvGame.GetReferences().speechManager; CursorManager cursorManager = AdvGame.GetReferences().cursorManager; MenuManager menuManager = AdvGame.GetReferences().menuManager; if (sceneManager == null) { Debug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard"); } if (settingsManager == null) { Debug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard"); } else { if (settingsManager.IsInLoadingScene()) { Debug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene."); return; } if (!GameObject.FindGameObjectWithTag(Tags.player)) { KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity); } else { KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>(); if (sceneChanger != null && sceneChanger.GetPlayerOnTransition() != null && settingsManager.playerSwitching == PlayerSwitching.DoNotAllow) { // Replace "prefab" player with a local one if one exists GameObject[] playerObs = GameObject.FindGameObjectsWithTag(Tags.player); foreach (GameObject playerOb in playerObs) { if (playerOb.GetComponent <Player>() && sceneChanger.GetPlayerOnTransition() != playerOb.GetComponent <Player>()) { KickStarter.sceneChanger.DestroyOldPlayer(); KickStarter.playerPrefab = playerOb.GetComponent <Player>(); break; } } } } } if (actionsManager == null) { Debug.LogError("No Actions Manager found - please set one using the main Adventure Creator window"); } if (inventoryManager == null) { Debug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window"); } if (variablesManager == null) { Debug.LogError("No Variables Manager found - please set one using the main Adventure Creator window"); } if (speechManager == null) { Debug.LogError("No Speech Manager found - please set one using the main Adventure Creator window"); } if (cursorManager == null) { Debug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window"); } if (menuManager == null) { Debug.LogError("No Menu Manager found - please set one using the main Adventure Creator window"); } if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None) { Debug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder"); } } else { Debug.LogError("No References object found. Please set one using the main Adventure Creator window"); } if (persistentEnginePrefab == null) { try { persistentEnginePrefab = (GameObject)Instantiate(Resources.Load(Resource.persistentEngine)); persistentEnginePrefab.name = AdvGame.GetName(Resource.persistentEngine); } catch {} } if (persistentEnginePrefab == null) { Debug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine"); } else { if (persistentEnginePrefab.GetComponent <Options>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no Options component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached."); } if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached."); } if (persistentEnginePrefab.GetComponent <StateHandler>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached."); } if (persistentEnginePrefab.GetComponent <SceneChanger>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached."); } if (persistentEnginePrefab.GetComponent <SaveSystem>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached."); } if (persistentEnginePrefab.GetComponent <LevelStorage>() == null) { Debug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached."); } } if (GameObject.FindWithTag(Tags.mainCamera) == null) { Debug.LogError("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one."); } else { if (GameObject.FindWithTag(Tags.mainCamera).GetComponent <MainCamera>() == null) { Debug.LogError("MainCamera has no MainCamera component."); } } if (this.GetComponent <MenuSystem>() == null) { Debug.LogError(this.name + " has no MenuSystem component attached."); } if (this.GetComponent <Dialog>() == null) { Debug.LogError(this.name + " has no Dialog component attached."); } if (this.GetComponent <PlayerInput>() == null) { Debug.LogError(this.name + " has no PlayerInput component attached."); } if (this.GetComponent <PlayerInteraction>() == null) { Debug.LogError(this.name + " has no PlayerInteraction component attached."); } if (this.GetComponent <PlayerMovement>() == null) { Debug.LogError(this.name + " has no PlayerMovement component attached."); } if (this.GetComponent <PlayerCursor>() == null) { Debug.LogError(this.name + " has no PlayerCursor component attached."); } if (this.GetComponent <PlayerQTE>() == null) { Debug.LogError(this.name + " has no PlayerQTE component attached."); } if (this.GetComponent <SceneSettings>() == null) { Debug.LogError(this.name + " has no SceneSettings component attached."); } else { if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null) { // No NavMesh, are there Characters in the scene? AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[]; if (allChars.Length > 0) { Debug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager."); } } if (this.GetComponent <SceneSettings>().defaultPlayerStart == null) { Debug.LogWarning("No default PlayerStart set. The game may not be able to begin if one is not defined - please choose one using the Scene Manager."); } } if (this.GetComponent <NavigationManager>() == null) { Debug.LogError(this.name + " has no NavigationManager component attached."); } if (this.GetComponent <ActionListManager>() == null) { Debug.LogError(this.name + " has no ActionListManager component attached."); } }
public override void ShowGUI(List <ActionParameter> parameters) { location = (VariableLocation)EditorGUILayout.EnumPopup("Source:", location); if (isAssetFile && getVarMethod == GetVarMethod.LocalVariable) { EditorGUILayout.HelpBox("Local Variables cannot be referenced by Asset-based Actions.", MessageType.Warning); return; } switch (location) { case VariableLocation.Global: if (AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, ParameterType.GlobalVariable); if (parameterID >= 0) { placeholderType = (VariableType)EditorGUILayout.EnumPopup("Placeholder type:", placeholderType); variableID = ShowVarGUI(parameters, variablesManager.vars, variableID, false); } else { variableID = ShowVarGUI(parameters, variablesManager.vars, variableID, true); } } break; case VariableLocation.Local: if (localVariables != null) { parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, ParameterType.LocalVariable); if (parameterID >= 0) { placeholderType = (VariableType)EditorGUILayout.EnumPopup("Placeholder type:", placeholderType); variableID = ShowVarGUI(parameters, localVariables.localVars, variableID, false); } else { variableID = ShowVarGUI(parameters, localVariables.localVars, variableID, true); } } else { EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info); } break; case VariableLocation.Component: parameterID = Action.ChooseParameterGUI("Variable:", parameters, parameterID, ParameterType.ComponentVariable); if (parameterID >= 0) { placeholderType = (VariableType)EditorGUILayout.EnumPopup("Placeholder type:", placeholderType); variableID = ShowVarGUI(parameters, (variables != null) ? variables.vars : null, variableID, false); } else { variables = (Variables)EditorGUILayout.ObjectField("Component:", variables, typeof(Variables), true); variablesConstantID = FieldToID <Variables> (variables, variablesConstantID); variables = IDToField <Variables> (variables, variablesConstantID, false); if (variables != null) { variableID = ShowVarGUI(parameters, variables.vars, variableID, true); } } break; } }
/// <summary> /// Gets the variable ID array. To add a new variable, AC needs a reference to the /// current IDs. This generates the list of current IDs. /// </summary> /// <returns>The variable ID array.</returns> /// <param name="variablesManager">Variables manager.</param> private static int[] GetVarIDArray(VariablesManager variablesManager) { List<int> idArray = new List<int>(); foreach (GVar var in GlobalVariables.GetAllVars()) { idArray.Add(var.id); } idArray.Sort(); return idArray.ToArray(); }
public void OnAwake() { ClearVariables(); // Test for key imports References references = (References)Resources.Load(Resource.references); if (references) { SceneManager sceneManager = AdvGame.GetReferences().sceneManager; SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; SpeechManager speechManager = AdvGame.GetReferences().speechManager; CursorManager cursorManager = AdvGame.GetReferences().cursorManager; MenuManager menuManager = AdvGame.GetReferences().menuManager; if (sceneManager == null) { ACDebug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard"); } if (settingsManager == null) { ACDebug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard"); } else { if (settingsManager.IsInLoadingScene()) { ACDebug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene."); SetPersistentEngine(); return; } // Unity 5.3 has a bug whereby a modified Player prefab is placed in the scene when editing, but not visible // This causes the Player to not load properly, so try to detect this remnant and delete it! GameObject existingPlayer = GameObject.FindGameObjectWithTag(Tags.player); if (existingPlayer != null) { if (settingsManager.GetDefaultPlayer() != null && existingPlayer.name == (settingsManager.GetDefaultPlayer().name + "(Clone)")) { DestroyImmediate(GameObject.FindGameObjectWithTag(Tags.player)); ACDebug.LogWarning("Player clone found in scene - this may have been hidden by a Unity bug, and has been destroyed."); } } if (!GameObject.FindGameObjectWithTag(Tags.player)) { KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity); } else { KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>(); if (sceneChanger == null || sceneChanger.GetPlayerOnTransition() == null) { // New local player if (KickStarter.playerPrefab != null) { KickStarter.playerPrefab.Initialise(); } } AssignLocalPlayer(); } } if (actionsManager == null) { ACDebug.LogError("No Actions Manager found - please set one using the main Adventure Creator window"); } if (inventoryManager == null) { ACDebug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window"); } if (variablesManager == null) { ACDebug.LogError("No Variables Manager found - please set one using the main Adventure Creator window"); } if (speechManager == null) { ACDebug.LogError("No Speech Manager found - please set one using the main Adventure Creator window"); } if (cursorManager == null) { ACDebug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window"); } if (menuManager == null) { ACDebug.LogError("No Menu Manager found - please set one using the main Adventure Creator window"); } if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None) { ACDebug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder"); } } else { ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window"); } SetPersistentEngine(); if (persistentEnginePrefab == null) { ACDebug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine"); } else { if (persistentEnginePrefab.GetComponent <Options>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no Options component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached."); } if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached."); } if (persistentEnginePrefab.GetComponent <StateHandler>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached."); } if (persistentEnginePrefab.GetComponent <SceneChanger>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached."); } if (persistentEnginePrefab.GetComponent <SaveSystem>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached."); } if (persistentEnginePrefab.GetComponent <LevelStorage>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached."); } if (persistentEnginePrefab.GetComponent <RuntimeLanguages>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeLanguages component attached."); } if (persistentEnginePrefab.GetComponent <ActionListAssetManager>() == null) { ACDebug.LogError(persistentEnginePrefab.name + " has no ActionListAssetManager component attached."); } } if (this.GetComponent <MenuSystem>() == null) { ACDebug.LogError(this.name + " has no MenuSystem component attached."); } if (this.GetComponent <Dialog>() == null) { ACDebug.LogError(this.name + " has no Dialog component attached."); } if (this.GetComponent <PlayerInput>() == null) { ACDebug.LogError(this.name + " has no PlayerInput component attached."); } if (this.GetComponent <PlayerInteraction>() == null) { ACDebug.LogError(this.name + " has no PlayerInteraction component attached."); } if (this.GetComponent <PlayerMovement>() == null) { ACDebug.LogError(this.name + " has no PlayerMovement component attached."); } if (this.GetComponent <PlayerCursor>() == null) { ACDebug.LogError(this.name + " has no PlayerCursor component attached."); } if (this.GetComponent <PlayerQTE>() == null) { ACDebug.LogError(this.name + " has no PlayerQTE component attached."); } if (this.GetComponent <SceneSettings>() == null) { ACDebug.LogError(this.name + " has no SceneSettings component attached."); } else { if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null) { // No NavMesh, are there Characters in the scene? AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[]; if (allChars.Length > 0) { ACDebug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager."); } } if (this.GetComponent <SceneSettings>().defaultPlayerStart == null) { if (AdvGame.GetReferences().settingsManager == null || AdvGame.GetReferences().settingsManager.GetDefaultPlayer() != null) { ACDebug.LogWarning("No default PlayerStart set. The game may not be able to begin if one is not defined - please choose one using the Scene Manager."); } } } if (this.GetComponent <NavigationManager>() == null) { ACDebug.LogError(this.name + " has no NavigationManager component attached."); } if (this.GetComponent <ActionListManager>() == null) { ACDebug.LogError(this.name + " has no ActionListManager component attached."); } if (this.GetComponent <EventManager>() == null) { ACDebug.LogError(this.name + " has no EventManager component attached."); } }
override public string SetLabel () { if (location == VariableLocation.Local && !isAssetFile) { if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>()) { localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>(); } if (localVariables) { return GetLabelString (localVariables.localVars); } } else { if (!variablesManager) { variablesManager = AdvGame.GetReferences ().variablesManager; } if (variablesManager) { return GetLabelString (variablesManager.vars); } } return ""; }
private int ShowVarGUI (List<ActionParameter> parameters, List<GVar> vars, int ID, bool changeID) { if (vars.Count > 0) { if (changeID) { ID = ShowVarSelectorGUI (vars, ID); } variableNumber = Mathf.Min (variableNumber, vars.Count-1); getVarMethod = (GetVarMethod) EditorGUILayout.EnumPopup ("Compare with:", getVarMethod); if (parameters == null || parameters.Count == 0) { EditorGUILayout.BeginHorizontal (); } if (vars [variableNumber].type == VariableType.Boolean) { boolCondition = (BoolCondition) EditorGUILayout.EnumPopup (boolCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("Boolean:", parameters, checkParameterID, ParameterType.Boolean); if (checkParameterID < 0) { boolValue = (BoolValue) EditorGUILayout.EnumPopup ("Boolean:", boolValue); } } } else if (vars [variableNumber].type == VariableType.Integer) { intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("Integer:", parameters, checkParameterID, ParameterType.Integer); if (checkParameterID < 0) { intValue = EditorGUILayout.IntField ("Integer:", intValue); } } } else if (vars [variableNumber].type == VariableType.PopUp) { intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("Value:", parameters, checkParameterID, ParameterType.Integer); if (checkParameterID < 0) { intValue = EditorGUILayout.Popup ("Value:", intValue, vars [variableNumber].popUps); } } } else if (vars [variableNumber].type == VariableType.Float) { intCondition = (IntCondition) EditorGUILayout.EnumPopup (intCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("Float:", parameters, checkParameterID, ParameterType.Float); if (checkParameterID < 0) { floatValue = EditorGUILayout.FloatField ("Float:", floatValue); } } } else if (vars [variableNumber].type == VariableType.String) { boolCondition = (BoolCondition) EditorGUILayout.EnumPopup (boolCondition); if (getVarMethod == GetVarMethod.EnteredValue) { checkParameterID = Action.ChooseParameterGUI ("String:", parameters, checkParameterID, ParameterType.String); if (checkParameterID < 0) { stringValue = EditorGUILayout.TextField ("String:", stringValue); } } } if (getVarMethod == GetVarMethod.GlobalVariable) { if (!variablesManager) { variablesManager = AdvGame.GetReferences ().variablesManager; } if (variablesManager == null || variablesManager.vars == null || variablesManager.vars.Count == 0) { EditorGUILayout.HelpBox ("No Global variables exist!", MessageType.Info); } else { checkParameterID = Action.ChooseParameterGUI ("Global variable:", parameters, checkParameterID, ParameterType.GlobalVariable); if (checkParameterID < 0) { compareVariableID = ShowVarSelectorGUI (variablesManager.vars, compareVariableID); } } } else if (getVarMethod == GetVarMethod.LocalVariable) { if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>()) { localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>(); } if (localVariables == null || localVariables.localVars == null || localVariables.localVars.Count == 0) { EditorGUILayout.HelpBox ("No Local variables exist!", MessageType.Info); } else { checkParameterID = Action.ChooseParameterGUI ("Local variable:", parameters, checkParameterID, ParameterType.LocalVariable); if (checkParameterID < 0) { compareVariableID = ShowVarSelectorGUI (localVariables.localVars, compareVariableID); } } } if (parameters == null || parameters.Count == 0) { EditorGUILayout.EndHorizontal (); } } else { EditorGUILayout.HelpBox ("No variables exist!", MessageType.Info); ID = -1; variableNumber = -1; } return ID; }
override public void ShowGUI (List<ActionParameter> parameters) { if (isAssetFile) { location = VariableLocation.Global; } else { location = (VariableLocation) EditorGUILayout.EnumPopup ("Source:", location); } if (isAssetFile && getVarMethod == GetVarMethod.LocalVariable) { EditorGUILayout.HelpBox ("Local Variables cannot be referenced by Asset-based Actions.", MessageType.Warning); } if (location == VariableLocation.Global) { if (!variablesManager) { variablesManager = AdvGame.GetReferences ().variablesManager; } if (variablesManager) { parameterID = Action.ChooseParameterGUI ("Variable:", parameters, parameterID, ParameterType.GlobalVariable); if (parameterID >= 0) { variableID = ShowVarGUI (parameters, variablesManager.vars, variableID, false); } else { variableID = ShowVarGUI (parameters, variablesManager.vars, variableID, true); } } } else if (location == VariableLocation.Local) { if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>()) { localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>(); } if (localVariables) { parameterID = Action.ChooseParameterGUI ("Variable:", parameters, parameterID, ParameterType.LocalVariable); if (parameterID >= 0) { variableID = ShowVarGUI (parameters, localVariables.localVars, variableID, false); } else { variableID = ShowVarGUI (parameters, localVariables.localVars, variableID, true); } } } }
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); }
override public void ShowGUI (List<ActionParameter> parameters) { // OLD if (isAssetFile) { oldLocation = VariableLocation.Global; } else { oldLocation = (VariableLocation) EditorGUILayout.EnumPopup ("'From' source:", oldLocation); } if (oldLocation == VariableLocation.Global) { if (!variablesManager) { variablesManager = AdvGame.GetReferences ().variablesManager; } if (variablesManager) { oldVariableID = ShowVarGUI (variablesManager.vars, parameters, ParameterType.GlobalVariable, oldVariableID, oldParameterID, false); } } else if (oldLocation == VariableLocation.Local) { if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>()) { localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>(); } if (localVariables) { oldVariableID = ShowVarGUI (localVariables.localVars, parameters, ParameterType.LocalVariable, oldVariableID, oldParameterID, false); } } EditorGUILayout.Space (); // NEW if (isAssetFile) { newLocation = VariableLocation.Global; } else { newLocation = (VariableLocation) EditorGUILayout.EnumPopup ("'To' source:", newLocation); } if (newLocation == VariableLocation.Global) { if (!variablesManager) { variablesManager = AdvGame.GetReferences ().variablesManager; } if (variablesManager) { newVariableID = ShowVarGUI (variablesManager.vars, parameters, ParameterType.GlobalVariable, newVariableID, newParameterID, true); } } else if (newLocation == VariableLocation.Local) { if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>()) { localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>(); } if (localVariables) { newVariableID = ShowVarGUI (localVariables.localVars, parameters, ParameterType.LocalVariable, newVariableID, newParameterID, true); } } // Types match? if (oldParameterID == -1 && newParameterID == -1 && newVarType != oldVarType) { EditorGUILayout.HelpBox ("The chosen Variables do not share the same Type", MessageType.Warning); } AfterRunningOption (); }
override public void ShowGUI (List<ActionParameter> parameters) { if (isAssetFile) { location = VariableLocation.Global; } else { location = (VariableLocation) EditorGUILayout.EnumPopup ("Source:", location); } if (location == VariableLocation.Global) { if (!variablesManager) { variablesManager = AdvGame.GetReferences ().variablesManager; } if (variablesManager) { parameterID = Action.ChooseParameterGUI ("Integer variable:", parameters, parameterID, ParameterType.GlobalVariable); if (parameterID >= 0) { variableID = ShowVarGUI (variablesManager.vars, variableID, false); } else { variableID = ShowVarGUI (variablesManager.vars, variableID, true); } } } else if (location == VariableLocation.Local) { if (!localVariables && GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent<LocalVariables>()) { localVariables = GameObject.FindWithTag (Tags.gameEngine).GetComponent <LocalVariables>(); } if (localVariables) { parameterID = Action.ChooseParameterGUI ("Integer variable:", parameters, parameterID, ParameterType.LocalVariable); if (parameterID >= 0) { variableID = ShowVarGUI (localVariables.localVars, variableID, false); } else { variableID = ShowVarGUI (localVariables.localVars, variableID, true); } } } numSockets = EditorGUILayout.IntSlider ("# of possible values:", numSockets, 1, 10); doLoop = EditorGUILayout.Toggle ("Run on a loop?", doLoop); }
/** * <summary>Unsets the values of all script variables, so that they can be re-assigned to the correct scene if multiple scenes are open.</summary> */ public void ClearVariables() { playerPrefab = null; mainCameraPrefab = null; persistentEnginePrefab = null; gameEnginePrefab = null; // Managers sceneManagerPrefab = null; settingsManagerPrefab = null; actionsManagerPrefab = null; variablesManagerPrefab = null; inventoryManagerPrefab = null; speechManagerPrefab = null; cursorManagerPrefab = null; menuManagerPrefab = null; // PersistentEngine components optionsComponent = null; runtimeInventoryComponent = null; runtimeVariablesComponent = null; playerMenusComponent = null; stateHandlerComponent = null; sceneChangerComponent = null; saveSystemComponent = null; levelStorageComponent = null; runtimeLanguagesComponent = null; // GameEngine components menuSystemComponent = null; dialogComponent = null; playerInputComponent = null; playerInteractionComponent = null; playerMovementComponent = null; playerCursorComponent = null; playerQTEComponent = null; sceneSettingsComponent = null; navigationManagerComponent = null; actionListManagerComponent = null; localVariablesComponent = null; menuPreviewComponent = null; SetGameEngine (); }
protected bool TestManagerPresence() { References references = (References)Resources.Load(Resource.references); if (references) { SceneManager sceneManager = AdvGame.GetReferences().sceneManager; SettingsManager settingsManager = AdvGame.GetReferences().settingsManager; ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; SpeechManager speechManager = AdvGame.GetReferences().speechManager; CursorManager cursorManager = AdvGame.GetReferences().cursorManager; MenuManager menuManager = AdvGame.GetReferences().menuManager; string missingManagers = string.Empty; if (sceneManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Scene"; } if (settingsManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Settings"; } if (actionsManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Actions"; } if (variablesManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Variables"; } if (inventoryManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Inventory"; } if (speechManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Speech"; } if (cursorManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Cursor"; } if (menuManager == null) { if (!string.IsNullOrEmpty(missingManagers)) { missingManagers += ", "; } missingManagers += "Menu"; } if (!string.IsNullOrEmpty(missingManagers)) { ACDebug.LogError("Unassigned AC Manager(s): " + missingManagers + " - all Managers must be assigned in the AC Game Editor window for AC to initialise"); return(false); } } else { ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window"); return(false); } return(true); }
private void SetParametersGUI(List <ActionParameter> externalParameters) { // Ensure target and local parameter lists match int numParameters = externalParameters.Count; if (numParameters < localParameters.Count) { localParameters.RemoveRange(numParameters, localParameters.Count - numParameters); } else if (numParameters > localParameters.Count) { if (numParameters > localParameters.Capacity) { localParameters.Capacity = numParameters; } for (int i = localParameters.Count; i < numParameters; i++) { ActionParameter newParameter = new ActionParameter(externalParameters [i].ID); localParameters.Add(newParameter); } } EditorGUILayout.BeginVertical("Button"); for (int i = 0; i < externalParameters.Count; i++) { string label = externalParameters[i].label; if (externalParameters[i].parameterType == ParameterType.GameObject) { if (isAssetFile) { // ID localParameters[i].intValue = EditorGUILayout.IntField(label + " (ID):", localParameters[i].intValue); localParameters[i].gameObject = null; } else { /// Gameobject localParameters[i].gameObject = (GameObject)EditorGUILayout.ObjectField(label + ":", localParameters[i].gameObject, typeof(GameObject), true); localParameters[i].intValue = 0; if (localParameters[i].gameObject != null && localParameters[i].gameObject.GetComponent <ConstantID>() == null) { localParameters[i].gameObject.AddComponent <ConstantID>(); } } } else if (externalParameters[i].parameterType == ParameterType.GlobalVariable) { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; localParameters[i].intValue = ShowVarSelectorGUI(label + ":", variablesManager.vars, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("A Variables Manager is required to pass Global Variables.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.InventoryItem) { if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; localParameters[i].intValue = ShowInvItemSelectorGUI(label + ":", inventoryManager.items, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Inventory items.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.LocalVariable) { if (KickStarter.localVariables) { localParameters[i].intValue = ShowVarSelectorGUI(label + ":", KickStarter.localVariables.localVars, localParameters[i].intValue); } else { EditorGUILayout.HelpBox("A GameEngine prefab is required to pass Local Variables.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.String) { localParameters[i].stringValue = EditorGUILayout.TextField(label + ":", localParameters[i].stringValue); } else if (externalParameters[i].parameterType == ParameterType.Float) { localParameters[i].floatValue = EditorGUILayout.FloatField(label + ":", localParameters[i].floatValue); } else if (externalParameters[i].parameterType == ParameterType.Integer) { localParameters[i].intValue = EditorGUILayout.IntField(label + ":", localParameters[i].intValue); } else if (externalParameters[i].parameterType == ParameterType.Boolean) { BoolValue boolValue = BoolValue.False; if (localParameters[i].intValue == 1) { boolValue = BoolValue.True; } boolValue = (BoolValue)EditorGUILayout.EnumPopup(label + ":", boolValue); if (boolValue == BoolValue.True) { localParameters[i].intValue = 1; } else { localParameters[i].intValue = 0; } } } EditorGUILayout.EndVertical(); }
public void ShowGUI(bool isAssetFile, bool onlyEditValues = false, bool readOnly = false) { if (Application.isPlaying || readOnly) { EditorGUILayout.LabelField("Type:", parameterType.ToString()); EditorGUILayout.LabelField("Current value:", "'" + GetLabel() + "'"); CustomGUILayout.TokenLabel("[param:" + ID.ToString() + "]"); } else { if (onlyEditValues) { EditorGUILayout.LabelField("Type:", parameterType.ToString()); } else { parameterType = (ParameterType)EditorGUILayout.EnumPopup("Type:", parameterType); } switch (parameterType) { case ParameterType.Boolean: BoolValue boolValue = (intValue == 1) ? BoolValue.True : BoolValue.False; boolValue = (BoolValue)EditorGUILayout.EnumPopup("Default value:", boolValue); intValue = (boolValue == BoolValue.True) ? 1 : 0; break; case ParameterType.Integer: intValue = EditorGUILayout.IntField("Default value:", intValue); break; case ParameterType.Float: floatValue = EditorGUILayout.FloatField("Default value:", floatValue); break; case ParameterType.String: EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Default value:", GUILayout.Width(145f)); EditorStyles.textField.wordWrap = true; stringValue = EditorGUILayout.TextArea(stringValue, GUILayout.MaxWidth(400f)); EditorGUILayout.EndHorizontal(); break; case ParameterType.Vector3: vector3Value = EditorGUILayout.Vector3Field("Default value:", vector3Value); break; case ParameterType.UnityObject: objectValue = (Object)EditorGUILayout.ObjectField("Default value:", objectValue, typeof(Object), true); break; case ParameterType.Document: if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; intValue = ActionRunActionList.ShowDocumentSelectorGUI("Default value:", inventoryManager.documents, intValue); } else { EditorGUILayout.HelpBox("An Inventory Manager is required.", MessageType.Warning); } break; case ParameterType.InventoryItem: if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; intValue = ActionRunActionList.ShowInvItemSelectorGUI("Default value:", inventoryManager.items, intValue); } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Inventory items.", MessageType.Warning); } break; case ParameterType.GlobalVariable: if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; intValue = ActionRunActionList.ShowVarSelectorGUI("Default value:", variablesManager.vars, intValue); } else { EditorGUILayout.HelpBox("A Variables Manager is required to pass Global Variables.", MessageType.Warning); } break; case ParameterType.LocalVariable: if (isAssetFile) { intValue = 0; EditorGUILayout.HelpBox("Local Variable parameters cannot have default values in ActionList Assets.", MessageType.Info); } else { if (KickStarter.localVariables) { intValue = ActionRunActionList.ShowVarSelectorGUI("Default value:", KickStarter.localVariables.localVars, intValue); } else { EditorGUILayout.HelpBox("A GameEngine prefab is required to pass Local Variables.", MessageType.Warning); } } break; case ParameterType.ComponentVariable: if (isAssetFile) { variables = null; intValue = 0; EditorGUILayout.HelpBox("Component Variable parameters cannot have default values in ActionList Assets.", MessageType.Info); } else { variables = (Variables)EditorGUILayout.ObjectField("Variables component:", variables, typeof(Variables), true); if (variables != null) { intValue = ActionRunActionList.ShowVarSelectorGUI("Default value:", variables.vars, intValue); } } break; case ParameterType.GameObject: if (isAssetFile) { gameObject = (GameObject)EditorGUILayout.ObjectField("Default value:", gameObject, typeof(GameObject), true); if (gameObject != null) { if (!UnityVersionHandler.IsPrefabFile(gameObject)) { intValue = Action.FieldToID(gameObject, intValue, false, isAssetFile); gameObject = Action.IDToField(gameObject, intValue, true, false, isAssetFile); } else { // A prefab, ask if we want to affect the prefab or the scene-based instance? gameObjectParameterReferences = (GameObjectParameterReferences)EditorGUILayout.EnumPopup("GameObject parameter:", gameObjectParameterReferences); } } else { intValue = EditorGUILayout.IntField("Default value (ID #):", intValue); } } else { // Gameobject gameObject = (GameObject)EditorGUILayout.ObjectField("Default value:", gameObject, typeof(GameObject), true); intValue = 0; if (gameObject != null && gameObject.GetComponent <ConstantID> () == null) { UnityVersionHandler.AddConstantIDToGameObject <ConstantID> (gameObject); } } break; default: break; } CustomGUILayout.TokenLabel("[param:" + ID.ToString() + "]"); } }
private void PropertiesGUI() { List <string> binList = new List <string>(); foreach (InvBin bin in bins) { binList.Add(bin.label); } EditorGUILayout.Space(); CreatePropertiesGUI(); EditorGUILayout.Space(); if (selectedInvVar != null && invVars.Contains(selectedInvVar)) { string apiPrefix = "AC.KickStarter.variablesManager.GetProperty (" + selectedInvVar.id + ")"; EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Inventory property '" + selectedInvVar.label + "' properties", CustomStyles.subHeader); EditorGUILayout.Space(); selectedInvVar.label = CustomGUILayout.TextField("Name:", selectedInvVar.label, apiPrefix + ".label"); selectedInvVar.type = (VariableType)CustomGUILayout.EnumPopup("Type:", selectedInvVar.type, apiPrefix + ".type"); if (selectedInvVar.type == VariableType.PopUp) { selectedInvVar.popUps = VariablesManager.PopupsGUI(selectedInvVar.popUps); } selectedInvVar.limitToCategories = EditorGUILayout.BeginToggleGroup("Limit to set categories?", selectedInvVar.limitToCategories); if (bins.Count > 0) { List <int> newCategoryIDs = new List <int>(); foreach (InvBin bin in bins) { bool usesCategory = false; if (selectedInvVar.categoryIDs.Contains(bin.id)) { usesCategory = true; } usesCategory = CustomGUILayout.Toggle("Use in '" + bin.label + "'?", usesCategory, apiPrefix + ".categoryIDs"); if (usesCategory) { newCategoryIDs.Add(bin.id); } } selectedInvVar.categoryIDs = newCategoryIDs; } else if (selectedInvVar.limitToCategories) { EditorGUILayout.HelpBox("No categories are defined!", MessageType.Warning); } EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } if (GUI.changed) { foreach (InvItem item in items) { RebuildProperties(item); } } }
public static GUIData SetParametersGUI(List <ActionParameter> externalParameters, bool isAssetFile, GUIData guiData, List <ActionParameter> ownParameters = null) { guiData = SyncLists(externalParameters, guiData); EditorGUILayout.BeginVertical("Button"); for (int i = 0; i < externalParameters.Count; i++) { string label = externalParameters[i].label; int linkedID = (i < guiData.parameterIDs.Count) ? guiData.parameterIDs[i] : -1; //guiData.fromParameters[i].ID = externalParameters[i].ID; guiData.fromParameters[i].parameterType = externalParameters[i].parameterType; if (externalParameters[i].parameterType == ParameterType.GameObject) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.GameObject); if (linkedID < 0) { if (isAssetFile) { guiData.fromParameters[i].gameObject = (GameObject)EditorGUILayout.ObjectField(label + ":", guiData.fromParameters[i].gameObject, typeof(GameObject), true); if (guiData.fromParameters[i].gameObject != null) { if (!UnityVersionHandler.IsPrefabFile(guiData.fromParameters[i].gameObject)) { guiData.fromParameters[i].intValue = Action.FieldToID(guiData.fromParameters[i].gameObject, guiData.fromParameters[i].intValue, false, isAssetFile); guiData.fromParameters[i].gameObject = Action.IDToField(guiData.fromParameters[i].gameObject, guiData.fromParameters[i].intValue, true, false, isAssetFile); } else { // A prefab, ask if we want to affect the prefab or the scene-based instance? guiData.fromParameters[i].gameObjectParameterReferences = (GameObjectParameterReferences)EditorGUILayout.EnumPopup("GameObject parameter:", guiData.fromParameters[i].gameObjectParameterReferences); } } else { guiData.fromParameters[i].intValue = EditorGUILayout.IntField(label + " (ID #):", guiData.fromParameters[i].intValue); } } else { // Gameobject guiData.fromParameters[i].gameObject = (GameObject)EditorGUILayout.ObjectField(label + ":", guiData.fromParameters[i].gameObject, typeof(GameObject), true); guiData.fromParameters[i].intValue = 0; if (guiData.fromParameters[i].gameObject != null && guiData.fromParameters[i].gameObject.GetComponent <ConstantID>() == null) { UnityVersionHandler.AddConstantIDToGameObject <ConstantID> (guiData.fromParameters[i].gameObject); } } } } else if (externalParameters[i].parameterType == ParameterType.UnityObject) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.UnityObject); if (linkedID < 0) { guiData.fromParameters[i].objectValue = (Object)EditorGUILayout.ObjectField(label + ":", guiData.fromParameters[i].objectValue, typeof(Object), true); } } else if (externalParameters[i].parameterType == ParameterType.GlobalVariable) { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.GlobalVariable); if (linkedID < 0) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; guiData.fromParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", variablesManager.vars, guiData.fromParameters[i].intValue); } } else { EditorGUILayout.HelpBox("A Variables Manager is required to pass Global Variables.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.InventoryItem) { if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.InventoryItem); if (linkedID < 0) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; guiData.fromParameters[i].intValue = ActionRunActionList.ShowInvItemSelectorGUI(label + ":", inventoryManager.items, guiData.fromParameters[i].intValue); } } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Inventory items.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.Document) { if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Document); if (linkedID < 0) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; guiData.fromParameters[i].intValue = ActionRunActionList.ShowDocumentSelectorGUI(label + ":", inventoryManager.documents, guiData.fromParameters[i].intValue); } } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Documents.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.LocalVariable) { if (KickStarter.localVariables) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.LocalVariable); if (linkedID < 0) { guiData.fromParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", KickStarter.localVariables.localVars, guiData.fromParameters[i].intValue); } } else { EditorGUILayout.HelpBox("A GameEngine prefab is required to pass Local Variables.", MessageType.Warning); } } else if (externalParameters[i].parameterType == ParameterType.String) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.String); if (linkedID < 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(label + ":", GUILayout.Width(145f)); EditorStyles.textField.wordWrap = true; guiData.fromParameters[i].stringValue = EditorGUILayout.TextArea(guiData.fromParameters[i].stringValue, GUILayout.MaxWidth(400f)); EditorGUILayout.EndHorizontal(); } } else if (externalParameters[i].parameterType == ParameterType.Float) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Float); if (linkedID < 0) { guiData.fromParameters[i].floatValue = EditorGUILayout.FloatField(label + ":", guiData.fromParameters[i].floatValue); } } else if (externalParameters[i].parameterType == ParameterType.Integer) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Integer); if (linkedID < 0) { guiData.fromParameters[i].intValue = EditorGUILayout.IntField(label + ":", guiData.fromParameters[i].intValue); } } else if (externalParameters[i].parameterType == ParameterType.Vector3) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Vector3); if (linkedID < 0) { guiData.fromParameters[i].vector3Value = EditorGUILayout.Vector3Field(label + ":", guiData.fromParameters[i].vector3Value); } } else if (externalParameters[i].parameterType == ParameterType.Boolean) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Boolean); if (linkedID < 0) { BoolValue boolValue = BoolValue.False; if (guiData.fromParameters[i].intValue == 1) { boolValue = BoolValue.True; } boolValue = (BoolValue)EditorGUILayout.EnumPopup(label + ":", boolValue); if (boolValue == BoolValue.True) { guiData.fromParameters[i].intValue = 1; } else { guiData.fromParameters[i].intValue = 0; } } } else if (externalParameters[i].parameterType == ParameterType.ComponentVariable) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.ComponentVariable); if (linkedID < 0) { guiData.fromParameters[i].variables = (Variables)EditorGUILayout.ObjectField("'" + label + "' component:", guiData.fromParameters[i].variables, typeof(Variables), true); if (guiData.fromParameters[i].variables != null) { guiData.fromParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", guiData.fromParameters[i].variables.vars, guiData.fromParameters[i].intValue); } } } if (i < guiData.parameterIDs.Count) { guiData.parameterIDs[i] = linkedID; } if (i < externalParameters.Count - 1) { EditorGUILayout.Space(); } } EditorGUILayout.EndVertical(); return(guiData); }
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--; } }
public void ShowGUI(VariableLocation location, bool canEdit, List <VarPreset> _varPresets = null, string apiPrefix = "", Variables _variables = null) { string labelPrefix = (canEdit) ? "Initial value:" : "Current value:"; string helpText = (canEdit) ? "Its initial value" : "Its current value"; if (!canEdit && HasTranslations() && Options.GetLanguage() > 0) { labelPrefix = "Original language value:"; } if (canEdit) { label = CustomGUILayout.TextField("Label:", label, apiPrefix + ".label", "Its editor name"); type = (VariableType)CustomGUILayout.EnumPopup("Type:", type, apiPrefix + ".type", "Its variable type"); } else { EditorGUILayout.LabelField("Label: " + label); EditorGUILayout.LabelField("Type: " + type.ToString()); } switch (type) { case VariableType.Boolean: if (val != 1) { val = 0; } val = CustomGUILayout.Popup(labelPrefix, val, boolType, apiPrefix + ".BooleanValue", helpText); break; case VariableType.Float: floatVal = CustomGUILayout.FloatField(labelPrefix, floatVal, apiPrefix + ".FloatValue", helpText); break; case VariableType.Integer: val = CustomGUILayout.IntField(labelPrefix, val, apiPrefix + ".IntegerValue", helpText); break; case VariableType.PopUp: Object objectToRecord = null; if (location == VariableLocation.Global) { objectToRecord = KickStarter.variablesManager; } if (location == VariableLocation.Local) { objectToRecord = KickStarter.localVariables; } if (location == VariableLocation.Component) { objectToRecord = _variables; } VariablesManager.ShowPopUpLabelsGUI(this, canEdit, objectToRecord); if (GetNumPopUpValues() > 0) { string[] popUpLabels = GenerateEditorPopUpLabels(); val = CustomGUILayout.Popup(labelPrefix, val, popUpLabels, apiPrefix + ".IntegerValue", helpText); } else { val = 0; } if (popUpID > 0) { if (Application.isPlaying && canTranslate) { EditorGUILayout.LabelField("Values can be translated"); } } else { if (canEdit) { canTranslate = CustomGUILayout.Toggle("Values can be translated?", canTranslate, apiPrefix + ".canTranslate", "If True, the variable's value can be translated"); } else if (canTranslate) { EditorGUILayout.LabelField("Values can be translated"); } } break; case VariableType.String: EditorGUILayout.BeginHorizontal(); CustomGUILayout.LabelField(labelPrefix, GUILayout.Width(140f), apiPrefix + ".TextValue"); EditorStyles.textField.wordWrap = true; textVal = CustomGUILayout.TextArea(textVal, GUILayout.MaxWidth(800f), apiPrefix + ".TextValue"); EditorGUILayout.EndHorizontal(); if (canEdit) { canTranslate = CustomGUILayout.Toggle("Values can be translated?", canTranslate, apiPrefix + ".canTranslate", "If True, the variable's value can be translated"); } else if (canTranslate) { EditorGUILayout.LabelField("Values can be translated"); } break; case VariableType.Vector3: vector3Val = CustomGUILayout.Vector3Field(labelPrefix, vector3Val, apiPrefix + ".Vector3Value", helpText); break; } switch (location) { case VariableLocation.Global: CustomGUILayout.TokenLabel("[var:" + id.ToString() + "]"); break; case VariableLocation.Local: CustomGUILayout.TokenLabel("[localvar:" + id.ToString() + "]"); break; case VariableLocation.Component: if (_variables != null) { ConstantID _constantID = _variables.GetComponent <ConstantID> (); if (_constantID != null && _constantID.constantID != 0) { CustomGUILayout.TokenLabel("[compvar:" + _constantID.constantID.ToString() + ":" + id.ToString() + "]"); } } break; } if (_varPresets != null) { EditorGUILayout.Space(); foreach (VarPreset _varPreset in _varPresets) { // Local string apiPrefix2 = (location == VariableLocation.Local) ? "AC.KickStarter.localVariables.GetPreset (" + _varPreset.ID + ").GetPresetValue (" + id + ")" : "AC.KickStarter.runtimeVariables.GetPreset (" + _varPreset.ID + ").GetPresetValue (" + id + ")"; _varPreset.UpdateCollection(this); string label = "'" + (!string.IsNullOrEmpty(_varPreset.label) ? _varPreset.label : ("Preset #" + _varPreset.ID.ToString())) + "' value:"; PresetValue presetValue = _varPreset.GetPresetValue(this); switch (type) { case VariableType.Boolean: presetValue.val = CustomGUILayout.Popup(label, presetValue.val, boolType, apiPrefix2 + ".BooleanValue"); break; case VariableType.Float: presetValue.floatVal = CustomGUILayout.FloatField(label, presetValue.floatVal, apiPrefix2 + ".FloatValue"); break; case VariableType.Integer: presetValue.val = CustomGUILayout.IntField(label, presetValue.val, apiPrefix2 + ".IntegerValue"); break; case VariableType.PopUp: presetValue.val = CustomGUILayout.Popup(label, presetValue.val, popUps, apiPrefix2 + ".IntegerValue"); break; case VariableType.String: presetValue.textVal = CustomGUILayout.TextField(label, presetValue.textVal, apiPrefix2 + ".TextValue"); break; case VariableType.Vector3: presetValue.vector3Val = CustomGUILayout.Vector3Field(label, presetValue.vector3Val, apiPrefix2 + ".Vector3Value"); break; } } } EditorGUILayout.Space(); if (canEdit) { switch (location) { case VariableLocation.Local: link = VarLink.None; break; case VariableLocation.Global: case VariableLocation.Component: link = (VarLink)CustomGUILayout.EnumPopup("Link to:", link, apiPrefix + ".link", "What it links to"); if (link == VarLink.PlaymakerVariable) { if (PlayMakerIntegration.IsDefinePresent()) { if (location == VariableLocation.Global) { pmVar = CustomGUILayout.TextField("Playmaker Global Variable:", pmVar, apiPrefix + ".pmVar", "The name of the Playmaker variable to link to."); } else if (location == VariableLocation.Component) { if (_variables != null && PlayMakerIntegration.HasFSM(_variables.gameObject)) { pmVar = CustomGUILayout.TextField("Playmaker Local Variable:", pmVar, apiPrefix + ".pmVar", "The name of the Playmaker variable to link to. It is assumed to be placed on the same GameObject as this Variables component."); } else { EditorGUILayout.HelpBox("A Playmaker FSM component must be present on the Variables GameObject.", MessageType.Info); } } if (!string.IsNullOrEmpty(pmVar)) { updateLinkOnStart = CustomGUILayout.Toggle("Use PM for initial value?", updateLinkOnStart, apiPrefix + ".updateLinkOnStart", "If True, then Playmaker will be referred to for the initial value"); } } else { EditorGUILayout.HelpBox("The 'PlayMakerIsPresent' Scripting Define Symbol must be listed in the\nPlayer Settings. Please set it from Edit -> Project Settings -> Player", MessageType.Warning); } } else if (link == VarLink.OptionsData) { if (location == VariableLocation.Global) { EditorGUILayout.HelpBox("This Variable will be stored in PlayerPrefs, and not in saved game files.", MessageType.Info); } else { EditorGUILayout.HelpBox("Component variables cannot be linked to Options Data - use Global variables instead.", MessageType.Warning); } } else if (link == VarLink.CustomScript) { updateLinkOnStart = CustomGUILayout.Toggle("Script sets initial value?", updateLinkOnStart, apiPrefix + ".updateLinkOnStart", "If True, then a custom script will be referred to for the initial value"); EditorGUILayout.HelpBox("See the Manual's 'Global variable linking' chapter for details on how to synchronise values.", MessageType.Info); } break; } } else { if (link != VarLink.None) { EditorGUILayout.LabelField("Links to: " + link.ToString()); if (link == VarLink.PlaymakerVariable && !string.IsNullOrEmpty(pmVar)) { EditorGUILayout.LabelField("Linked PM variable: " + pmVar); } if (link == VarLink.PlaymakerVariable || link == VarLink.CustomScript) { if (updateLinkOnStart) { EditorGUILayout.LabelField("Script sets initial value"); } } } } if (canEdit) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Internal description:", "An Editor-only description to aid designers"), GUILayout.MaxWidth(146f)); description = EditorGUILayout.TextArea(description); EditorGUILayout.EndHorizontal(); } else { if (!string.IsNullOrEmpty(description)) { EditorGUILayout.LabelField("Internal description: " + description); } } }