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); } } }