void DrawFSMGraph(ref bool regen, ref bool repos)
        {
            foldoutStates = QuickGUI.DrawHeader("状态预览图", "foldout", false);
            if (foldoutStates)
            {
                QuickGUI.BeginContents(50);
                //EditorGUILayout.BeginVertical("helpbox");

                //EditorGUILayout.BeginHorizontal();
                //EditorGUILayout.EndHorizontal();

                QuickGUI.ReportView(ref stateClipRect, stateViewPos, OnDrawFSMGraphCallback, Mathf.Max(350f, stateClipRect.width * 0.75f), 80);
                stateClipRectCenter = stateClipRect.size * 0.5f;

                EditorGUI.BeginDisabledGroup(Application.isPlaying);

                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(40);
                regen |= GUILayout.Button("Rebuild State Machine");
                GUILayout.Space(40);
                EditorGUILayout.EndHorizontal();

                EditorGUI.EndDisabledGroup();

                QuickGUI.EndContents();
                //EditorGUILayout.EndVertical();
            }
        }
        void DrawFSMGraph()
        {
            FStateMachineMono f = target as FStateMachineMono;

            fsmImpl = f.FSM;
            if (fsm != f)
            {
                fsm         = f;
                fsm.IsDirty = true;
            }
            if (fsm.IsDirty)
            {
                Reposition(fsm);
                fsm.IsDirty = false;
            }
            foldoutStates = QuickGUI.DrawHeader("状态预览图", "foldout", false);
            if (foldoutStates)
            {
                QuickGUI.BeginContents(50);
                GUILayout.Space(10);
                EditorGUILayout.BeginHorizontal();
                float scale = EditorGUILayout.Slider("滑动缩放视图", cellScale, 0.5f, 3f);
                EditorGUI.BeginDisabledGroup(Application.isPlaying);
                bool regen = GUILayout.Button("刷新", GUILayout.Height(20));
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();


                if (regen || reloaded)
                {
                    fsm.GenerateStateMachine();
                    fsm.IsDirty = true;
                    reloaded    = false;
                }
                if (Mathf.Abs(scale - cellScale) > 0.01f)
                {
                    cellScale   = scale;
                    fsm.IsDirty = true;
                }
                if (fsm.IsDirty)
                {
                    Reposition(fsm);
                    fsm.IsDirty = false;
                }
                QuickGUI.ReportView(ref stateClipRect, stateViewPos, OnDrawFSMGraphCallback, Mathf.Max(350f, stateClipRect.width * 0.75f), 80);
                stateClipRectCenter = stateClipRect.size * 0.5f;

                QuickGUI.EndContents();
            }
            if (fsm.IsDirty)
            {
                Reposition(fsm);
                fsm.IsDirty = false;
            }
        }
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     if (QuickGUI.TitleBar("Add Point", 12) == 0)
     {
         mPolygon.AddPoint(Vector2.zero);
         return;
     }
     drop = QuickGUI.DrawHeader("Points", null, drop);
     if (drop)
     {
         QuickGUI.BeginContents(20);
         for (int i = 0; i < mPolygon.Points.Length; i++)
         {
             bool    del = false;
             Vector2 p   = mPolygon.Points[i];
             EditorGUILayout.BeginHorizontal();
             Vector2 newp = EditorGUILayout.Vector2Field("", p);
             if (p != newp)
             {
                 mPolygon.Points[i] = newp;
                 mPolygon.SetVerticesDirty();
             }
             if (i > 2 && GUILayout.Button("-", GUILayout.Width(20)))
             {
                 del = true;
             }
             EditorGUILayout.EndHorizontal();
             if (del)
             {
                 mPolygon.RemovePoint(i);
                 break;
             }
         }
         QuickGUI.EndContents();
     }
 }
        public static void OnBlackboardInspectorGUI(BlackboardAsset asset)
        {
            drop = QuickGUI.DrawHeader("Blackboard", "BT", false);
            if (drop)
            {
                QuickGUI.BeginContents(200);
                scroll = GUILayout.BeginScrollView(scroll, GUILayout.MaxHeight(200));
                for (int i = 0; i < asset.m_Properties.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("", "OL Minus", GUILayout.Width(20)))
                    {
                        BlackboardAsset.KeyValue[] keys = new BlackboardAsset.KeyValue[asset.m_Properties.Length - 1];
                        if (i > 0)
                        {
                            System.Array.Copy(asset.m_Properties, 0, keys, 0, i);
                        }
                        if (i < asset.m_Properties.Length - 1)
                        {
                            System.Array.Copy(asset.m_Properties, i + 1, keys, i, keys.Length - i);
                        }
                        asset.m_Properties = keys;
                        EditorUtility.SetDirty(asset);
                        break;
                    }
                    BlackboardAsset.KeyValue key = asset.m_Properties[i];
                    GUILayout.Label(key.m_Key, GUILayout.Width(140));
                    GUILayout.Label(key.m_Value, "textfield");
                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndScrollView();
                GUILayout.Space(10);

                if (JDateTime.NowMillies - repeatTip < 2000)
                {
                    GUILayout.Label("已经存在相同的属性", "flow overlay box");
                }
                EditorGUILayout.BeginHorizontal();
                dropIndex = Mathf.Min(dropIndex, BehaviourModuleManager.GetOrNewInstance().SharedTypeNames.Length - 1);
                if (GUILayout.Button("", "OL Plus", GUILayout.Width(20)))
                {
                    if (string.IsNullOrEmpty(newName) || asset.HasKey(newName))
                    {
                        repeatTip = JDateTime.NowMillies;
                    }
                    else
                    {
                        BlackboardAsset.KeyValue[] keys = new BlackboardAsset.KeyValue[asset.m_Properties.Length + 1];
                        if (keys.Length > 1)
                        {
                            System.Array.Copy(asset.m_Properties, keys, keys.Length - 1);
                        }
                        BlackboardAsset.KeyValue newk = new BlackboardAsset.KeyValue();
                        newk.m_Key            = newName;
                        newk.m_Value          = BehaviourModuleManager.GetOrNewInstance().SharedTypeNames[dropIndex];
                        keys[keys.Length - 1] = newk;
                        asset.m_Properties    = keys;
                        EditorUtility.SetDirty(asset);
                        newName = "newVariable";
                        scroll  = Vector2.up * asset.m_Properties.Length * 30;
                    }
                }
                newName   = GUILayout.TextField(newName ?? "newVariable", GUILayout.Width(140));
                dropIndex = EditorGUILayout.Popup(dropIndex, BehaviourModuleManager.GetOrNewInstance().SharedTypeNames);
                EditorGUILayout.EndHorizontal();
                QuickGUI.EndContents();
            }
        }
