/** * Initialises the element when it is created within MenuManager. */ public override void Declare() { uiText = null; uiButton = null; label = "Cycle"; selected = 0; isVisible = true; isClickable = true; numSlots = 1; textEffects = TextEffects.None; outlineSize = 2f; SetSize(new Vector2(15f, 5f)); anchor = TextAnchor.MiddleLeft; cycleType = AC_CycleType.CustomScript; splitLanguageType = SplitLanguageType.TextAndVoice; varID = 0; optionsArray = new List <string>(); cycleText = string.Empty; actionListOnClick = null; uiSelectableHideStyle = UISelectableHideStyle.DisableObject; cycleUIBasis = CycleUIBasis.Button; optionTextures = new Texture2D[0]; rawImage = null; linkedVariable = null; uiDropdown = null; base.Declare(); }
private void CopyCycle(MenuCycle _element, bool ignoreUnityUI) { if (ignoreUnityUI) { uiButton = null; } else { uiButton = _element.uiButton; } uiText = null; label = _element.label; textEffects = _element.textEffects; outlineSize = _element.outlineSize; anchor = _element.anchor; selected = _element.selected; optionsArray = _element.optionsArray; cycleType = _element.cycleType; splitLanguageType = _element.splitLanguageType; varID = _element.varID; cycleText = string.Empty; actionListOnClick = _element.actionListOnClick; uiSelectableHideStyle = _element.uiSelectableHideStyle; cycleUIBasis = _element.cycleUIBasis; optionTextures = _element.optionTextures; linkedVariable = null; uiDropdown = _element.uiDropdown; base.Copy(_element); }
/** * <summary>Creates a new instance of the 'Save: Set Option' Action, set to change the active language</summary> * <param name = "languageIndex">The index number of the new language</param> * <param name = "splitLanguageType">Whether to switch text language, voice language, or both</param> * <returns>The generated Action</returns> */ public static ActionOptionSet CreateNew_Language(int languageIndex, SplitLanguageType splitLanguageType = SplitLanguageType.TextAndVoice) { ActionOptionSet newAction = (ActionOptionSet)CreateInstance <ActionOptionSet>(); newAction.method = OptionSetMethod.Language; newAction.index = languageIndex; newAction.splitLanguageType = splitLanguageType; return(newAction); }
override public void ShowGUI(List <ActionParameter> parameters) { method = (OptionSetMethod)EditorGUILayout.EnumPopup("Option to set:", method); switch (method) { case OptionSetMethod.Language: if (KickStarter.speechManager == null) { EditorGUILayout.HelpBox("No Speech Manager found! One must be assigned in order to change the language.", MessageType.Warning); } else if (KickStarter.speechManager.languages != null && KickStarter.speechManager.languages.Count > 1) { if (KickStarter.speechManager != null && KickStarter.speechManager.separateVoiceAndTextLanguages) { splitLanguageType = (SplitLanguageType)EditorGUILayout.EnumPopup("Affect:", splitLanguageType); } indexParameterID = Action.ChooseParameterGUI("Language:", parameters, indexParameterID, ParameterType.Integer); if (indexParameterID < 0) { index = EditorGUILayout.Popup("Language:", index, KickStarter.speechManager.languages.ToArray()); } } else { index = 0; EditorGUILayout.HelpBox("Multiple languages not found!.", MessageType.Warning); } break; case OptionSetMethod.Subtitles: indexParameterID = Action.ChooseParameterGUI("Show subtitles:", parameters, indexParameterID, ParameterType.Boolean); if (indexParameterID < 0) { bool showSubtitles = (index == 1); showSubtitles = EditorGUILayout.Toggle("Show subtitles?", showSubtitles); index = (showSubtitles) ? 1 : 0; } break; case OptionSetMethod.SFXVolume: case OptionSetMethod.SpeechVolume: case OptionSetMethod.MusicVolume: volumeParameterID = Action.ChooseParameterGUI("New volume:", parameters, volumeParameterID, ParameterType.Float); if (volumeParameterID < 0) { volume = EditorGUILayout.Slider("New volume:", volume, 0f, 1f); } break; } AfterRunningOption(); }
public override void ShowGUI(Menu menu) { string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuCycle)"; MenuSource source = menu.menuSource; EditorGUILayout.BeginVertical("Button"); if (source != AC.MenuSource.AdventureCreator) { cycleUIBasis = (CycleUIBasis)CustomGUILayout.EnumPopup("UI basis:", cycleUIBasis, apiPrefix + ".cycleUIBasis", "What kind of UI element the Cycle is linked to"); if (cycleUIBasis == CycleUIBasis.Button) { uiButton = LinkedUiGUI <UnityEngine.UI.Button> (uiButton, "Linked Button:", source, "The Unity UI Button this is linked to"); } else if (cycleUIBasis == CycleUIBasis.Dropdown) { uiDropdown = LinkedUiGUI <Dropdown> (uiDropdown, "Linked Dropdown:", source); } uiSelectableHideStyle = (UISelectableHideStyle)CustomGUILayout.EnumPopup("When invisible:", uiSelectableHideStyle, apiPrefix + ".uiSelectableHideStyle", "The method by which this element is hidden from view when made invisible"); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); } cycleType = (AC_CycleType)CustomGUILayout.EnumPopup("Cycle type:", cycleType, apiPrefix + ".cycleType", "What the value links to"); if (cycleType == AC_CycleType.Language && KickStarter.speechManager != null && KickStarter.speechManager.separateVoiceAndTextLanguages) { splitLanguageType = (SplitLanguageType)CustomGUILayout.EnumPopup("Language type:", splitLanguageType, apiPrefix + ".splitLanguageType", "What kind of language this affects"); } if (source == MenuSource.AdventureCreator || cycleUIBasis == CycleUIBasis.Button) { label = CustomGUILayout.TextField("Label text:", label, apiPrefix + ".label", "The text that's displayed on-screen, which prefixes the varying text"); } if (cycleType == AC_CycleType.CustomScript || cycleType == AC_CycleType.Variable) { bool showOptionsGUI = true; if (cycleType == AC_CycleType.Variable) { VariableType[] allowedVarTypes = new VariableType[2]; allowedVarTypes[0] = VariableType.Integer; allowedVarTypes[1] = VariableType.PopUp; varID = AdvGame.GlobalVariableGUI("Global variable:", varID, allowedVarTypes, "The Global PopUp or Integer variable that's value will be synced with the cycle"); if (AdvGame.GetReferences().variablesManager != null && AdvGame.GetReferences().variablesManager.GetVariable(varID) != null && AdvGame.GetReferences().variablesManager.GetVariable(varID).type == VariableType.PopUp) { showOptionsGUI = false; } } if (showOptionsGUI) { int numOptions = optionsArray.Count; numOptions = EditorGUILayout.IntField("Number of choices:", optionsArray.Count); if (numOptions < 0) { numOptions = 0; } if (numOptions < optionsArray.Count) { optionsArray.RemoveRange(numOptions, optionsArray.Count - numOptions); } else if (numOptions > optionsArray.Count) { if (numOptions > optionsArray.Capacity) { optionsArray.Capacity = numOptions; } for (int i = optionsArray.Count; i < numOptions; i++) { optionsArray.Add(string.Empty); } } for (int i = 0; i < optionsArray.Count; i++) { optionsArray [i] = CustomGUILayout.TextField("Choice #" + i.ToString() + ":", optionsArray [i], apiPrefix + ".optionsArray[" + i.ToString() + "]"); } } if (cycleType == AC_CycleType.CustomScript) { if (optionsArray.Count > 0) { selected = CustomGUILayout.IntField("Default option #:", selected, apiPrefix + ".selected"); } ShowClipHelp(); } actionListOnClick = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList on click:", actionListOnClick, false, apiPrefix + ".actionListOnClick", "The ActionList asset to run when the element is clicked on"); } alternativeInputButton = CustomGUILayout.TextField("Alternative input button:", alternativeInputButton, apiPrefix + ".alternativeInputButton", "The name of the input button that triggers the element when pressed"); bool showOptionTextures = (optionTextures.Length > 0); if (menu.menuSource != MenuSource.AdventureCreator && cycleUIBasis == CycleUIBasis.Dropdown) { showOptionTextures = false; } showOptionTextures = EditorGUILayout.Toggle("Per-option textures?", showOptionTextures); if (showOptionTextures) { int numOptions = (cycleType == AC_CycleType.Language) ? KickStarter.speechManager.languages.Count : optionsArray.Count; if (cycleType == AC_CycleType.Language) { numOptions = 0; if (KickStarter.speechManager != null && KickStarter.speechManager.languages != null) { numOptions = KickStarter.speechManager.languages.Count; } } if (optionTextures.Length != numOptions) { optionTextures = new Texture2D[numOptions]; } } else { optionTextures = new Texture2D[0]; } EditorGUILayout.EndVertical(); if (showOptionTextures) { EditorGUILayout.BeginVertical("Button"); for (int i = 0; i < optionTextures.Length; i++) { optionTextures[i] = (Texture2D)EditorGUILayout.ObjectField("Option #" + i + " texture:", optionTextures[i], typeof(Texture2D), false); } if (menu.menuSource != MenuSource.AdventureCreator) { EditorGUILayout.HelpBox("Per-option textures require a RawImage component on the linked Button.", MessageType.Info); } EditorGUILayout.EndVertical(); } base.ShowGUI(menu); }