private void SetParamGUI(List <ActionParameter> parameters, List <ActionParameter> ownParameters = null, bool forceConstantIDs = false)
        {
            if (parameters == null || parameters.Count == 0)
            {
                parameterLabel = "";
                return;
            }

            _parameter = GetParameterWithID(parameters, parameterID);

            if (_parameter == null)
            {
                parameterLabel = "";
                return;
            }

            parameterLabel = _parameter.label;

            setParamMethod = (SetParamMethod)EditorGUILayout.EnumPopup("New value is:", setParamMethod);

            if (setParamMethod == SetParamMethod.EnteredHere)
            {
                if (ownParameters != null && ownParameters.Count > 0)
                {
                    ownParamID = Action.ChooseParameterGUI("Set as:", ownParameters, ownParamID, _parameter.parameterType);
                    if (ownParamID >= 0)
                    {
                        return;
                    }
                }

                if (_parameter.parameterType == ParameterType.Boolean)
                {
                    bool boolValue = (intValue == 1) ? true : false;
                    boolValue = EditorGUILayout.Toggle("Set as:", boolValue);
                    intValue  = (boolValue) ? 1 : 0;
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    intValue = EditorGUILayout.IntField("Set as:", intValue);
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    floatValue = EditorGUILayout.FloatField("Set as:", floatValue);
                }
                else if (_parameter.parameterType == ParameterType.String)
                {
                    stringValue = EditorGUILayout.TextField("Set as:", stringValue);
                }
                else if (_parameter.parameterType == ParameterType.GameObject)
                {
                    gameobjectValue = (GameObject)EditorGUILayout.ObjectField("Set to:", gameobjectValue, typeof(GameObject), true);

                    gameObjectConstantID = FieldToID(gameobjectValue, gameObjectConstantID, forceConstantIDs);
                    gameobjectValue      = IDToField(gameobjectValue, gameObjectConstantID, false, forceConstantIDs);
                }
                else if (_parameter.parameterType == ParameterType.GlobalVariable)
                {
                    if (AdvGame.GetReferences().variablesManager == null || AdvGame.GetReferences().variablesManager.vars == null || AdvGame.GetReferences().variablesManager.vars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Global variables exist!", MessageType.Info);
                    }
                    else
                    {
                        intValue = ShowVarSelectorGUI(AdvGame.GetReferences().variablesManager.vars, intValue);
                    }
                }
                else if (_parameter.parameterType == ParameterType.UnityObject)
                {
                    unityObjectValue = (Object)EditorGUILayout.ObjectField("Set to:", unityObjectValue, typeof(Object), true);
                }
                else if (_parameter.parameterType == ParameterType.InventoryItem)
                {
                    intValue = ShowInvSelectorGUI(intValue);
                }
                else if (_parameter.parameterType == ParameterType.LocalVariable)
                {
                    if (isAssetFile)
                    {
                        EditorGUILayout.HelpBox("Cannot access local variables from an asset file.", MessageType.Warning);
                    }
                    else if (KickStarter.localVariables == null || KickStarter.localVariables.localVars == null || KickStarter.localVariables.localVars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Local variables exist!", MessageType.Info);
                    }
                    else
                    {
                        intValue = ShowVarSelectorGUI(KickStarter.localVariables.localVars, intValue);
                    }
                }
                else if (_parameter.parameterType == ParameterType.Vector3)
                {
                    vector3Value = EditorGUILayout.Vector3Field("Set as:", vector3Value);
                }
            }
            else if (setParamMethod == SetParamMethod.Random)
            {
                if (_parameter.parameterType == ParameterType.Boolean)
                {
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    intValue    = EditorGUILayout.IntField("Minimum:", intValue);
                    intValueMax = EditorGUILayout.IntField("Maximum:", intValueMax);
                    if (intValueMax < intValue)
                    {
                        intValueMax = intValue;
                    }
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    floatValue    = EditorGUILayout.FloatField("Minimum:", floatValue);
                    floatValueMax = EditorGUILayout.FloatField("Maximum:", floatValueMax);
                    if (floatValueMax < floatValue)
                    {
                        floatValueMax = floatValue;
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Parameters of type '" + _parameter.parameterType + "' cannot be set randomly.", MessageType.Warning);
                }
            }
            else if (setParamMethod == SetParamMethod.CopiedFromGlobalVariable)
            {
                if (AdvGame.GetReferences() != null && AdvGame.GetReferences().variablesManager != null && AdvGame.GetReferences().variablesManager.vars != null && AdvGame.GetReferences().variablesManager.vars.Count > 0)
                {
                    if (_parameter.parameterType == ParameterType.Vector3)
                    {
                        globalVariableID = AdvGame.GlobalVariableGUI("Vector3 variable:", globalVariableID, VariableType.Vector3);
                    }
                    else if (_parameter.parameterType == ParameterType.GameObject || _parameter.parameterType == ParameterType.GlobalVariable || _parameter.parameterType == ParameterType.InventoryItem || _parameter.parameterType == ParameterType.LocalVariable || _parameter.parameterType == ParameterType.UnityObject)
                    {
                        EditorGUILayout.HelpBox("Parameters of type '" + _parameter.parameterType + "' cannot have values transferred from Global Variables.", MessageType.Warning);
                    }
                    else
                    {
                        globalVariableID = AdvGame.GlobalVariableGUI("Variable:", globalVariableID);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No Global Variables found!", MessageType.Warning);
                }
            }
            else if (setParamMethod == SetParamMethod.CopiedFromParameter)
            {
                if (changeOwn)
                {
                    parameterToCopyID = Action.ChooseParameterGUI(parameters, parameterToCopyID);
                }
                else
                {
                    if (actionListSource == ActionListSource.InScene && actionList != null)
                    {
                        if (actionList.source == ActionListSource.InScene)
                        {
                            if (actionList.useParameters && actionList.parameters.Count > 0)
                            {
                                parameterToCopyID = Action.ChooseParameterGUI(actionList.parameters, parameterToCopyID);
                            }
                        }
                        else if (actionList.source == ActionListSource.AssetFile && actionList.assetFile != null)
                        {
                            if (actionList.assetFile.useParameters && actionList.assetFile.parameters.Count > 0)
                            {
                                parameterToCopyID = Action.ChooseParameterGUI(actionList.assetFile.parameters, parameterToCopyID);
                            }
                        }
                    }
                    else if (actionListSource == ActionListSource.AssetFile && actionListAsset != null)
                    {
                        if (actionListAsset.useParameters && actionListAsset.parameters.Count > 0)
                        {
                            parameterToCopyID = Action.ChooseParameterGUI(actionListAsset.parameters, parameterToCopyID);
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void SetParamGUI(List <ActionParameter> parameters)
        {
            if (parameters == null || parameters.Count == 0)
            {
                parameterLabel = "";
                return;
            }

            _parameter = GetParameterWithID(parameters, parameterID);

            if (_parameter == null)
            {
                parameterLabel = "";
                return;
            }

            parameterLabel = _parameter.label;

            setParamMethod = (SetParamMethod)EditorGUILayout.EnumPopup("New value is:", setParamMethod);

            if (setParamMethod == SetParamMethod.EnteredHere)
            {
                if (_parameter.parameterType == ParameterType.Boolean)
                {
                    bool boolValue = (intValue == 1) ? true : false;
                    boolValue = EditorGUILayout.Toggle("Set as:", boolValue);
                    intValue  = (boolValue) ? 1 : 0;
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    intValue = EditorGUILayout.IntField("Set as:", intValue);
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    floatValue = EditorGUILayout.FloatField("Set as:", floatValue);
                }
                else if (_parameter.parameterType == ParameterType.String)
                {
                    stringValue = EditorGUILayout.TextField("Set as:", stringValue);
                }
                else if (_parameter.parameterType == ParameterType.GameObject)
                {
                    gameobjectValue = (GameObject)EditorGUILayout.ObjectField("Set to:", gameobjectValue, typeof(GameObject), true);

                    gameObjectConstantID = FieldToID(gameobjectValue, gameObjectConstantID);
                    gameobjectValue      = IDToField(gameobjectValue, gameObjectConstantID, false);
                }
                else if (_parameter.parameterType == ParameterType.GlobalVariable)
                {
                    if (AdvGame.GetReferences().variablesManager == null || AdvGame.GetReferences().variablesManager.vars == null || AdvGame.GetReferences().variablesManager.vars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Global variables exist!", MessageType.Info);
                    }
                    else
                    {
                        intValue = ShowVarSelectorGUI(AdvGame.GetReferences().variablesManager.vars, intValue);
                    }
                }
                else if (_parameter.parameterType == ParameterType.UnityObject)
                {
                    unityObjectValue = (Object)EditorGUILayout.ObjectField("Set to:", unityObjectValue, typeof(Object), true);
                }
                else if (_parameter.parameterType == ParameterType.InventoryItem)
                {
                    intValue = ShowInvSelectorGUI(intValue);
                }
                else if (_parameter.parameterType == ParameterType.LocalVariable)
                {
                    if (isAssetFile)
                    {
                        EditorGUILayout.HelpBox("Cannot access local variables from an asset file.", MessageType.Warning);
                    }
                    else if (KickStarter.localVariables == null || KickStarter.localVariables.localVars == null || KickStarter.localVariables.localVars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Local variables exist!", MessageType.Info);
                    }
                    else
                    {
                        intValue = ShowVarSelectorGUI(KickStarter.localVariables.localVars, intValue);
                    }
                }
                else if (_parameter.parameterType == ParameterType.Vector3)
                {
                    vector3Value = EditorGUILayout.Vector3Field("Set as:", vector3Value);
                }
            }
            else
            {
                if (AdvGame.GetReferences() != null && AdvGame.GetReferences().variablesManager != null && AdvGame.GetReferences().variablesManager.vars != null && AdvGame.GetReferences().variablesManager.vars.Count > 0)
                {
                    if (_parameter.parameterType == ParameterType.Vector3)
                    {
                        globalVariableID = AdvGame.GlobalVariableGUI("Vector3 variable:", globalVariableID, VariableType.Vector3);
                    }
                    else if (_parameter.parameterType == ParameterType.GameObject || _parameter.parameterType == ParameterType.GlobalVariable || _parameter.parameterType == ParameterType.InventoryItem || _parameter.parameterType == ParameterType.LocalVariable || _parameter.parameterType == ParameterType.UnityObject)
                    {
                        EditorGUILayout.HelpBox("Parameters of type '" + _parameter.parameterType + "' cannot have values transferred from Global Variables.", MessageType.Warning);
                    }
                    else
                    {
                        globalVariableID = AdvGame.GlobalVariableGUI("Variable:", globalVariableID);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No Global Variables found!", MessageType.Warning);
                }
            }
        }