Exemplo n.º 1
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            if (PlayMakerIntegration.IsDefinePresent())
            {
                isPlayer = EditorGUILayout.Toggle("Use Player's FSM?", isPlayer);
                if (!isPlayer)
                {
                    parameterID = Action.ChooseParameterGUI("PlayMaker FSM:", parameters, parameterID, ParameterType.GameObject);
                    if (parameterID >= 0)
                    {
                        constantID   = 0;
                        linkedObject = null;
                    }
                    else
                    {
                        linkedObject = (GameObject)EditorGUILayout.ObjectField("PlayMaker FSM:", linkedObject, typeof(GameObject), true);

                        constantID   = FieldToID(linkedObject, constantID);
                        linkedObject = IDToField(linkedObject, constantID, false);
                    }
                }

                fsmName   = EditorGUILayout.TextField("FSM to call (optional):", fsmName);
                eventName = EditorGUILayout.TextField("Event to call:", eventName);
            }
            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);
            }

            AfterRunningOption();
        }
Exemplo n.º 2
0
        /**
         * Sets its value to that of its linked PlayMaker variable (if appropriate).
         */
        public void Download()
        {
            if (link == VarLink.PlaymakerGlobalVariable && pmVar != "")
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (type == VariableType.Integer || type == VariableType.PopUp)
                {
                    val = PlayMakerIntegration.GetGlobalInt(pmVar);
                }
                else if (type == VariableType.Boolean)
                {
                    bool _val = PlayMakerIntegration.GetGlobalBool(pmVar);
                    if (_val)
                    {
                        val = 1;
                    }
                    else
                    {
                        val = 0;
                    }
                }
                else if (type == VariableType.String)
                {
                    textVal = PlayMakerIntegration.GetGlobalString(pmVar);
                }
                else if (type == VariableType.Float)
                {
                    floatVal = PlayMakerIntegration.GetGlobalFloat(pmVar);
                }
            }
        }
Exemplo n.º 3
0
        /**
         * <summary>Sets the value of its linked variable to its value (if appropriate).</summary>
         * <param name = "_location">The variable's location</param>
         * <param name = "_variables">The variable's Variables component, if location = VariableLocation.Component</param>
         */
        public void Upload(VariableLocation _location = VariableLocation.Global, Variables _variables = null)
        {
            if (_location == VariableLocation.Local)
            {
                return;
            }

            if (link == VarLink.PlaymakerVariable && !string.IsNullOrEmpty(pmVar))
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (_location != VariableLocation.Component)
                {
                    _variables = null;
                }
                if (_location == VariableLocation.Component && _variables == null)
                {
                    return;
                }

                switch (type)
                {
                case VariableType.Integer:
                case VariableType.PopUp:
                    PlayMakerIntegration.SetInt(pmVar, val, _variables);
                    break;

                case VariableType.Boolean:
                    PlayMakerIntegration.SetBool(pmVar, (val == 1), _variables);
                    break;

                case VariableType.String:
                    PlayMakerIntegration.SetString(pmVar, textVal, _variables);
                    break;

                case VariableType.Float:
                    PlayMakerIntegration.SetFloat(pmVar, floatVal, _variables);
                    break;

                case VariableType.Vector3:
                    PlayMakerIntegration.SetVector3(pmVar, vector3Val, _variables);
                    break;
                }
            }
            else if (link == VarLink.OptionsData)
            {
                Options.SavePrefs();
            }
            else if (link == VarLink.CustomScript)
            {
                KickStarter.eventManager.Call_OnUploadVariable(this, _variables);
            }
        }
