public void ShowGUI(string apiPrefix) { label = CustomGUILayout.TextField("Label:", label, apiPrefix + ".label"); if (labelLineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", labelLineID.ToString()); } if (ID >= 2) { stateType = (ObjectiveStateType)CustomGUILayout.EnumPopup("State type:", stateType, apiPrefix + ".stateType"); } else { EditorGUILayout.LabelField("State type: " + stateType.ToString()); } EditorGUILayout.BeginHorizontal(); CustomGUILayout.LabelField("Description:", GUILayout.Width(140f), apiPrefix + ".description"); EditorStyles.textField.wordWrap = true; description = CustomGUILayout.TextArea(description, GUILayout.MaxWidth(800f), apiPrefix + ".description"); EditorGUILayout.EndHorizontal(); if (descriptionLineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", descriptionLineID.ToString()); } }
public void ShowGUI() { if (speechPlayableData.lineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", speechPlayableData.lineID.ToString()); } speechPlayableData.messageText = CustomGUILayout.TextArea("Line text:", speechPlayableData.messageText); }
private string EditField(string label, string field, bool multiLine, string api = "") { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(label, GUILayout.Width(85f)); if (multiLine) { field = CustomGUILayout.TextArea(field, GUILayout.MaxWidth(570f), api); } else { field = CustomGUILayout.TextField(field, GUILayout.MaxWidth(570f), api); } EditorGUILayout.EndHorizontal(); return(field); }
public override void ShowGUI(Menu menu) { string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuJournal)"; MenuSource source = menu.menuSource; EditorGUILayout.BeginVertical("Button"); journalType = (JournalType)CustomGUILayout.EnumPopup("Journal type:", journalType, apiPrefix + ".journalType", "What type of journal this is"); if (journalType == JournalType.DisplayExistingJournal || journalType == JournalType.DisplayActiveDocument) { if (journalType == JournalType.DisplayExistingJournal) { EditorGUILayout.HelpBox("This Journal will share pages from another Journal element in the same Menu.", MessageType.Info); otherJournalTitle = CustomGUILayout.TextField("Existing element name:", otherJournalTitle, apiPrefix + ".otherJournalTitle", "The name of the Journal element within the same Menu that is used as reference"); pageOffset = CustomGUILayout.IntField("Page offset #:", pageOffset, apiPrefix + ".pageOffset", "The difference in page index between this and the reference Journal"); } if (pages == null || pages.Count != 1) { pages.Clear(); pages.Add(new JournalPage()); } showPage = 1; if (source == MenuSource.AdventureCreator) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Placeholder text:", GUILayout.Width(146f)); pages[0].text = CustomGUILayout.TextArea(pages[0].text, GUILayout.MaxWidth(370f), apiPrefix + ".pages[0].text"); EditorGUILayout.EndHorizontal(); } } else if (journalType == JournalType.NewJournal) { if (pages == null) { pages = new List <JournalPage>(); pages.Clear(); pages.Add(new JournalPage()); } numPages = pages.Count; for (int i = 0; i < pages.Count; i++) { EditorGUILayout.BeginHorizontal(); if (pages[i].lineID >= 0) { CustomGUILayout.LabelField("Page #" + (i + 1).ToString() + ", Text ID #" + pages[i].lineID + ":", apiPrefix + ".pages[" + i.ToString() + "].text"); } else { CustomGUILayout.LabelField("Page #" + (i + 1).ToString() + ":", apiPrefix + ".pages[" + i.ToString() + "].text"); } if (GUILayout.Button("", CustomStyles.IconCog)) { sideMenu = i; SideMenu(); } EditorGUILayout.EndHorizontal(); pages[i].text = CustomGUILayout.TextArea(pages[i].text, GUILayout.MaxWidth(370f), apiPrefix + ".pages[" + i.ToString() + "].text"); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } if (GUILayout.Button("Create new page", EditorStyles.miniButton)) { Undo.RecordObject(this, "Create journal page"); pages.Add(new JournalPage()); } numPages = pages.Count; EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); if (numPages > 1) { showPage = CustomGUILayout.IntSlider("Preview page #:", showPage, 1, numPages, apiPrefix + ".showPage", "The index number of the current page being shown "); startFromPage = CustomGUILayout.Toggle("Start from this page?", startFromPage, apiPrefix + ".startFromPage", "If True, then the page index above will be the first open when the game begins"); } else if (numPages == 1) { showPage = 1; } else { showPage = 0; } } if (source == MenuSource.AdventureCreator) { anchor = (TextAnchor)CustomGUILayout.EnumPopup("Text alignment:", anchor, apiPrefix + ".anchor", "The text alignment"); textEffects = (TextEffects)CustomGUILayout.EnumPopup("Text effect:", textEffects, apiPrefix + ".textEffects", "The special FX applied to the text"); if (textEffects != TextEffects.None) { outlineSize = CustomGUILayout.Slider("Effect size:", outlineSize, 1f, 5f, apiPrefix + ".outlineSize", "The outline thickness"); } } else { EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); #if TextMeshProIsPresent uiText = LinkedUiGUI <TMPro.TextMeshProUGUI> (uiText, "Linked Text:", source); #else uiText = LinkedUiGUI <Text> (uiText, "Linked Text:", source); #endif } if (journalType == JournalType.NewJournal) { actionListOnAddPage = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList on add page:", actionListOnAddPage, false, apiPrefix + ".actionListOnAddPage", "An ActionList to run whenever a new page is added"); } EditorGUILayout.EndVertical(); base.ShowGUI(menu); }
public override void ShowGUI(Menu menu) { string apiPrefix = "AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\")"; MenuSource source = menu.menuSource; EditorGUILayout.BeginVertical("Button"); journalType = (JournalType)CustomGUILayout.EnumPopup("Journal type:", journalType, apiPrefix + ".journalType"); if (journalType == JournalType.DisplayExistingJournal) { EditorGUILayout.HelpBox("This Journal will share pages from another Journal element in the same Menu.", MessageType.Info); otherJournalTitle = CustomGUILayout.TextField("Existing element name:", otherJournalTitle, apiPrefix + ".otherJournalTitle"); pageOffset = CustomGUILayout.IntField("Page offset #:", pageOffset, apiPrefix + ".pageOffset"); if (pages == null || pages.Count != 1) { pages.Clear(); pages.Add(new JournalPage()); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Placeholder text:", GUILayout.Width(146f)); pages[0].text = CustomGUILayout.TextArea(pages[0].text, GUILayout.MaxWidth(370f), apiPrefix + ".pages[0].text"); showPage = 1; EditorGUILayout.EndHorizontal(); if (source == MenuSource.AdventureCreator) { anchor = (TextAnchor)CustomGUILayout.EnumPopup("Text alignment:", anchor, apiPrefix + ".anchor"); textEffects = (TextEffects)CustomGUILayout.EnumPopup("Text effect:", textEffects, apiPrefix + ".textEffects"); if (textEffects != TextEffects.None) { outlineSize = CustomGUILayout.Slider("Effect size:", outlineSize, 1f, 5f, apiPrefix + ".outlineSize"); } } else { EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); uiText = LinkedUiGUI <Text> (uiText, "Linked Text:", source); } } else { if (pages == null || pages.Count == 0) { pages.Clear(); pages.Add(new JournalPage()); } numPages = pages.Count; for (int i = 0; i < pages.Count; i++) { EditorGUILayout.BeginHorizontal(); if (pages[i].lineID >= 0) { EditorGUILayout.LabelField("Page #" + (i + 1).ToString() + ", Text ID #" + pages[i].lineID + ":"); } else { EditorGUILayout.LabelField("Page #" + (i + 1).ToString() + ":"); } if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f))) { sideMenu = i; SideMenu(); } EditorGUILayout.EndHorizontal(); pages[i].text = CustomGUILayout.TextArea(pages[i].text, GUILayout.MaxWidth(370f), apiPrefix + ".pages[" + i.ToString() + "].text"); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } if (GUILayout.Button("Create new page", EditorStyles.miniButton)) { Undo.RecordObject(this, "Create journal page"); pages.Add(new JournalPage()); } numPages = pages.Count; EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); if (numPages > 1) { showPage = CustomGUILayout.IntSlider("Preview page #:", showPage, 1, numPages, apiPrefix + ".showPage"); startFromPage = CustomGUILayout.Toggle("Start from this page?", startFromPage, apiPrefix + ".startFromPage"); } else { showPage = 1; } if (source == MenuSource.AdventureCreator) { anchor = (TextAnchor)CustomGUILayout.EnumPopup("Text alignment:", anchor, apiPrefix + ".anchor"); textEffects = (TextEffects)CustomGUILayout.EnumPopup("Text effect:", textEffects, apiPrefix + ".textEffects"); } else { EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); uiText = LinkedUiGUI <Text> (uiText, "Linked Text:", source); } actionListOnAddPage = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList on add page:", actionListOnAddPage, false, apiPrefix + ".actionListOnAddPage"); } EditorGUILayout.EndVertical(); base.ShowGUI(menu); }
public void ShowGUI(string apiPrefix) { if (Application.isPlaying && KickStarter.runtimeObjectives != null) { ObjectiveState currentState = KickStarter.runtimeObjectives.GetObjectiveState(ID); if (currentState != null) { EditorGUILayout.LabelField("Current state::", currentState.ID + ": " + currentState.Label, EditorStyles.boldLabel); } else { EditorGUILayout.LabelField("Current state:", "INACTIVE", EditorStyles.boldLabel); } EditorGUILayout.Space(); } title = CustomGUILayout.TextField("Title:", title, apiPrefix + ".title"); if (titleLineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", titleLineID.ToString()); } EditorGUILayout.BeginHorizontal(); CustomGUILayout.LabelField("Description:", GUILayout.Width(140f), apiPrefix + ".description"); EditorStyles.textField.wordWrap = true; description = CustomGUILayout.TextArea(description, GUILayout.MaxWidth(800f), apiPrefix + ".description"); EditorGUILayout.EndHorizontal(); if (descriptionLineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", descriptionLineID.ToString()); } if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow) { perPlayer = CustomGUILayout.Toggle("Per-Player?", perPlayer, apiPrefix + ".perPlayer"); } texture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> ("Texture:", texture, false, apiPrefix + ".texture"); lockStateWhenComplete = CustomGUILayout.Toggle("Lock state when complete?", lockStateWhenComplete, apiPrefix + ".lockStateWhenComplete"); lockStateWhenFail = CustomGUILayout.Toggle("Lock state when fail?", lockStateWhenFail, apiPrefix + ".lockStateWhenFail"); EditorGUILayout.Space(); EditorGUILayout.LabelField("Objective states:"); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(states.Count * 21, 185f) + 5)); for (int i = 0; i < states.Count; i++) { EditorGUILayout.BeginHorizontal(); ObjectiveState thisState = states[i]; if (GUILayout.Toggle(selectedState == i, thisState.ID.ToString() + ": " + thisState.Label, "Button")) { if (selectedState != i) { selectedState = i; EditorGUIUtility.editingTextField = false; } } if (GUILayout.Button(string.Empty, CustomStyles.IconCog)) { sideState = i; EditorGUIUtility.editingTextField = false; SideStateMenu(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Create new state")) { Undo.RecordObject(KickStarter.inventoryManager, "Add Objective state"); states.Add(new ObjectiveState(GetStateIDArray())); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); if (selectedState >= 0 && states.Count > selectedState) { EditorGUILayout.BeginVertical("Button"); showStateGUI = CustomGUILayout.ToggleHeader(showStateGUI, "State #" + states[selectedState].ID.ToString() + ": " + states[selectedState].Label); if (showStateGUI) { states[selectedState].ShowGUI(apiPrefix + ".states[" + selectedState.ToString() + "]."); } EditorGUILayout.EndVertical(); } }
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); } } }
public void ShowGUI(bool isAssetFile, bool onlyEditValues = false, bool readOnly = false) { if (Application.isPlaying || readOnly) { EditorGUILayout.LabelField("Label:", label); } else { label = CustomGUILayout.TextField("Label:", label, string.Empty, "The parameter's name"); } 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)CustomGUILayout.EnumPopup("Type:", parameterType, string.Empty, "The parameter's type"); description = CustomGUILayout.TextArea("Description:", description, string.Empty, "Descriptive text to display as a tooltip when assigning this parameter's value"); } switch (parameterType) { case ParameterType.Boolean: BoolValue boolValue = (intValue == 1) ? BoolValue.True : BoolValue.False; boolValue = (BoolValue)CustomGUILayout.EnumPopup("Default value:", boolValue); intValue = (boolValue == BoolValue.True) ? 1 : 0; break; case ParameterType.Integer: intValue = CustomGUILayout.IntField("Default value:", intValue); break; case ParameterType.Float: floatValue = CustomGUILayout.FloatField("Default value:", floatValue); break; case ParameterType.String: stringValue = CustomGUILayout.TextArea("Default value:", stringValue); break; case ParameterType.Vector3: vector3Value = CustomGUILayout.Vector3Field("Default value:", vector3Value); break; case ParameterType.UnityObject: objectValue = CustomGUILayout.ObjectField <Object> ("Default value:", objectValue, 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)CustomGUILayout.ObjectField <Variables> ("Variables component:", 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)CustomGUILayout.ObjectField <GameObject> ("Default value:", gameObject, true); intValue = 0; if (gameObject && gameObject.GetComponent <ConstantID> () == null) { UnityVersionHandler.AddConstantIDToGameObject <ConstantID> (gameObject); } } break; default: break; } CustomGUILayout.TokenLabel("[param:" + ID.ToString() + "]"); } }
public override void ShowGUI(List <ActionParameter> parameters) { changeType = (MenuChangeType)EditorGUILayout.EnumPopup("Change type:", changeType); switch (changeType) { case MenuChangeType.TurnOnMenu: { menuToChangeParameterID = Action.ChooseParameterGUI("Menu to turn on:", parameters, menuToChangeParameterID, ParameterType.String); if (menuToChangeParameterID < 0) { menuToChange = EditorGUILayout.TextField("Menu to turn on:", menuToChange); } doFade = EditorGUILayout.Toggle("Transition?", doFade); } break; case MenuChangeType.TurnOffMenu: { menuToChangeParameterID = Action.ChooseParameterGUI("Menu to turn off:", parameters, menuToChangeParameterID, ParameterType.String); if (menuToChangeParameterID < 0) { menuToChange = EditorGUILayout.TextField("Menu to turn off:", menuToChange); } doFade = EditorGUILayout.Toggle("Transition?", doFade); } break; case MenuChangeType.HideMenuElement: { menuToChangeParameterID = Action.ChooseParameterGUI("Menu containing element:", parameters, menuToChangeParameterID, ParameterType.String); if (menuToChangeParameterID < 0) { menuToChange = EditorGUILayout.TextField("Menu containing element:", menuToChange); } elementToChangeParameterID = Action.ChooseParameterGUI("Element to hide:", parameters, elementToChangeParameterID, ParameterType.String); if (elementToChangeParameterID < 0) { elementToChange = EditorGUILayout.TextField("Element to hide:", elementToChange); } } break; case MenuChangeType.ShowMenuElement: { menuToChangeParameterID = Action.ChooseParameterGUI("Menu containing element:", parameters, menuToChangeParameterID, ParameterType.String); if (menuToChangeParameterID < 0) { menuToChange = EditorGUILayout.TextField("Menu containing element:", menuToChange); } elementToChangeParameterID = Action.ChooseParameterGUI("Element to show:", parameters, elementToChangeParameterID, ParameterType.String); if (elementToChangeParameterID < 0) { elementToChange = EditorGUILayout.TextField("Element to show:", elementToChange); } } break; case MenuChangeType.LockMenu: { menuToChangeParameterID = Action.ChooseParameterGUI("Menu to lock:", parameters, menuToChangeParameterID, ParameterType.String); if (menuToChangeParameterID < 0) { menuToChange = EditorGUILayout.TextField("Menu to lock:", menuToChange); } doFade = EditorGUILayout.Toggle("Transition?", doFade); } break; case MenuChangeType.UnlockMenu: { menuToChangeParameterID = Action.ChooseParameterGUI("Menu to unlock:", parameters, menuToChangeParameterID, ParameterType.String); if (menuToChangeParameterID < 0) { menuToChange = EditorGUILayout.TextField("Menu to unlock:", menuToChange); } } break; case MenuChangeType.AddJournalPage: { if (lineID > -1) { EditorGUILayout.LabelField("Speech Manager ID:", lineID.ToString()); } menuToChangeParameterID = Action.ChooseParameterGUI("Menu containing element:", parameters, menuToChangeParameterID, ParameterType.String); if (menuToChangeParameterID < 0) { menuToChange = EditorGUILayout.TextField("Menu containing element:", menuToChange); } elementToChangeParameterID = Action.ChooseParameterGUI("Journal element:", parameters, elementToChangeParameterID, ParameterType.String); if (elementToChangeParameterID < 0) { elementToChange = EditorGUILayout.TextField("Journal element:", elementToChange); } journalText = CustomGUILayout.TextArea("New page text:", journalText); onlyAddNewJournal = EditorGUILayout.Toggle("Only add if not already in?", onlyAddNewJournal); if (onlyAddNewJournal && lineID == -1) { EditorGUILayout.HelpBox("The page text must be added to the Speech Manager by clicking the 'Gather text' button, in order for duplicates to be prevented.", MessageType.Warning); } journalPageIndexParameterID = Action.ChooseParameterGUI("Index to insert into:", parameters, journalPageIndexParameterID, ParameterType.Integer); if (journalPageIndexParameterID < 0) { journalPageIndex = EditorGUILayout.IntField("Index to insert into:", journalPageIndex); EditorGUILayout.HelpBox("An index value of -1 will add the page to the end of the Journal.", MessageType.Info); } } break; case MenuChangeType.RemoveJournalPage: { menuToChangeParameterID = Action.ChooseParameterGUI("Menu containing element:", parameters, menuToChangeParameterID, ParameterType.String); if (menuToChangeParameterID < 0) { menuToChange = EditorGUILayout.TextField("Menu containing element:", menuToChange); } elementToChangeParameterID = Action.ChooseParameterGUI("Journal element:", parameters, elementToChangeParameterID, ParameterType.String); if (elementToChangeParameterID < 0) { elementToChange = EditorGUILayout.TextField("Journal element:", elementToChange); } removeJournalPageMethod = (RemoveJournalPageMethod)EditorGUILayout.EnumPopup("Removal method:", removeJournalPageMethod); if (removeJournalPageMethod == RemoveJournalPageMethod.RemoveSinglePage) { journalPageIndexParameterID = Action.ChooseParameterGUI("Page number to remove:", parameters, journalPageIndexParameterID, ParameterType.Integer); if (journalPageIndexParameterID < 0) { journalPageIndex = EditorGUILayout.IntField("Page number to remove:", journalPageIndex); EditorGUILayout.HelpBox("An index value of -1 will remove the last page of the Journal.", MessageType.Info); } } } break; default: break; } if (doFade && (changeType == MenuChangeType.TurnOnMenu || changeType == MenuChangeType.TurnOffMenu || changeType == MenuChangeType.LockMenu)) { willWait = EditorGUILayout.Toggle("Wait until finish?", willWait); } AfterRunningOption(); }
public override void ShowGUI(Menu menu) { string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuLabel)"; MenuSource source = menu.menuSource; CustomGUILayout.BeginVertical(); if (source != MenuSource.AdventureCreator) { #if TextMeshProIsPresent uiText = LinkedUiGUI <TMPro.TextMeshProUGUI> (uiText, "Linked Text:", source); #else uiText = LinkedUiGUI <Text> (uiText, "Linked Text:", source); #endif CustomGUILayout.EndVertical(); CustomGUILayout.BeginVertical(); } labelType = (AC_LabelType)CustomGUILayout.EnumPopup("Label type:", labelType, apiPrefix + ".labelType", "What kind of text the label displays"); if (labelType == AC_LabelType.Normal) { label = CustomGUILayout.TextArea("Label text:", label, apiPrefix + ".label", "The display text"); } else if (source == MenuSource.AdventureCreator) { label = CustomGUILayout.TextArea("Placeholder text:", label, apiPrefix + ".label"); } if (labelType == AC_LabelType.GlobalVariable) { variableID = AdvGame.GlobalVariableGUI("Global Variable:", variableID, "The Global Variable whose value will be displayed"); } else if (labelType == AC_LabelType.DialogueLine) { useCharacterColour = CustomGUILayout.Toggle("Use Character text colour?", useCharacterColour, apiPrefix + ".useCharacterColour", "If True, then the displayed subtitle text will use the speaking character's subtitle text colour"); if (sizeType == AC_SizeType.Manual && source == MenuSource.AdventureCreator) { autoAdjustHeight = CustomGUILayout.Toggle("Auto-adjust height to fit?", autoAdjustHeight, apiPrefix + ".autoAdjustHeight", "If True, then the label's height will adjust itself to fit the text within it"); } } else if (labelType == AC_LabelType.DialogueSpeaker) { useCharacterColour = CustomGUILayout.Toggle("Use Character text colour?", useCharacterColour, apiPrefix + ".useCharacterColour", "If True, then the displayed text will use the speaking character's subtitle text colour"); } else if (labelType == AC_LabelType.SelectedObjective) { selectedObjectiveLabelType = (SelectedObjectiveLabelType)CustomGUILayout.EnumPopup("Objective text:", selectedObjectiveLabelType, apiPrefix + ".selectedObjectiveLabelType", "Which associated text of the selected Objective to display"); } if (labelType == AC_LabelType.Hotspot || labelType == AC_LabelType.DialogueLine || labelType == AC_LabelType.DialogueSpeaker) { updateIfEmpty = CustomGUILayout.Toggle("Update if string is empty?", updateIfEmpty, apiPrefix + ".updateIfEmpty", "If True, then the display text buffer can be empty "); if (labelType == AC_LabelType.Hotspot) { showPendingWhileMovingToHotspot = CustomGUILayout.ToggleLeft("Show pending Interaction while moving to Hotspot?", showPendingWhileMovingToHotspot, apiPrefix + ".showPendingWhileMovingToHotspot", "If True, then the label will not change while the player is moving towards a Hotspot in order to run an interaction"); } } else if (labelType == AC_LabelType.InventoryProperty) { if (AdvGame.GetReferences().inventoryManager) { if (AdvGame.GetReferences().inventoryManager.invVars != null && AdvGame.GetReferences().inventoryManager.invVars.Count > 0) { InvVar[] invVars = AdvGame.GetReferences().inventoryManager.invVars.ToArray(); List <string> invVarNames = new List <string>(); int itemPropertyNumber = 0; for (int i = 0; i < invVars.Length; i++) { if (invVars[i].id == itemPropertyID) { itemPropertyNumber = i; } invVarNames.Add(invVars[i].id + ": " + invVars[i].label); } itemPropertyNumber = CustomGUILayout.Popup("Inventory property:", itemPropertyNumber, invVarNames.ToArray(), apiPrefix + ".itemPropertyNumber", "The inventory property to show"); itemPropertyID = invVars[itemPropertyNumber].id; inventoryPropertyType = (InventoryPropertyType)CustomGUILayout.EnumPopup("Inventory item source:", inventoryPropertyType, apiPrefix + ".inventoryPropertyType", "What kind of item to display properties for"); if (invVars[itemPropertyNumber].type == VariableType.Float || invVars[itemPropertyNumber].type == VariableType.Integer) { multiplyByItemCount = CustomGUILayout.Toggle("Multiply by item count?", multiplyByItemCount, apiPrefix + ".multiplyByItemCount", "If True, then the property's value will be multipled by the item's count."); } } else { EditorGUILayout.HelpBox("No Inventory properties defined!", MessageType.Warning); } } else { EditorGUILayout.HelpBox("No Inventory Manager assigned!", MessageType.Warning); } } CustomGUILayout.EndVertical(); base.ShowGUI(menu); }
public static GUIData SetParametersGUI(List <ActionParameter> externalParameters, bool isAssetFile, GUIData guiData, List <ActionParameter> ownParameters = null) { guiData = SyncLists(externalParameters, guiData); CustomGUILayout.BeginVertical(); for (int i = 0; i < externalParameters.Count; i++) { string label = externalParameters[i].label; string tooltip = externalParameters[i].description; int linkedID = (i < guiData.parameterIDs.Count) ? guiData.parameterIDs[i] : -1; guiData.fromParameters[i].parameterType = externalParameters[i].parameterType; switch (externalParameters[i].parameterType) { case ParameterType.GameObject: { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.GameObject); if (linkedID < 0) { if (isAssetFile) { guiData.fromParameters[i].gameObject = (GameObject)CustomGUILayout.ObjectField <GameObject> (label + ":", guiData.fromParameters[i].gameObject, true, string.Empty, tooltip); if (guiData.fromParameters[i].gameObject) { 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 = CustomGUILayout.IntField(label + " (ID #):", guiData.fromParameters[i].intValue, string.Empty, tooltip); } } else { // Gameobject guiData.fromParameters[i].gameObject = (GameObject)CustomGUILayout.ObjectField <GameObject> (label + ":", guiData.fromParameters[i].gameObject, true, string.Empty, tooltip); guiData.fromParameters[i].intValue = 0; if (guiData.fromParameters[i].gameObject && guiData.fromParameters[i].gameObject.GetComponent <ConstantID>() == null) { UnityVersionHandler.AddConstantIDToGameObject <ConstantID> (guiData.fromParameters[i].gameObject); } } } } break; case ParameterType.UnityObject: { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.UnityObject); if (linkedID < 0) { guiData.fromParameters[i].objectValue = (Object)CustomGUILayout.ObjectField <Object> (label + ":", guiData.fromParameters[i].objectValue, true, string.Empty, tooltip); } } break; case ParameterType.GlobalVariable: { if (AdvGame.GetReferences() && AdvGame.GetReferences().variablesManager) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.GlobalVariable, -1, tooltip); if (linkedID < 0) { VariablesManager variablesManager = AdvGame.GetReferences().variablesManager; guiData.fromParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", variablesManager.vars, guiData.fromParameters[i].intValue, tooltip); } } else { EditorGUILayout.HelpBox("A Variables Manager is required to pass Global Variables.", MessageType.Warning); } } break; case ParameterType.InventoryItem: { if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.InventoryItem, -1, tooltip); if (linkedID < 0) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; guiData.fromParameters[i].intValue = ActionRunActionList.ShowInvItemSelectorGUI(label + ":", inventoryManager.items, guiData.fromParameters[i].intValue, tooltip); } } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Inventory items.", MessageType.Warning); } } break; case ParameterType.Document: { if (AdvGame.GetReferences() && AdvGame.GetReferences().inventoryManager) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Document, -1, tooltip); if (linkedID < 0) { InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager; guiData.fromParameters[i].intValue = ActionRunActionList.ShowDocumentSelectorGUI(label + ":", inventoryManager.documents, guiData.fromParameters[i].intValue, tooltip); } } else { EditorGUILayout.HelpBox("An Inventory Manager is required to pass Documents.", MessageType.Warning); } } break; case ParameterType.LocalVariable: { if (KickStarter.localVariables) { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.LocalVariable, -1, tooltip); if (linkedID < 0) { guiData.fromParameters[i].intValue = ActionRunActionList.ShowVarSelectorGUI(label + ":", KickStarter.localVariables.localVars, guiData.fromParameters[i].intValue, tooltip); } } else { EditorGUILayout.HelpBox("A GameEngine prefab is required to pass Local Variables.", MessageType.Warning); } } break; case ParameterType.String: { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.String, -1, tooltip); if (linkedID < 0) { guiData.fromParameters[i].stringValue = CustomGUILayout.TextArea(label, guiData.fromParameters[i].stringValue, string.Empty, tooltip); } } break; case ParameterType.Float: { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Float, -1, tooltip); if (linkedID < 0) { guiData.fromParameters[i].floatValue = CustomGUILayout.FloatField(label + ":", guiData.fromParameters[i].floatValue, string.Empty, tooltip); } } break; case ParameterType.Integer: { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Integer, -1, tooltip); if (linkedID < 0) { guiData.fromParameters[i].intValue = CustomGUILayout.IntField(label + ":", guiData.fromParameters[i].intValue, string.Empty, tooltip); } } break; case ParameterType.Vector3: { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Vector3, -1, tooltip); if (linkedID < 0) { guiData.fromParameters[i].vector3Value = CustomGUILayout.Vector3Field(label + ":", guiData.fromParameters[i].vector3Value, string.Empty, tooltip); } } break; case ParameterType.Boolean: { linkedID = Action.ChooseParameterGUI(label + ":", ownParameters, linkedID, ParameterType.Boolean, -1, tooltip); if (linkedID < 0) { BoolValue boolValue = BoolValue.False; if (guiData.fromParameters[i].intValue == 1) { boolValue = BoolValue.True; } boolValue = (BoolValue)CustomGUILayout.EnumPopup(label + ":", boolValue, string.Empty, tooltip); if (boolValue == BoolValue.True) { guiData.fromParameters[i].intValue = 1; } else { guiData.fromParameters[i].intValue = 0; } } } break; case 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); } } } break; default: break; } if (i < guiData.parameterIDs.Count) { guiData.parameterIDs[i] = linkedID; } if (i < externalParameters.Count - 1) { EditorGUILayout.Space(); } } CustomGUILayout.EndVertical(); return(guiData); }