コード例 #1
0
        public void OnGUI()
        {
            multiSetParameterIndex = -1;

            if (CloseIfError())
            {
                Close();
                return;
            }

            GUIUtils.StartBox(1);

            if (!selectionSystem.hasSelection)
            {
                GUIUtils.Label(noAOsGUI);
            }
            else
            {
                bool drawingSingle = selectionSystem.singleSelected;

                SelectionElement firstSelected = selectionSystem.firstSelected;

                EditorProp assetObjectProp = drawingSingle ? AOStateMachineEditor.GetAOatPoolID(currentState, firstSelected.refIndex) : multiEditAssetObjectProp;

                if (assetObjectProp == null)
                {
                    GUIUtils.Label(noAOsGUI);
                }
                else
                {
                    // GUIUtils.Label(drawingSingle ? new GUIContent("<b>" + firstSelected.path + "</b>") : selectEditGUI);
                    GUIUtils.Label(drawingSingle ? new GUIContent("<b>" + firstSelected.gui.text + "</b>") : selectEditGUI);

                    GUILayout.FlexibleSpace();

                    GUIUtils.BeginIndent();
                    DrawAOParameters(drawingSingle, assetObjectProp);
                    GUIUtils.EndIndent();

                    GUILayout.FlexibleSpace();

                    bool setMessages   = DrawMessaging(AOStateMachineEditor.messageBlocksField, sendMessagesGUI, assetObjectProp, drawingSingle);
                    bool setConditions = DrawMessaging(AOStateMachineEditor.conditionsBlockField, conditionsGUI, assetObjectProp, drawingSingle);

                    if (!drawingSingle)
                    {
                        if (multiSetParameterIndex != -1)
                        {
                            CopyParameters(
                                selectionSystem.GetReferenceIndiciesInSelectionOrAllShown(false).Generate(i => AOStateMachineEditor.GetAOatPoolID(currentState, i)),
                                multiEditAssetObjectProp,
                                multiSetParameterIndex
                                );
                        }
                        if (setMessages || setConditions)
                        {
                            CopyTextBlock(
                                selectionSystem.GetReferenceIndiciesInSelectionOrAllShown(false).Generate(i => AOStateMachineEditor.GetAOatPoolID(currentState, i)),
                                multiEditAssetObjectProp,
                                setMessages ? AOStateMachineEditor.messageBlocksField : AOStateMachineEditor.conditionsBlockField
                                );
                        }
                    }
                }
            }

            GUILayout.FlexibleSpace();
            if (GUIUtils.Button(closeGUI, GUIStyles.button, Colors.blue, Colors.black))
            {
                Close();
            }

            GUIUtils.EndBox(1);
            stateMachineEditor.so.SaveObject();
        }
コード例 #2
0
 public static AssetObjectWindow ShowAssetObjectWindow(AOStateMachineEditor stateMachineEditor, EditorProp packProp, ElementSelectionSystem selectionSystem)
 {
     return(((AssetObjectWindow)GetWindow(typeof(AssetObjectWindow), true, "Asset Object:", false)).InitializeInternal(stateMachineEditor, packProp, selectionSystem));
 }
コード例 #3
0
 public void SetCurrentState(EditorProp currentState)
 {
     this.currentState = currentState;
 }
コード例 #4
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]);
                }
            }
        }
コード例 #5
0
        AssetObjectWindow InitializeInternal(AOStateMachineEditor stateMachineEditor, EditorProp packProp, ElementSelectionSystem selectionSystem)
        {
            this.stateMachineEditor = stateMachineEditor;
            this.selectionSystem    = selectionSystem;

            multiEditAssetObjectProp = new EditorProp(new SerializedObject(this))["multiEditAssetObject"];
            PacksManagerEditor.UpdateAssetObjectParametersIfDifferentFromDefaults(multiEditAssetObjectProp, packProp, true, true);

            EditorProp aoParameters = multiEditAssetObjectProp[AOStateMachineEditor.paramsField];
            int        paramsLength = aoParameters.arraySize;

            parameterLabels = paramsLength.Generate(i => new GUIContent(aoParameters[i]["name"].stringValue)).ToArray();

            int ySize = minSizeWithoutParameters + (parameterYSize * paramsLength);

            position = new Rect(256, 256, 400, ySize);
            return(this);
        }
コード例 #6
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);
     }
 }
コード例 #7
0
 static void DefaultDurationParameter(EditorProp parameter)
 {
     parameter[CustomParameterEditor.nameField].SetValue("Duration");
     parameter[CustomParameterEditor.typeField].SetValue((int)CustomParameter.ParamType.FloatValue);
     parameter[CustomParameter.ParamType.FloatValue.ToString()].SetValue(-1.0f);
 }
コード例 #8
0
 void OnEnable()
 {
     so           = new EditorProp(serializedObject);
     packsManager = target as PacksManager;
     errors       = GetPacksErrors(packsManager, packs);
 }
コード例 #9
0
 bool CheckedVariable(EditorProp variable, GUIContent content, GUILayoutOption option)
 {
     return(GUIUtils.DrawTextProp(variable, content, GUIUtils.TextFieldType.Normal, false, " var ", option));
 }
コード例 #10
0
 void OnEnable()
 {
     so = new EditorProp(serializedObject);
 }