Exemplo n.º 4
0
        /**
         * <summary>Sets its value to that of its linked variable (if appropriate).</summary>
         * <param name = "_location">The variable's location</param>
         * <param name = "_variables">The variable's Variables component, if location = VariableLocation.Component</param>
         */
        public void Download(VariableLocation _location = VariableLocation.Global, Variables _variables = null)
        {
            if (_location == VariableLocation.Local)
            {
                return;
            }

            if (link == VarLink.PlaymakerVariable && !string.IsNullOrEmpty(pmVar))
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (_location != VariableLocation.Component)
                {
                    _variables = null;
                }
                if (_location == VariableLocation.Component && _variables == null)
                {
                    return;
                }

                switch (type)
                {
                case VariableType.Integer:
                case VariableType.PopUp:
                    SetValue(PlayMakerIntegration.GetInt(pmVar, _variables));
                    break;

                case VariableType.Boolean:
                    bool _val = PlayMakerIntegration.GetBool(pmVar, _variables);
                    SetValue((_val) ? 1 : 0);
                    break;

                case VariableType.String:
                    SetStringValue(PlayMakerIntegration.GetString(pmVar, _variables));
                    break;

                case VariableType.Float:
                    SetFloatValue(PlayMakerIntegration.GetFloat(pmVar, _variables));
                    break;

                case VariableType.Vector3:
                    SetVector3Value(PlayMakerIntegration.GetVector3(pmVar, _variables));
                    break;
                }
            }
            else if (link == VarLink.CustomScript)
            {
                KickStarter.eventManager.Call_OnDownloadVariable(this);
            }
        }
Exemplo n.º 5
0
        override public float Run()
        {
            if (linkedObject != null && eventName != "")
            {
                if (fsmName != "")
                {
                    PlayMakerIntegration.CallEvent(linkedObject, eventName, fsmName);
                }
                else
                {
                    PlayMakerIntegration.CallEvent(linkedObject, eventName);
                }
            }

            return(0f);
        }
Exemplo n.º 6
0
        override public float Run()
        {
            if (runtimeLinkedObject != null && !string.IsNullOrEmpty(eventName))
            {
                if (fsmName != "")
                {
                    PlayMakerIntegration.CallEvent(runtimeLinkedObject, eventName, fsmName);
                }
                else
                {
                    PlayMakerIntegration.CallEvent(runtimeLinkedObject, eventName);
                }
            }

            return(0f);
        }
Exemplo n.º 7
0
        /**
         * Sets the value of its linked Options Data or PlayMaker variable to its value (if appropriate).
         */
        public void Upload()
        {
            if (link == VarLink.PlaymakerGlobalVariable && pmVar != "")
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (type == VariableType.Integer || type == VariableType.PopUp)
                {
                    PlayMakerIntegration.SetGlobalInt(pmVar, val);
                }
                else if (type == VariableType.Boolean)
                {
                    if (val == 1)
                    {
                        PlayMakerIntegration.SetGlobalBool(pmVar, true);
                    }
                    else
                    {
                        PlayMakerIntegration.SetGlobalBool(pmVar, false);
                    }
                }
                else if (type == VariableType.String)
                {
                    PlayMakerIntegration.SetGlobalString(pmVar, textVal);
                }
                else if (type == VariableType.Float)
                {
                    PlayMakerIntegration.SetGlobalFloat(pmVar, floatVal);
                }
                else if (type == VariableType.Vector3)
                {
                    PlayMakerIntegration.SetGlobalVector3(pmVar, vector3Val);
                }
            }
            else if (link == VarLink.OptionsData)
            {
                Options.SavePrefs();
            }
            else if (link == VarLink.CustomScript)
            {
                KickStarter.eventManager.Call_OnUploadVariable(this);
            }
        }
Exemplo n.º 8
0
        /**
         * Sets its value to that of its linked PlayMaker variable (if appropriate).
         */
        public void Download()
        {
            if (link == VarLink.PlaymakerGlobalVariable && pmVar != "")
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (type == VariableType.Integer || type == VariableType.PopUp)
                {
                    SetValue(PlayMakerIntegration.GetGlobalInt(pmVar));
                }
                else if (type == VariableType.Boolean)
                {
                    bool _val = PlayMakerIntegration.GetGlobalBool(pmVar);
                    if (_val)
                    {
                        SetValue(1);
                    }
                    else
                    {
                        SetValue(0);
                    }
                }
                else if (type == VariableType.String)
                {
                    SetStringValue(PlayMakerIntegration.GetGlobalString(pmVar));
                }
                else if (type == VariableType.Float)
                {
                    SetFloatValue(PlayMakerIntegration.GetGlobalFloat(pmVar));
                }
                else if (type == VariableType.Vector3)
                {
                    SetVector3Value(PlayMakerIntegration.GetGlobalVector3(pmVar));
                }
            }
            else if (link == VarLink.CustomScript)
            {
                KickStarter.eventManager.Call_OnDownloadVariable(this);
            }
        }
