예제 #1
0
 void CopyParameters(IEnumerable <EditorProp> aos, EditorProp aoCopy, int paramIndex)
 {
     foreach (var ao in aos)
     {
         if (ao != null)
         {
             CustomParameterEditor.CopyParameter(ao[AOStateMachineEditor.paramsField][paramIndex], aoCopy[AOStateMachineEditor.paramsField][paramIndex]);
         }
     }
 }
예제 #2
0
 public static void UpdateAssetObjectParametersIfDifferentFromDefaults(EditorProp ao, EditorProp pack, bool reset, bool debug)
 {
     if (reset)
     {
         CustomParameterEditor.CopyParameterList(ao[AOStateMachineEditor.paramsField], pack[defaultParametersField]);
     }
     else
     {
         UpdateParametersIfDifferentFromDefaults(ao[AOStateMachineEditor.paramsField], pack[defaultParametersField], debug);
     }
 }
예제 #3
0
        bool DrawPackParameter(EditorProp parameter)
        {
            //name
            bool nameChanged = GUIUtils.DrawTextProp(parameter[nameField], GUIUtils.TextFieldType.Normal, false, "param name", GUILayout.MinWidth(32));
            //type
            GUILayoutOption pFieldWidth = GUILayout.Width(100);

            GUIUtils.DrawEnumProp(
                parameter[CustomParameterEditor.typeField],
                (int i) => (CustomParameter.ParamType)i,
                (Enum s) => (int)((CustomParameter.ParamType)s),
                pFieldWidth
                );
            //value
            GUIUtils.DrawProp(CustomParameterEditor.GetParamValueProperty(parameter), GUILayout.Width(128));
            return(nameChanged);
        }
예제 #4
0
        void DrawAOParameters(bool drawingSingle, EditorProp ao)
        {
            for (int i = 0; i < parameterLabels.Length; i++)
            {
                EditorGUILayout.BeginHorizontal();

                //multi set button
                GUI.enabled = !drawingSingle;
                if (GUIUtils.SmallButton(multiSetValueGUI))
                {
                    multiSetParameterIndex = i;
                }
                GUI.enabled = true;

                GUIUtils.Label(parameterLabels[i], parameterLabelWidth);
                GUIUtils.DrawProp(CustomParameterEditor.GetParamValueProperty(ao[AOStateMachineEditor.paramsField][i]));

                EditorGUILayout.EndHorizontal();
            }
        }
예제 #5
0
        static void UpdateParametersIfDifferentFromDefaults(EditorProp parameters, EditorProp defaultParams, bool debug)
        {
            int aoParametersCount  = parameters.arraySize;
            int defParametersCount = defaultParams.arraySize;

            Func <EditorProp, string> GetParamName = (EditorProp parameter) => parameter[CustomParameterEditor.nameField].stringValue;

            //check for parameters to delete
            for (int i = aoParametersCount - 1; i >= 0; i--)
            {
                string name        = GetParamName(parameters[i]);
                bool   inDefParams = false;
                for (int d = 0; d < defParametersCount; d++)
                {
                    if (GetParamName(defaultParams[d]) == name)
                    {
                        inDefParams = true;
                        break;
                    }
                }
                if (!inDefParams)
                {
                    if (debug)
                    {
                        Debug.Log("Deleting param: " + name);
                    }
                    parameters.DeleteAt(i, "deleting different params");
                }
            }
            // Debug.Log("finished deletes");

            aoParametersCount = parameters.arraySize;



            //check for parameters that need adding
            for (int i = 0; i < defParametersCount; i++)
            {
                var    defParam     = defaultParams[i];
                string defParamName = GetParamName(defParam);


                bool inParams = false;
                for (int p = 0; p < aoParametersCount; p++)
                {
                    if (GetParamName(parameters[p]) == defParamName)
                    {
                        inParams = true;
                        break;
                    }
                }
                if (!inParams)
                {
                    if (debug)
                    {
                        Debug.Log("adding param: " + defParamName);
                    }
                    CustomParameterEditor.CopyParameter(parameters.AddNew(), defParam);
                }
            }

            aoParametersCount = parameters.arraySize;


            // Debug.Log("finished Adds");

            //reorder to same order


            EditorProp temp = null;

            for (int d = 0; d < defParametersCount; d++)
            {
                string defParamName = GetParamName(defaultParams[d]);
                var    parameter    = parameters[d];
                if (GetParamName(parameter) == defParamName)
                {
                    continue;
                }

                if (debug)
                {
                    Debug.Log("moving param: " + GetParamName(parameter));
                }

                EditorProp trueParam = null;
                //for (int p = d + 1; p < c_p; p++) {
                for (int p = 0; p < aoParametersCount; p++)
                {
                    trueParam = parameters[p];
                    if (GetParamName(trueParam) == defParamName)
                    {
                        break;
                    }
                }

                if (trueParam == null)
                {
                    if (debug)
                    {
                        Debug.LogError("couldnt find: " + defParamName);
                    }
                }
                //put the current one in temp

                if (temp == null)
                {
                    //make extra temp parameeter
                    temp = parameters.AddNew();
                }

                // Debug.Log("put in temp");
                CustomParameterEditor.CopyParameter(temp, parameter);
                //place the real param in the current
                // Debug.Log("put in current");
                CustomParameterEditor.CopyParameter(parameter, trueParam);


                //place temp in old param that was moved
                // Debug.Log("put in temp 2");

                CustomParameterEditor.CopyParameter(trueParam, temp);
            }

            if (temp != null)
            {
                //delete temp parameter
                parameters.DeleteAt(parameters.arraySize - 1, "deleting temp param");
            }

            //check type changes
            Func <EditorProp, int> GetParamType = (EditorProp parameter) => parameter[CustomParameterEditor.typeField].intValue;

            for (int i = 0; i < defParametersCount; i++)
            {
                if (GetParamType(parameters[i]) != GetParamType(defaultParams[i]))
                {
                    if (debug)
                    {
                        Debug.Log("changing: " + GetParamName(parameters[i]) + " from " + GetParamType(parameters[i]) + " to " + GetParamType(defaultParams[i]));
                    }
                    CustomParameterEditor.CopyParameter(parameters[i], defaultParams[i]);
                }
            }
        }