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; varID = _element.varID; cycleText = ""; actionListOnClick = _element.actionListOnClick; uiSelectableHideStyle = _element.uiSelectableHideStyle; cycleUIBasis = _element.cycleUIBasis; #if UNITY_5_3_OR_NEWER uiDropdown = _element.uiDropdown; #endif base.Copy(_element); }
/** * 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; varID = 0; optionsArray = new List <string>(); cycleText = ""; actionListOnClick = null; uiSelectableHideStyle = UISelectableHideStyle.DisableObject; cycleUIBasis = CycleUIBasis.Button; #if UNITY_5_3_OR_NEWER uiDropdown = null; #endif base.Declare(); }
/** * 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); }
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) { #if UNITY_5_3_OR_NEWER uiDropdown = LinkedUiGUI <Dropdown> (uiDropdown, "Linked Dropdown:", source); #else EditorGUILayout.HelpBox("This option is only available with Unity 5.4 or newer.", MessageType.Info); #endif } 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 (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) { 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(""); } } 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(); } else if (cycleType == AC_CycleType.Variable) { varID = AdvGame.GlobalVariableGUI("Global integer var:", varID, VariableType.Integer, "The Global Integer variable that's value will be synced with the cycle"); } 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"); EditorGUILayout.EndVertical(); base.ShowGUI(menu); }
public override void ShowGUI(Menu menu) { MenuSource source = menu.menuSource; EditorGUILayout.BeginVertical("Button"); if (source != AC.MenuSource.AdventureCreator) { cycleUIBasis = (CycleUIBasis)EditorGUILayout.EnumPopup("UI basis:", cycleUIBasis); if (cycleUIBasis == CycleUIBasis.Button) { uiButton = LinkedUiGUI <UnityEngine.UI.Button> (uiButton, "Linked Button:", source); } else if (cycleUIBasis == CycleUIBasis.Dropdown) { #if UNITY_5_3_OR_NEWER uiDropdown = LinkedUiGUI <Dropdown> (uiDropdown, "Linked Dropdown:", source); #else EditorGUILayout.HelpBox("This option is only available with Unity 5.4 or newer.", MessageType.Info); #endif } uiSelectableHideStyle = (UISelectableHideStyle)EditorGUILayout.EnumPopup("When invisible:", uiSelectableHideStyle); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Button"); } if (source == MenuSource.AdventureCreator || cycleUIBasis == CycleUIBasis.Button) { label = EditorGUILayout.TextField("Label text:", label); } if (source == MenuSource.AdventureCreator) { anchor = (TextAnchor)EditorGUILayout.EnumPopup("Text alignment:", anchor); textEffects = (TextEffects)EditorGUILayout.EnumPopup("Text effect:", textEffects); if (textEffects != TextEffects.None) { outlineSize = EditorGUILayout.Slider("Effect size:", outlineSize, 1f, 5f); } } cycleType = (AC_CycleType)EditorGUILayout.EnumPopup("Cycle type:", cycleType); if (cycleType == AC_CycleType.CustomScript || cycleType == AC_CycleType.Variable) { 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(""); } } for (int i = 0; i < optionsArray.Count; i++) { optionsArray [i] = EditorGUILayout.TextField("Choice #" + i.ToString() + ":", optionsArray [i]); } if (cycleType == AC_CycleType.CustomScript) { if (optionsArray.Count > 0) { selected = EditorGUILayout.IntField("Default option #:", selected); } ShowClipHelp(); } else if (cycleType == AC_CycleType.Variable) { varID = EditorGUILayout.IntField("Global Variable ID:", varID); } actionListOnClick = (ActionListAsset)EditorGUILayout.ObjectField("ActionList on click:", actionListOnClick, typeof(ActionListAsset), false); } alternativeInputButton = EditorGUILayout.TextField("Alternative input button:", alternativeInputButton); EditorGUILayout.EndVertical(); base.ShowGUI(menu); }
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); }