Exemplo n.º 9
0
        public override float Run()
        {
            if (isPlayer && KickStarter.player == null)
            {
                LogWarning("Cannot use Player's FSM since no Player was found!");
            }

            if (runtimeLinkedObject != null && !string.IsNullOrEmpty(eventName))
            {
                if (fsmName != "")
                {
                    PlayMakerIntegration.CallEvent(runtimeLinkedObject, eventName, fsmName);
                }
                else
                {
                    PlayMakerIntegration.CallEvent(runtimeLinkedObject, eventName);
                }
            }

            return(0f);
        }
Exemplo n.º 10
0
        /**
         * Sets the value of its linked Options Data or PlayMaker variable to its value (if appropriate).
         */
        public void Upload()
        {
            if (link == VarLink.PlaymakerGlobalVariable && pmVar != "")
            {
                if (!PlayMakerIntegration.IsDefinePresent())
                {
                    return;
                }

                if (type == VariableType.Integer || type == VariableType.PopUp)
                {
                    PlayMakerIntegration.SetGlobalInt(pmVar, val);
                }
                else if (type == VariableType.Boolean)
                {
                    if (val == 1)
                    {
                        PlayMakerIntegration.SetGlobalBool(pmVar, true);
                    }
                    else
                    {
                        PlayMakerIntegration.SetGlobalBool(pmVar, false);
                    }
                }
                else if (type == VariableType.String)
                {
                    PlayMakerIntegration.SetGlobalString(pmVar, textVal);
                }
                else if (type == VariableType.Float)
                {
                    PlayMakerIntegration.SetGlobalFloat(pmVar, floatVal);
                }
            }
            else if (link == VarLink.OptionsData)
            {
                Options.SavePrefs();
            }
        }