Пример #5
0
        public override void OnInspectorGUI()
        {
            GUI.skin.label.richText = true;
            CheckTarget();
            bool dirty = false;

            GUILayout.Space(10);
            ECurveType tp = (ECurveType)EditorGUILayout.EnumPopup(mPath.m_Type);

            if (tp != mPath.m_Type)
            {
                mPath.m_Type = tp;
                dirty        = true;
            }
            int insertAt = -1;
            int deleteAt = -1;

            mFreezeAxis = QuickGUI.MultiOptionBar(mFreezeAxis, freezeOption);
            mPointsArea = GUILayout.BeginScrollView(mPointsArea, GUILayout.MaxHeight(200));
            if (QuickGUI.DrawHeader("Sample Points", "sample points", false))
            {
                QuickGUI.BeginContents(170);
                for (int i = 1; i < caches.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    int n = QuickGUI.GroupButton(addSubBtn, GUILayout.Width(40));
                    caches[i] = EditorGUILayout.Vector3Field(string.Format("P{0}{1}", i, i == mCurrentPoint?" [Moving]":""), caches[i]);
                    EditorGUILayout.EndHorizontal();
                    if (n != -1)
                    {
                        insertAt = n == 0 ? i : -1;
                        deleteAt = n == 1 ? i : -1;
                    }
                    if (Vector3.Distance(caches[i], mPath.m_Points[i]) > snapDis)
                    {
                        dirty             = true;
                        mPath.m_Points[i] = caches[i];
                    }
                }
                if (GUILayout.Button("+", GUILayout.Width(20)))
                {
                    insertAt = caches.Length;
                    deleteAt = -1;
                }
                QuickGUI.EndContents();
            }
            GUILayout.EndScrollView();

            if (insertAt > 0)
            {
                InsertAt(insertAt);
                dirty = true;
            }
            else if (deleteAt > 0)
            {
                DeleteAt(deleteAt);
                dirty = true;
            }

            if (dirty)
            {
                caches = new Vector3[mPath.m_Points.Length];
                System.Array.Copy(mPath.m_Points, caches, caches.Length);
                mPath.RecalculateLater();
                SceneView.RepaintAll();
            }
        }