Exemplo n.º 11
0
        private void ShowVarGUI(VariableLocation location, List <VarPreset> _varPresets = null, string apiPrefix = "")
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showVariablesProperties = CustomGUILayout.ToggleHeader(showVariablesProperties, location + " variable '" + selectedVar.label + "' properties");
            if (showVariablesProperties)
            {
                selectedVar.label = CustomGUILayout.TextField("Label:", selectedVar.label, apiPrefix + ".label");
                selectedVar.type  = (VariableType)CustomGUILayout.EnumPopup("Type:", selectedVar.type, apiPrefix + ".type");

                if (location == VariableLocation.Local)
                {
                    //EditorGUILayout.LabelField ("Replacement token:", "[localvar:" + selectedVar.id.ToString () + "]");
                    CustomGUILayout.TokenLabel("[localvar:" + selectedVar.id.ToString() + "]");
                }
                else
                {
                    //EditorGUILayout.LabelField ("Replacement token:", "[var:" + selectedVar.id.ToString () + "]");
                    CustomGUILayout.TokenLabel("[var:" + selectedVar.id.ToString() + "]");
                }

                if (selectedVar.type == VariableType.Boolean)
                {
                    if (selectedVar.val != 1)
                    {
                        selectedVar.val = 0;
                    }
                    selectedVar.val = CustomGUILayout.Popup("Initial value:", selectedVar.val, boolType, apiPrefix + ".val");
                }
                else if (selectedVar.type == VariableType.Integer)
                {
                    selectedVar.val = CustomGUILayout.IntField("Initial value:", selectedVar.val, apiPrefix + ".val");
                }
                else if (selectedVar.type == VariableType.PopUp)
                {
                    selectedVar.popUps       = PopupsGUI(selectedVar.popUps);
                    selectedVar.val          = CustomGUILayout.Popup("Initial value:", selectedVar.val, selectedVar.popUps, apiPrefix + ".val");
                    selectedVar.canTranslate = CustomGUILayout.Toggle("Values can be translated?", selectedVar.canTranslate, apiPrefix + ".canTranslate");
                }
                else if (selectedVar.type == VariableType.String)
                {
                    selectedVar.textVal      = CustomGUILayout.TextField("Initial value:", selectedVar.textVal, apiPrefix + ".textVal");
                    selectedVar.canTranslate = CustomGUILayout.Toggle("Values can be translated?", selectedVar.canTranslate, apiPrefix + ".canTranslate");
                }
                else if (selectedVar.type == VariableType.Float)
                {
                    selectedVar.floatVal = CustomGUILayout.FloatField("Initial value:", selectedVar.floatVal, apiPrefix + ".floatVal");
                }
                else if (selectedVar.type == VariableType.Vector3)
                {
                    selectedVar.vector3Val = CustomGUILayout.Vector3Field("Initial value:", selectedVar.vector3Val, apiPrefix + ".vector3Val");
                }

                if (_varPresets != null)
                {
                    foreach (VarPreset _varPreset in _varPresets)
                    {
                        // Local
                        string apiPrefix2 = (location == VariableLocation.Local) ?
                                            "AC.KickStarter.localVariables.GetPreset (" + _varPreset.ID + ").GetPresetValue (" + selectedVar.id + ")" :
                                            "AC.KickStarter.runtimeVariables.GetPreset (" + _varPreset.ID + ").GetPresetValue (" + selectedVar.id + ")";

                        _varPreset.UpdateCollection(selectedVar);

                        string      label       = "'" + _varPreset.label + "' value:";
                        PresetValue presetValue = _varPreset.GetPresetValue(selectedVar);
                        if (selectedVar.type == VariableType.Boolean)
                        {
                            presetValue.val = CustomGUILayout.Popup(label, presetValue.val, boolType, apiPrefix2 + ".val");
                        }
                        else if (selectedVar.type == VariableType.Integer)
                        {
                            presetValue.val = CustomGUILayout.IntField(label, presetValue.val, apiPrefix2 + ".val");
                        }
                        else if (selectedVar.type == VariableType.PopUp)
                        {
                            presetValue.val = CustomGUILayout.Popup(label, presetValue.val, selectedVar.popUps, apiPrefix2 + ".val");
                        }
                        else if (selectedVar.type == VariableType.String)
                        {
                            presetValue.textVal = CustomGUILayout.TextField(label, presetValue.textVal, apiPrefix2 + ".textVal");
                        }
                        else if (selectedVar.type == VariableType.Float)
                        {
                            presetValue.floatVal = CustomGUILayout.FloatField(label, presetValue.floatVal, apiPrefix2 + ".floatVal");
                        }
                        else if (selectedVar.type == VariableType.Vector3)
                        {
                            presetValue.vector3Val = CustomGUILayout.Vector3Field(label, presetValue.vector3Val, apiPrefix2 + ".vector3Val");
                        }
                    }
                }

                if (location == VariableLocation.Local)
                {
                    selectedVar.link = VarLink.None;
                }
                else
                {
                    EditorGUILayout.Space();
                    selectedVar.link = (VarLink)CustomGUILayout.EnumPopup("Link to:", selectedVar.link, apiPrefix + ".link");
                    if (selectedVar.link == VarLink.PlaymakerGlobalVariable)
                    {
                        if (PlayMakerIntegration.IsDefinePresent())
                        {
                            selectedVar.pmVar             = CustomGUILayout.TextField("Playmaker Global Variable:", selectedVar.pmVar, apiPrefix + ".pmVar");
                            selectedVar.updateLinkOnStart = CustomGUILayout.Toggle("Use PM for initial value?", selectedVar.updateLinkOnStart, apiPrefix + ".updateLinkOnStart");
                        }
                        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 (selectedVar.link == VarLink.OptionsData)
                    {
                        EditorGUILayout.HelpBox("This Variable will be stored in PlayerPrefs, and not in saved game files.", MessageType.Info);
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 12
0
        private void ShowVarGUI(VariableLocation location, List <VarPreset> _varPresets = null)
        {
            EditorGUILayout.LabelField(location + " variable '" + selectedVar.label + "' properties", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical("Button");

            selectedVar.label = EditorGUILayout.TextField("Label:", selectedVar.label);
            selectedVar.type  = (VariableType)EditorGUILayout.EnumPopup("Type:", selectedVar.type);

            if (location == VariableLocation.Local)
            {
                EditorGUILayout.LabelField("Replacement token:", "[localvar:" + selectedVar.id.ToString() + "]");
            }
            else
            {
                EditorGUILayout.LabelField("Replacement token:", "[var:" + selectedVar.id.ToString() + "]");
            }

            if (selectedVar.type == VariableType.Boolean)
            {
                if (selectedVar.val != 1)
                {
                    selectedVar.val = 0;
                }
                selectedVar.val = EditorGUILayout.Popup("Initial value:", selectedVar.val, boolType);
            }
            else if (selectedVar.type == VariableType.Integer)
            {
                selectedVar.val = EditorGUILayout.IntField("Initial value:", selectedVar.val);
            }
            else if (selectedVar.type == VariableType.PopUp)
            {
                selectedVar.popUps = PopupsGUI(selectedVar.popUps);
                selectedVar.val    = EditorGUILayout.Popup("Initial value:", selectedVar.val, selectedVar.popUps);
            }
            else if (selectedVar.type == VariableType.String)
            {
                selectedVar.textVal = EditorGUILayout.TextField("Initial value:", selectedVar.textVal);
            }
            else if (selectedVar.type == VariableType.Float)
            {
                selectedVar.floatVal = EditorGUILayout.FloatField("Initial value:", selectedVar.floatVal);
            }

            if (_varPresets != null)
            {
                foreach (VarPreset _varPreset in _varPresets)
                {
                    _varPreset.UpdateCollection(selectedVar);

                    string      label       = "'" + _varPreset.label + "' value:";
                    PresetValue presetValue = _varPreset.GetPresetValue(selectedVar);
                    if (selectedVar.type == VariableType.Boolean)
                    {
                        presetValue.val = EditorGUILayout.Popup(label, presetValue.val, boolType);
                    }
                    else if (selectedVar.type == VariableType.Integer)
                    {
                        presetValue.val = EditorGUILayout.IntField(label, presetValue.val);
                    }
                    else if (selectedVar.type == VariableType.PopUp)
                    {
                        presetValue.val = EditorGUILayout.Popup(label, presetValue.val, selectedVar.popUps);
                    }
                    else if (selectedVar.type == VariableType.String)
                    {
                        presetValue.textVal = EditorGUILayout.TextField(label, presetValue.textVal);
                    }
                    else if (selectedVar.type == VariableType.Float)
                    {
                        presetValue.floatVal = EditorGUILayout.FloatField(label, presetValue.floatVal);
                    }
                }
            }

            if (location == VariableLocation.Local)
            {
                selectedVar.link = VarLink.None;
            }
            else
            {
                EditorGUILayout.Space();
                selectedVar.link = (VarLink)EditorGUILayout.EnumPopup("Link to:", selectedVar.link);
                if (selectedVar.link == VarLink.PlaymakerGlobalVariable)
                {
                    if (PlayMakerIntegration.IsDefinePresent())
                    {
                        selectedVar.pmVar             = EditorGUILayout.TextField("Playmaker Global Variable:", selectedVar.pmVar);
                        selectedVar.updateLinkOnStart = EditorGUILayout.Toggle("Use PM for initial value?", selectedVar.updateLinkOnStart);
                    }
                    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 (selectedVar.link == VarLink.OptionsData)
                {
                    EditorGUILayout.HelpBox("This Variable will be stored in PlayerPrefs, and not in saved game files.", MessageType.Info);
                }
            }
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 13
0
        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);
                }
            }
        }