Ejemplo n.º 1
0
        private void OnGUI()
        {
            OnPrepareGraphGUI();
            ProcessMouseDeltaPos();

            GUI.skin.label.richText = true;

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal("TE toolbar");
            OnTitleGUI();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUI.SetNextControlName(mViewportName);

            QuickGUI.ReportView(ref mClipRect, mViewPos, OnDrawGUI, position.height, 100, mViewportTitle);
            mViewOffset = -mViewPos + new Vector2(mClipRect.size.x * 0.5f, 100f);
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            ProcessEvent();
            ProcessFocusCenter();

            OnGraphGUIEnd();

            if (repaint || onFocus)
            {
                Repaint();
            }
            repaint = false;
        }
Ejemplo n.º 2
0
 public override void OnGUI(Rect clipRect)
 {
     if (!Visible)
     {
         return;
     }
     mResizeNode = false;
     QuickGUI.DrawBox(GlobalRect, new Color(0.3f, 0.3f, 0.3f), Color.black, 2, true);
     //GUI.Label(GlobalRect, "", "sv_iconselector_back");
     if (Mode == EMode.alter_node)
     {
         OnContextDecoratorGUI();
         OnDecoratorsListGUI();
     }
     else if (Mode == EMode.new_node)
     {
         OnNewNodeGUI();
     }
     //GUI.Label(GlobalRect, "", "Icon.OutlineBorder");
     if (mResizeNode)
     {
         BehaviourNodeGUI node = Context as BehaviourNodeGUI;
         if (node != null)
         {
             node.Resize();
         }
         mResizeNode = false;
     }
     if (!Visible)
     {
         Hide();
     }
 }
        protected virtual void OnChildSlotLayer(Rect rect)
        {
            raychild = !editor.IsRequestParentOrChild && rect.Contains(editor.GlobalMousePosition);
            var highlight = raychild || editor.PresentChildRequest == this;

            QuickGUI.DrawBox(rect, highlight ? SELECTED_COLOR * 0.8f : SLOT_COLOR, highlight ? SELECTED_COLOR : BOARDER_COLOR, 2, raychild);
        }
        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();
            }
        }
Ejemplo n.º 5
0
        public override void DrawComment(bool raycast)
        {
            if (mAsset == null)
            {
                return;
            }
            var com = mAsset.m_Comment;

            if (string.IsNullOrEmpty(com))
            {
                return;
            }
            if (com != mComment)
            {
                mComment     = com;
                mCommentSize = CalculateSubtitleSize(mComment, SUB_SIZE + 2);
            }
            var rect = new Rect();
            var size = mCommentSize * GlobalScale;

            rect.size = size + Vector2.one * 4;
            rect.x    = GlobalRect.x;
            rect.y    = GlobalRect.y - size.y - 8;
            QuickGUI.DrawBox(rect, Color.gray * (raycast ? 0.7f : 0.5f), Color.black, raycast ? 1 : 0);
            rect.size = size;
            rect.x    = GlobalRect.x + 2;
            rect.y    = GlobalRect.y - size.y - 6;
            GUISubtitle(rect, mComment, Color.white * (raycast ? 1f : 0.7f), SUB_SIZE + 2, raycast ? FontStyle.Normal : FontStyle.Italic, TextAnchor.MiddleLeft);
        }
        void DrawResultsList()
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUI.SetNextControlName("QuickSearch");
            string s = QuickGUI.SearchTextBar(sampleSearch);

            UpdateShowResult(s);

            GUILayout.Label(string.Format("{0}/{1}", off, showResults.Count), "ProgressBarBack");
            GUILayout.EndHorizontal();
            GUILayout.Space(10);

            QuickGUI.StepVerticalScroll(ref off, ref scrollPos, 30, showResults.Count, DrawResultItem, null);

            GUILayout.BeginHorizontal();

            pPercent = showResults.Count > 30 ? (float)off / (float)(showResults.Count - 30) : 1f;
            float p2 = GUILayout.HorizontalSlider(pPercent, 0f, 1f);

            if (p2 != pPercent && showResults.Count > 30)
            {
                off = Mathf.FloorToInt((showResults.Count - 30) * p2);
            }
            pPercent = p2;

            GUILayout.Label(string.Format("{0}/{1}", Mathf.Min(off + 30, showResults.Count), showResults.Count), "ProgressBarBack");
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
 protected virtual void OnContentLayer(Rect rect)
 {
     QuickGUI.DrawBox(rect, color, selected ? SELECTED_COLOR : BOARDER_COLOR, selected ? 2 : 1, true);
     if (!string.IsNullOrEmpty(title))
     {
         GUITitle(rect, title);
     }
 }
Ejemplo n.º 8
0
        public override void OnGUI(Rect clipRect)
        {
            mRaycastProperty = null;
            if (Blackboard == null)
            {
                Visible = false;
                return;
            }
            //bool vis = mVisible;
            //if (!vis && mVisible)
            //    mTick = JDateTime.NowMillies;
            Rect rec = LocalRect;

            rec.width    = Mathf.Clamp(Parent.LocalRect.width * 0.35f, 200, 500);
            rec.height   = mDrop ? 180 : 25;
            rec.position = new Vector2(0, Parent.LocalRect.height - LocalRect.height);
            LocalRect    = rec;

            BTBlackboard blackboard = Blackboard;

            //bool set;
            QuickGUI.DrawBox(GlobalRect, Color.gray * 0.5f, Color.black, 1, true);
            Rect r = new Rect(GlobalRect.xMin, GlobalRect.yMin, GlobalRect.width, 20);

            //bool drop = mDrop;
            mDrop = GUI.Toggle(r, mDrop, "Blackboard", "PreDropDown") && blackboard.Length > 0;
            //if (!drop && mDrop)
            //    mTick = JDateTime.NowMillies;
            if (mDrop)
            {
                r.height = GlobalRect.height - 20;
                r.y      = GlobalRect.yMin + 25;
                BeginScroll(r, ref mScrollRect);
                r.position = new Vector2(0, mScrollOffset);
                r.height   = 20;
                for (int i = 0; i < blackboard.Length; i++)
                {
                    r.width    = 100;
                    r.position = new Vector2(0, i * 20 + mScrollOffset);
                    GUI.Label(r, blackboard.GetPropertyName(i));
                    r.width = GlobalRect.width - 100;
                    r.x     = 100;
                    if (blackboard.IsSet(i))
                    {
                        GUI.Label(r, blackboard[i].ToString(), "AssetLabel");
                    }
                    else
                    {
                        GUI.Label(r, "[NOT SET]");
                    }
                    if (r.Contains(Event.current.mousePosition))
                    {
                        mRaycastProperty = blackboard[i];
                    }
                }
                EndScroll(r.yMax, ref mScrollRect, ref mScrollOffset);
            }
        }
Ejemplo n.º 9
0
        protected override void OnContentLayer(Rect rect)
        {
            if (mResize)
            {
                DoResize();
            }
            mContext = null;
            var space  = SPACE * GlobalScale;
            var icon   = ICON_SIZE * GlobalScale * 1.5f;
            var tsize  = mTitleSize * GlobalScale;
            var dsize  = mDetailSize * GlobalScale;
            var decorh = mDecorHeight * GlobalScale;

            var pos = rect;

            QuickGUI.DrawBox(rect, color, selected ? SELECTED_COLOR : BOARDER_COLOR, 0, true);
            if (editor.Binder.IsRunning())
            {
                pos.width *= Mathf.PingPong(Time.realtimeSinceStartup * 0.5f, 1f);
                GUI.Label(pos, DevilEditorUtility.EmptyContent, "MeLivePlayBar");
            }

            pos.size     = icon;
            pos.position = rect.position + space;
            GUI.DrawTexture(pos, AIModules.icon);
            pos.size = tsize;
            pos.x   += space.x + icon.x;
            GUITitle(pos, title, TITLE_COLOR, TITLE_SIZE + 4, FontStyle.Bold, TextAnchor.MiddleLeft);
            pos.size     = dsize;
            pos.position = rect.position + new Vector2(space.x, tsize.y + space.y);
            GUITitle(pos, detail, Color.white, FontStyle.Normal, TextAnchor.MiddleLeft);

            var   raycast = false;
            float h       = pos.yMax + space.y;

            for (int i = 0; i < mServiceNames.Count; i++)
            {
                pos.position = new Vector2(rect.x, h + i * decorh);
                pos.size     = new Vector2(rect.width, decorh);
                raycast      = pos.Contains(editor.GlobalMousePosition);
                if (raycast)
                {
                    mContext = mServiceNodes[i];
                }
                QuickGUI.DrawBox(pos, raycast ? SELECTED_COLOR : mServiceModules[i].color, SELECTED_COLOR, 0);

                pos.size = Vector2.one * decorh * 0.9f;
                GUI.DrawTexture(pos, mServiceModules[i].icon);
                pos.x += decorh;
                GUISubtitle(pos, mServiceNames[i], raycast ? Color.black : SUBTITLE_COLOR, FontStyle.Normal, TextAnchor.MiddleLeft);
                if (GetServiceName(mServiceNodes[i], mServiceModules[i]) != mServiceNames[i])
                {
                    Resize();
                }
            }
        }
        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;
            }
        }
        void DrawComponentField()
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Component", GUILayout.Width(100));
            string[] pops = new string[mAllCmpTypes.Count + 1];
            pops[0] = "All";
            for (int i = 1; i < pops.Length; i++)
            {
                pops[i] = mAllCmpTypes[i - 1].Name;
            }
            cmpIndex = Mathf.Min(cmpIndex, pops.Length - 1);
            GUILayout.Label(pops[cmpIndex], "ShurikenModuleTitle");
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
            showCmps = QuickGUI.SearchTextBar(showCmps);
            EditorGUILayout.EndHorizontal();
            cmpPos = GUILayout.BeginScrollView(cmpPos, "box");
            bool first = true;

            for (int i = 0; i < pops.Length; i++)
            {
                bool old = cmpIndex == i;
                if (!old && !pops[i].ToLower().Contains(showCmps.ToLower()))
                {
                    continue;
                }
                if (!first)
                {
                    GUILayout.Space(3);
                    QuickGUI.HLine(Color.gray);
                }
                bool last = GUILayout.Toggle(old, pops[i], "PlayerSettingsLevel");
                if (last)
                {
                    cmpIndex = i;
                }
                if (last ^ old)
                {
                    showCmps = "";
                }
                first = false;
            }
            GUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 12
0
        void OnPropertiesList(Rect r, BehaviourNodeGUI.Decorator decorator, Vector2 tsize, Vector2 dsize)
        {
            BTInputProperty[] properties = decorator.Properties;
            if (properties.Length == 0)
            {
                return;
            }
            Rect h = new Rect();

            h.size     = new Vector2(dsize.x - 6 * GlobalScale, dsize.y);
            h.position = r.position + Vector2.one * 3 * GlobalScale;
            Installizer.contentStyle.alignment = TextAnchor.MiddleLeft;
            Installizer.contentStyle.fontSize  = (int)Mathf.Max(1, BehaviourNodeGUI.SUB_FONT_SIZE * GlobalScale);
            bool dirty = false;

            for (int i = 0; i < properties.Length; i++)
            {
                BTInputProperty prop = properties[i];
                Installizer.contentContent.text = prop.PropertyName;
                GUI.Label(h, Installizer.contentContent, Installizer.contentStyle);
                h.y += dsize.y;//  = new Vector2(r.xMin + x0, r.yMin + i * dsize.y);
                //GUI.Label(h, "", "textfield");// "TL LoopSection");
                QuickGUI.DrawBox(h, Color.clear, Color.gray, 1);
                if (h.Contains(Event.current.mousePosition))
                {
                    mRaycastProperty = prop;
                }
                if (mFocusProperty == prop)
                {
                    string str = GUI.TextField(h, prop.InputData, Installizer.contentStyle);
                    dirty         |= str != prop.InputData;
                    prop.InputData = str;
                }
                else
                {
                    prop.ReguexData();
                    GUI.Label(h, prop.IsDefaultValue ?
                              string.Format("<i><color=#a0a0a0>({0})</color></i> {1} ", prop.TypeName, prop.InputData) : prop.InputData, Installizer.contentStyle);
                }
                h.y += tsize.y;
            }
            if (dirty)
            {
                decorator.UpdatePropertiesInfo();
                mResizeNode = true;
            }
        }
Ejemplo n.º 13
0
        // 附加到对象的装饰节点
        void OnAttachedDecoratorListGUI(ref Rect r, Vector2 tsize, Vector2 dsize, BehaviourNodeGUI node, List <BehaviourNodeGUI.Decorator> decorators)
        {
            Rect btn = new Rect();

            btn.size = Vector2.one * Mathf.Clamp(20 * GlobalScale, 15, 30);
            Rect tmp = new Rect();

            for (int i = 0; i < decorators.Count; i++)
            {
                BehaviourNodeGUI.Decorator decor = decorators[i];
                float h = (tsize.y + dsize.y) * decor.Properties.Length + tsize.y + tsize.y - dsize.y;
                r.height = h;
                bool inter = r.Contains(Event.current.mousePosition);
                //GUI.Label(r, "", inter ? "flow node 0" : "sv_iconselector_back");
                QuickGUI.DrawBox(r, new Color(0.3f, 0.3f, 0.3f), inter ? Color.yellow : Color.black, inter ? 2 : 0);
                Texture icon = decor.BTMeta.Icon;
                if (icon != null)
                {
                    tmp.size     = Vector2.one * tsize.y;
                    tmp.position = new Vector2(r.xMin + 1, r.yMin + 1);
                    GUI.DrawTexture(tmp, icon, ScaleMode.ScaleToFit);
                }
                if (inter)//|| mFocusDecorator == decorators[i])
                {
                    mRaycastDecorator = decor;
                }
                tmp.size     = tsize;
                tmp.position = new Vector2(r.xMin, r.yMin);
                Installizer.contentStyle.alignment = TextAnchor.MiddleCenter;
                Installizer.contentStyle.fontSize  = (int)Mathf.Max(1, 12f * GlobalScale);
                Installizer.contentContent.text    = decor.NotFlag?decor.BTMeta.NotDisplayName: decor.BTMeta.DisplayName;
                GUI.Label(tmp, Installizer.contentContent, Installizer.contentStyle);
                btn.center = new Vector2(tmp.xMax - btn.size.x * 0.5f, tmp.center.y);
                if (tsize.y > 8 && inter && GUI.Button(btn, "", "WinBtnCloseActiveMac"))
                {
                    node.RemoveDecorator(decor.BTMeta);
                    mResizeNode = true;
                    break;
                }
                tmp.size     = dsize;
                tmp.position = new Vector2(r.xMin, r.yMin + tsize.y);
                OnPropertiesList(tmp, decor, tsize, dsize);
                r.position += Vector2.up * h;
            }
            r.height = 0;
        }
Ejemplo n.º 14
0
 public void OnGUI(Rect rect, float scale)
 {
     if (BTMeta != null)
     {
         QuickGUI.DrawBox(rect, new Color(0.3f, 0.3f, 0.3f), Color.yellow, rect.Contains(Event.current.mousePosition) ? 2 : 0);
         Rect r = rect;
         r.size      = Vector2.one * (BehaviourNodeGUI.FONT_SIZE * scale);
         r.position += Vector2.one * (3 * scale);
         Texture icon = BTMeta.Icon;
         if (icon != null)
         {
             GUI.DrawTexture(r, icon, ScaleMode.ScaleToFit);
         }
         r.position = new Vector2(rect.x + r.size.x, rect.y);
         r.width    = rect.width - r.size.x;
         r.height   = TitleSize.y * scale;
         Installizer.contentStyle.fontStyle        = FontStyle.Bold;
         Installizer.contentStyle.normal.textColor = Color.white;
         Installizer.contentStyle.fontSize         = (int)Mathf.Max(1, BehaviourNodeGUI.SUB_FONT_SIZE * scale);
         Installizer.contentStyle.alignment        = TextAnchor.MiddleCenter;
         Installizer.contentContent.text           = BTMeta.DisplayName;
         GUI.Label(r, Installizer.contentContent, Installizer.contentStyle);
         r.y      = rect.y + TitleSize.y * scale;
         r.height = DetailSize.y * scale;
         r.width  = rect.width - 6 * scale;
         r.x      = rect.x + 5 * scale;
         Installizer.contentStyle.fontStyle        = FontStyle.Normal;
         Installizer.contentStyle.normal.textColor = new Color(0.7f, 0.7f, 0.7f);
         Installizer.contentStyle.fontSize         = (int)Mathf.Max(1, BehaviourNodeGUI.SUB_FONT_SIZE * 0.9f * scale);
         Installizer.contentStyle.alignment        = TextAnchor.MiddleLeft;
         Installizer.contentContent.text           = BTMeta.SubTitle;
         GUI.Label(r, Installizer.contentContent, Installizer.contentStyle);
     }
     else
     {
         Color c = BehaviourModuleManager.GetOrNewInstance().GetCategoryColor(Category);
         QuickGUI.DrawBox(rect, Collaped ? c : new Color(c.r * 0.5f, c.g * 0.5f, c.b * 0.5f), Color.yellow, 0);
         Installizer.titleStyle.fontSize  = (int)Mathf.Max(1, BehaviourNodeGUI.SUB_FONT_SIZE * scale);
         Installizer.titleStyle.alignment = TextAnchor.MiddleCenter;
         Installizer.titleContent.text    = Category;
         GUI.Label(rect, Installizer.titleContent, Installizer.titleStyle);
     }
 }
Ejemplo n.º 15
0
        public override void DrawComment(bool raycast)
        {
            if (!mResized)
            {
                return;
            }
            var com = mAsset.m_Comment;

            if (mRuntime != null)
            {
                if (string.IsNullOrEmpty(com))
                {
                    com = StringUtil.Concat("ID: ", mRuntime.Asset.GetInstanceID().ToString("x"));
                }
                else
                {
                    com = StringUtil.Concat("ID: ", mRuntime.Asset.GetInstanceID().ToString("x"), '\n', com);
                }
            }
            if (string.IsNullOrEmpty(com))
            {
                return;
            }
            if (com != mComment)
            {
                mComment     = com;
                mCommentSize = CalculateSubtitleSize(mComment, SUB_SIZE + 2);
            }
            var rect = new Rect();
            var size = mCommentSize * GlobalScale;

            rect.size = size + Vector2.one * 4;
            rect.x    = GlobalRect.x;
            rect.y    = GlobalRect.y - size.y - 8;
            QuickGUI.DrawBox(rect, Color.gray * (raycast ? 0.7f : 0.5f), Color.black, raycast ? 1 : 0);
            rect.size = size;
            rect.x    = GlobalRect.x + 2;
            rect.y    = GlobalRect.y - size.y - 6;
            GUISubtitle(rect, mComment, Color.white * (raycast ? 1f : 0.7f), SUB_SIZE + 2, raycast ? FontStyle.Normal : FontStyle.Italic, TextAnchor.MiddleLeft);
        }
        void DrawActiveOption()
        {
            //GUILayout.BeginHorizontal();
            int act = 0;

            if (mActive)
            {
                act |= 0x1;
            }
            if (mInactive)
            {
                act |= 0x2;
            }
            if (mNigative)
            {
                act |= 0x4;
            }
            act       = QuickGUI.MultiOptionBar(act, new string[] { "Active", "Inactive", "Revert" });
            mActive   = (act & 0x1) != 0;
            mInactive = (act & 0x2) != 0;
            mNigative = (act & 0x4) != 0;
        }
Ejemplo n.º 17
0
        void OnGUI()
        {
            //right
            GUILayout.BeginVertical();
            GUILayout.Space(4);
            int colLimit = (int)Mathf.Min(mTitles.Length, position.width / 200f);

            tab = QuickGUI.HTabBar(tab, 20, colLimit, mTitles);
            GUILayout.Space(3);
            GUILayout.BeginHorizontal("TextArea");
            if (tab >= 0 && tab < mPages.Length)
            {
                mPages[tab].OnGUI();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("STATUS", GUILayout.Width(50));
            mPages[tab].OnStatusGUI();
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
 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 override void OnGUI()
        {
            if (mStyles.Count == 0)
            {
                foreach (GUIStyle style in GUI.skin)
                {
                    mStyles.Add(style);
                }
            }

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            //GUILayout.Label("单击示例将复制其名到剪贴板", "label");
            //GUILayout.FlexibleSpace();
            //GUILayout.Label("查找:");
            search = QuickGUI.SearchTextBar(search);
            GUILayout.EndHorizontal();

            QuickGUI.StepVerticalScroll(ref offIndex, ref offPos, 30, mStyles.Count,
                                        (id, counter) =>
            {
                GUIStyle style = mStyles[id];
                if (style.name.ToLower().Contains(search.ToLower()))
                {
                    GUILayout.BeginHorizontal("GridList");
                    GUILayout.Space(7);
                    if (GUILayout.Button(StringUtil.WrapString(style.name, 5, "."), style, GUILayout.Width(100)))
                    {
                        EditorGUIUtility.systemCopyBuffer = "\"" + style.name + "\"";
                    }
                    GUILayout.Space(10);
                    GUILayout.Toggle(true, "t", style, GUILayout.Width(50));
                    GUILayout.Space(7);
                    GUILayout.Toggle(false, "f", style, GUILayout.Width(50));
                    GUILayout.Space(10);
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.SelectableLabel("\"" + style.name + "\"");
                    GUILayout.EndHorizontal();
                    GUILayout.Space(11);
                    return(true);
                }
                return(false);
            }, "box");

            //scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            //foreach (GUIStyle style in GUI.skin)
            //{
            //    if (style.name.ToLower().Contains(search.ToLower()))
            //    {
            //        GUILayout.BeginHorizontal("GridList");
            //        GUILayout.Space(7);
            //        if (GUILayout.Button(StringUtil.WrapString(style.name, 5, "."), style, GUILayout.Width(100)))
            //        {
            //            EditorGUIUtility.systemCopyBuffer = "\"" + style.name + "\"";
            //        }
            //        GUILayout.Space(10);
            //        GUILayout.Toggle(true, "t", style, GUILayout.Width(50));
            //        GUILayout.Space(7);
            //        GUILayout.Toggle(false, "f", style, GUILayout.Width(50));
            //        GUILayout.Space(10);
            //        GUILayout.FlexibleSpace();
            //        EditorGUILayout.SelectableLabel("\"" + style.name + "\"");
            //        GUILayout.EndHorizontal();
            //        GUILayout.Space(11);
            //    }
            //}
            //GUILayout.EndScrollView();
            GUILayout.EndVertical();
        }
Ejemplo n.º 20
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();
            }
        }
Ejemplo n.º 21
0
 public override void OnInspectorGUI()
 {
     mPos = EditorGUILayout.BeginScrollView(mPos);
     if (mTarget.m_Anims != null)
     {
         for (int i = 0; i < mTarget.m_Anims.Length; i++)
         {
             bool drop = mDropIndex == i;
             EditorGUILayout.BeginVertical(drop ? "flow overlay box" : "box");
             var anim = mTarget.m_Anims[i];
             int ret  = QuickGUI.TitleBarWithBtn(anim.m_Name, 12, 15, "OL Minus", "OL Plus");
             if (ret == 0)
             {
                 mDropIndex = i;
                 GUI.FocusControl(null);
             }
             if (drop)
             {
                 var str = EditorGUILayout.TextField("Name", anim.m_Name ?? "");
                 mDirty     |= str != anim.m_Name;
                 anim.m_Name = str;
                 var dur = Mathf.Max(0.0001f, EditorGUILayout.FloatField("Duration", anim.m_Duration));
                 mDirty         |= dur != anim.m_Duration;
                 anim.m_Duration = dur;
                 OnFrameGUI(anim);
             }
             if (drop)
             {
                 GUILayout.Space(10);
             }
             EditorGUILayout.EndVertical();
             if (ret == 1)
             {
                 RemoveAnim(i);
                 mDirty = true;
                 GUI.FocusControl(null);
                 break;
             }
             else if (ret == 2)
             {
                 InsertAnim(i, anim);
                 mDropIndex = i;
                 mDirty     = true;
                 GUI.FocusControl(null);
                 break;
             }
         }
     }
     EditorGUILayout.BeginVertical("U2D.createRect");
     if (QuickGUI.TitleBar("New Emoji Animation", 13) == 0)
     {
         InsertAnim(mTarget.m_Anims == null ? 0 : mTarget.m_Anims.Length);
         mDropIndex = mTarget.m_Anims.Length - 1;
         mDirty     = true;
         GUI.FocusControl(null);
     }
     if (mDirty)
     {
         mDirty = false;
         EditorUtility.SetDirty(target);
         serializedObject.Update();
     }
     EditorGUILayout.EndVertical();
     EditorGUILayout.EndScrollView();
 }
        public override void OnGUI(Rect clipRect)
        {
            mRaycastProperty = null;
            bool vis = mVisible;

            mVisible = mWindow.IsPlaying && mWindow.Runner != null;
            if (!vis && mVisible)
            {
                mTick = JDateTime.NowMillies;
            }
            if (mVisible)
            {
                //if (JDateTime.NowMillies - mTick > 8000)
                //    mDrop = false;
                Rect rec = LocalRect;
                rec.width    = Mathf.Clamp(Parent.LocalRect.width * 0.35f, 200, 500);
                rec.height   = mDrop ? 180 : 25;
                rec.position = new Vector2(0, Parent.LocalRect.height - LocalRect.height);
                LocalRect    = rec;

                BTBlackboard          blackboard = mWindow.Runner.Blackboard;
                BTBlackboarProperty[] props      = (BTBlackboarProperty[])Ref.GetField(blackboard, "mVariables");
                QuickGUI.DrawBox(GlobalRect, Color.gray * 0.5f, Color.black, 1, true);
                Rect r    = new Rect(GlobalRect.xMin, GlobalRect.yMin, GlobalRect.width, 20);
                bool drop = mDrop;
                mDrop = GUI.Toggle(r, mDrop, "Blackboard", "PreDropDown");
                if (!drop && mDrop)
                {
                    mTick = JDateTime.NowMillies;
                }
                if (mDrop)
                {
                    r.height = GlobalRect.height - 20;
                    r.y      = GlobalRect.yMin + 25;
                    BeginScroll(r, ref mScrollRect);
                    r.position = new Vector2(0, mScrollOffset);
                    r.height   = 20;
                    for (int i = 0; i < props.Length; i++)
                    {
                        r.width    = 100;
                        r.position = new Vector2(0, i * 20 + mScrollOffset);
                        GUI.Label(r, props[i].Name);
                        r.width = GlobalRect.width - 100;
                        r.x     = 100;
                        if (props[i].IsSet)
                        {
                            GUI.Label(r, props[i].Value == null ? "[NULL]" : props[i].Value.ToString(), "AssetLabel");
                        }
                        else
                        {
                            GUI.Label(r, "[NOT SET]");
                        }
                        if (r.Contains(Event.current.mousePosition))
                        {
                            mRaycastProperty = props[i];
                        }
                    }
                    EndScroll(r.yMax, ref mScrollRect, ref mScrollOffset);
                }
            }
        }
Ejemplo n.º 23
0
        protected virtual void OnNodeGUI()
        {
            Rect  r        = new Rect();
            float w        = (LocalRect.width - 10) * GlobalScale;
            float y0       = GlobalRect.yMin + 15 * GlobalScale;
            float x0       = GlobalRect.center.x - w * 0.5f;
            bool  editmode = !mWindow.ContextMenu.Visible && mWindow.EditMode == BehaviourTreeDesignerWindow.ENodeEditMode.none;

            // conditions
            r.size     = new Vector2(w, 1);
            r.position = new Vector2(x0, y0);
            OnDecoratorListGUI(conditions, ref r);
            //self
            r.position = new Vector2(x0, r.yMax);
            r.size     = new Vector2(w, (Self.SubTextHeight + Self.TextHeight) * GlobalScale);
            QuickGUI.DrawBox(r, Self.BTMeta.color, Color.black, 1);
            Texture2D icon = Self.BTMeta.Icon;

            if (icon != null)
            {
                Rect tmp = new Rect();
                tmp.size     = Vector2.one * ICON_SIZE * GlobalScale;
                tmp.position = r.position + Vector2.one;
                GUI.DrawTexture(tmp, icon, ScaleMode.ScaleToFit);
            }
            //if (bg != null)
            //    GUI.DrawTexture(r, bg, ScaleMode.StretchToFill, true, 0, Color.blue, 5, 5);
            //else
            //    GUI.Label(r, "", Self.BTMeta.FrameStyle);
            float dx = 5 * GlobalScale;
            Rect  r2 = new Rect(x0 + dx + ICON_SIZE * GlobalScale, r.yMin, w - dx, Self.TextHeight * GlobalScale);

            Installizer.titleStyle.fontSize         = (int)Mathf.Max(1, FONT_SIZE * GlobalScale);
            Installizer.titleStyle.normal.textColor = Color.white;
            Installizer.titleStyle.alignment        = TextAnchor.MiddleLeft;
            Installizer.titleContent.text           = Self.BTMeta.DisplayName;
            GUI.Label(r2, Installizer.titleContent, Installizer.titleStyle);
            if (!string.IsNullOrEmpty(Self.PropertiesInfo))
            {
                r2.position = new Vector2(x0 + dx, r2.yMax);
                r2.size     = new Vector2(w - dx, Self.SubTextHeight * GlobalScale);
                Installizer.contentContent.text    = Self.PropertiesInfo;
                Installizer.contentStyle.alignment = TextAnchor.MiddleLeft;
                Installizer.contentStyle.fontSize  = (int)Mathf.Max(1, SUB_FONT_SIZE * GlobalScale * 0.95f);
                GUI.Label(r2, Installizer.contentContent, Installizer.contentStyle);
            }
            if (mWindow.IsPlaying && Self.BTRuntimeState == EBTTaskState.running && RuntimeNode.ChildLength == 0)
            {
                Rect  tmp = r;
                float x   = Mathf.PingPong(mWindow.Runner.TaskTime * 0.5f, 2f);
                tmp.xMax = Mathf.Lerp(r.xMin, r.xMax, Mathf.Clamp01(x));
                tmp.xMin = Mathf.Lerp(r.xMin, r.xMax, Mathf.Clamp01(x - 1));
                //GUI.Label(tmp, "", "U2D.createRect");
                QuickGUI.DrawBox(tmp, Color.blue * 0.3f, Color.blue, 1, true);
            }

            // services
            OnDecoratorListGUI(services, ref r);
            r.size     = new Vector2(100, 20);
            r.position = new Vector2(GlobalRect.xMin, GlobalRect.yMin - 20);
            if (mWindow.IsPlaying && RuntimeNode != null)
            {
                GUI.Label(r, string.Format("<color={0}>#{1}</color>", BTExecutionOrder > 0 ? "#10ff10" : "red",
                                           BTExecutionOrder > 0 ? BTExecutionOrder.ToString() : "-"));
            }
            else
            {
                GUI.Label(r, string.Format("<color={0}>#{1}</color>", BTExecutionOrder > 0 ? "#10ff10" : "red",
                                           BTExecutionOrder > 0 ? BTExecutionOrder.ToString() : "-"));
            }
            if (!string.IsNullOrEmpty(mError))
            {
                r.size     = new Vector2(200, 50);
                r.position = new Vector2(GlobalRect.xMin, GlobalRect.yMax);
                GUI.Label(r, string.Format("<size=13><b><color=red>{0}</color></b></size>", mError));
            }
        }
        bool DrawResultItem(int index, int counter)
        {
            if (index >= showResults.Count)
            {
                return(false);
            }
            SearchResult sr = showResults[index];

            if (!sr.gameObj)
            {
                return(false);
            }
            if (counter > 0)
            {
                GUILayout.Space(5);
                QuickGUI.HLine(Color.gray);
            }
            GameObject go = sr.gameObj;

            bool oldFout = foutIndex == index;// EditorPrefs.GetBool("go" + index);

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            string goName = go.name;

            GUILayout.BeginHorizontal();
            bool act = GUILayout.Toggle(go.activeSelf, "", GUILayout.Width(15));

            if (act ^ go.activeSelf)
            {
                go.SetActive(act);
            }
            bool fout = GUILayout.Toggle(oldFout, goName, "PlayerSettingsLevel");
            bool ding = GUILayout.Toggle(go == mDingObject, "\u2764", "SearchModeFilter", GUILayout.MaxWidth(20));

            if (ding)
            {
                mDingObject = go;
                mDing       = true;
            }
            GUILayout.EndHorizontal();
            if (fout ^ oldFout)
            {
                //EditorGUIUtility.PingObject(go);
                if (fout)
                {
                    PopupResult(index);
                }
            }
            if (fout)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(3);
                DrawResultItem(sr, !oldFout);
                GUILayout.Space(3);
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            return(true);
        }
        void DrawDingObject()
        {
            if (!mDingObject || !mDing)
            {
                mDingObject = Selection.activeGameObject;
            }
            if (!mDingObject)
            {
                EditorGUILayout.BeginVertical("flow overlay box", GUILayout.Width(350));
                GUILayout.Label("<size=25><b>NOTHINE SELECTED.</b></size>");
                EditorGUILayout.EndVertical();
                return;
            }
            EditorGUILayout.BeginVertical("flow overlay box", GUILayout.Width(350));
            string t = mDingObject.name;
            int    s = QuickGUI.TitleBar(t, 15,
                                         new string[] { mDing ? "<25>true:\u2764" : "<25>\u2764", mDingObject.activeSelf ? "<25>true:\u2714" : "<25>\u2714" });

            if (s == 1)
            {
                mDing = !mDing;
                if (!mDing && Selection.activeGameObject)
                {
                    mDingObject = Selection.activeGameObject;
                }
            }
            else if (s == 2)
            {
                mDingObject.gameObject.SetActive(!mDingObject.activeSelf);
            }
            if (s >= 0)
            {
                EditorGUIUtility.PingObject(mDingObject);
            }
            dingScroll = EditorGUILayout.BeginScrollView(dingScroll);
            Component[] cps = mDingObject.GetComponents <Component>();

            for (int i = 0; i < cps.Length; i++)
            {
                if (!cps[i] || cps[i] is Transform)
                {
                    continue;
                }
                //System.Type ctp = cps[i].GetType();
                int  id = cps[i].GetInstanceID();
                bool v  = popDingCmps.Contains(id);
                bool v2 = EditorGUILayout.InspectorTitlebar(v, cps[i]);
                if (v2 ^ v)
                {
                    if (!v2)
                    {
                        popDingCmps.Remove(id);
                        popDingEditors.Remove(id);
                    }
                    else
                    {
                        popDingCmps.Add(id);
                    }
                }
                if (v2)
                {
                    UnityEditor.Editor edi;// sr.GetValue<Editor>(cmps[i].GetType().Name);
                    if (!popDingEditors.TryGetValue(id, out edi) || !edi)
                    {
                        edi = UnityEditor.Editor.CreateEditor(cps[i]);
                        popDingEditors[id] = edi;
                    }
                    if (edi)
                    {
                        edi.OnInspectorGUI();
                    }
                }
            }
            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 26
0
        void OnContextDecoratorGUI()
        {
            mRaycastProperty  = null;
            mRaycastDecorator = null;
            float l = Mathf.Max(mMinTaskWidth, mMinDecoratorWidth);
            float w = l + mMinDecoratorWidth;

            if (w > LocalRect.width)
            {
                Rect rect = new Rect();
                rect.size     = new Vector2(w, LocalRect.height);
                rect.position = new Vector2(LocalRect.center.x - w * 0.5f, LocalRect.yMin);
                LocalRect     = rect;
            }
            Vector2 dsize = new Vector2(l * GlobalScale - 2, BehaviourNodeGUI.SUB_FONT_SIZE * GlobalScale);

            dsize.y += 5 * GlobalScale;
            Vector2 tsize = new Vector2(dsize.x, dsize.y * 1.3f);

            BehaviourNodeGUI node  = Context as BehaviourNodeGUI;
            TextAnchor       align = Installizer.contentStyle.alignment;

            Rect r = new Rect();

            r.size     = new Vector2(tsize.x, GlobalRect.height);
            r.position = GlobalRect.position;
            BeginScroll(r, ref mScrollRectL);

            //
            r.size     = tsize;
            r.position = new Vector2(0, mScrollOffsetL);
            BTInputProperty[] properties;
            // conditions
            OnAttachedDecoratorListGUI(ref r, tsize, dsize, node, node.conditions);
            // self
            properties = node.Self.Properties;
            r.size     = new Vector2(tsize.x, tsize.y + properties.Length * (tsize.y + dsize.y) + tsize.y);
            QuickGUI.DrawBox(r, node.Self.BTMeta.color, Color.black);
            if (r.Contains(Event.current.mousePosition))
            {
                mRaycastDecorator = node.Self;
            }
            Rect    tmp  = new Rect();
            Texture icon = node.Self.BTMeta.Icon;

            if (icon != null)
            {
                tmp.size     = Vector2.one * tsize.y;
                tmp.position = new Vector2(r.xMin + 1, r.yMin + 1);
                GUI.DrawTexture(tmp, icon, ScaleMode.ScaleToFit);
            }
            tmp.size     = tsize;
            tmp.position = new Vector2(r.xMin, r.yMin);
            Installizer.titleStyle.alignment = TextAnchor.MiddleCenter;
            Installizer.titleStyle.fontSize  = (int)Mathf.Max(1, BehaviourNodeGUI.FONT_SIZE * GlobalScale);
            Installizer.titleContent.text    = string.Format("<b>{0}</b>", node.Self.BTMeta.DisplayName);
            GUI.Label(tmp, Installizer.titleContent, Installizer.titleStyle);
            tmp.y += tsize.y + 4 * GlobalScale;
            OnPropertiesList(tmp, node.Self, tsize, dsize);
            r.y = r.yMax;
            //services
            OnAttachedDecoratorListGUI(ref r, tsize, dsize, node, node.services);

            EndScroll(r.yMax, ref mScrollRectL, ref mScrollOffsetL);

            Handles.color = Color.gray;
            Handles.DrawLine(new Vector3(GlobalRect.xMin + tsize.x, GlobalRect.yMin),
                             new Vector3(GlobalRect.xMin + tsize.x, GlobalRect.yMax));
            Installizer.contentStyle.alignment = align;
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            GUILayout.Space(10);
            for (int i = 0; i < m_PostEffects.arraySize; i++)
            {
                var eff = m_PostEffects.GetArrayElementAtIndex(i);
                if (eff.objectReferenceValue == null)
                {
                    if (i == dropIndex)
                    {
                        dropIndex = -1;
                    }
                    m_PostEffects.DeleteArrayElementAtIndex(i);
                    break;
                }
                drop = dropIndex == i;
                EditorGUILayout.BeginVertical(drop ? "flow overlay box" : "box");
                int  ret  = QuickGUI.TitleBarWithBtn(eff.objectReferenceValue.name, 12, 15, "OL Minus", "OL Plus");
                bool over = false;
                if (ret == 0)
                {
                    dropIndex = i;
                    if (eff.objectReferenceValue != null)
                    {
                        EditorGUIUtility.PingObject(eff.objectReferenceValue);
                    }
                }
                else if (ret == 1)
                {
                    m_PostEffects.DeleteArrayElementAtIndex(i);
                    over = true;
                }
                else if (drop)
                {
                    var editor = GetEditor(eff.objectReferenceValue);
                    if (editor != null)
                    {
                        editor.OnInspectorGUI();
                    }
                }
                EditorGUILayout.EndVertical();
                if (over)
                {
                    break;
                }
            }
            GUILayout.Space(5);
            var rect = EditorGUILayout.BeginHorizontal();

            newAsset = EditorGUILayout.ObjectField("New Effect", newAsset, typeof(CameraPostProcessingAsset), false) as CameraPostProcessingAsset;
            bool newpop = false;

            if (GUILayout.Button("Add", GUILayout.Width(40)))
            {
                if (newAsset == null)
                {
                    rect.x = rect.xMax;
                    newpop = true;
                }
                else
                {
                    var index = m_PostEffects.arraySize;
                    dropIndex = index;
                    m_PostEffects.InsertArrayElementAtIndex(index);
                    m_PostEffects.GetArrayElementAtIndex(index).objectReferenceValue = newAsset;
                    newAsset = null;
                }
            }
            EditorGUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();
            if (newpop)
            {
                EditorUtility.DisplayCustomMenu(rect, mAssetNames, -1, OnAddEffectSelected, null);
            }
        }
Ejemplo n.º 28
0
        protected override void OnContentLayer(Rect rect)
        {
            if (mNode == null || mNode.Asset == null)
            {
                editor.AIGraph.RemoveElement(this);
                return;
            }
            if (editor.Binder.IsRunning())
            {
                var runtime = editor.Binder.runtime;
                mRuntime = runtime == null ? null : runtime.GetNodeById(mNode.Identify);
            }
            else
            {
                mRuntime = null;
            }
            mContext = mNode;
            var space  = SPACE * GlobalScale;
            var icon   = ICON_SIZE * GlobalScale;
            var decorh = mDecorHeight * GlobalScale;
            var tsize  = mTitleSize * GlobalScale;
            var dsize  = mDetailSize * GlobalScale;
            var pos    = rect;

            QuickGUI.DrawBox(rect, color, selected ? SELECTED_COLOR : BOARDER_COLOR, selected ? 2 : 1, true);
            if (mRuntime != null && mRuntime.isTask)
            {
                pos.width *= Mathf.PingPong(((BTTaskAsset)mRuntime.Asset).EditorDebugTime * 0.5f, 1f);
                pos.height = tsize.y;
                pos.y      = rect.y + decorh * mConditionNames.Count;
                GUI.Label(pos, DevilEditorUtility.EmptyContent, "MeLivePlayBar");
            }
            bool  raycast;
            float h = rect.y;

            for (int i = 0; i < mConditionNames.Count; i++)
            {
                pos.position = new Vector2(rect.x, h + i * decorh);
                pos.size     = new Vector2(rect.width, decorh);
                raycast      = pos.Contains(editor.GlobalMousePosition);
                if (raycast)
                {
                    mContext = editor.TargetTree.GetNodeById(mAsset.GetConditionId(i));
                }
                QuickGUI.DrawBox(pos, raycast ? SELECTED_COLOR : mConditionMods[i].color, SELECTED_COLOR, 0);

                pos.size = Vector2.one * decorh * 0.9f;
                GUI.DrawTexture(pos, mConditionMods[i].icon);
                pos.x += decorh;
                GUISubtitle(pos, mConditionNames[i], raycast ? Color.black : SUBTITLE_COLOR, FontStyle.Normal, TextAnchor.MiddleLeft);
                if (mConditionNames[i] != GetConditionName(mConditionNodes[i], mConditionMods[i]))
                {
                    Resize();
                }
            }

            pos           = new Rect(rect.x, rect.y + decorh * mConditionNames.Count, rect.width, tsize.y + dsize.y + space.y * 2);
            pos.size      = icon;
            pos.position += space;
            GUI.DrawTexture(pos, mMod.icon);
            pos.size      = tsize;
            pos.position += Vector2.right * (icon.x + space.x * 0.5f);
            GUITitle(pos, title, FontStyle.Bold, TextAnchor.UpperLeft);
            if (!string.IsNullOrEmpty(mDetail))
            {
                pos.size     = dsize;
                pos.position = new Vector2(rect.x + space.x, pos.y + tsize.y + 0.5f * space.y);
                GUISubtitle(pos, mDetail, FontStyle.Normal, TextAnchor.MiddleLeft);
            }
            var del = GetDetail();

            if (del != mDetail)
            {
                mDetail = del;
                Resize();
            }
            if (mRuntime != null)
            {
                DebugRuntimeState(rect);
            }
            if (BreakToggle)
            {
                pos.size   = Vector2.one * 15;
                pos.center = new Vector2(rect.xMax, rect.yMin);
                GUI.Label(pos, DevilEditorUtility.EmptyContent, "Icon.AutoKey");
            }
        }
        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();
            }
        }
Ejemplo n.º 30
0
        void OnDecoratorListGUI(List <Decorator> decors, ref Rect rect)
        {
            int   size0 = (int)Mathf.Max(1, SUB_FONT_SIZE * GlobalScale);
            int   size1 = (int)Mathf.Max(1, size0 * 0.95f);
            float h0;
            float h1;
            Rect  r  = new Rect();
            float x0 = rect.xMin;
            float x  = 5 * GlobalScale;

            r.size     = new Vector2(rect.width - x * 2, rect.height);
            r.position = new Vector2(x + x0, rect.yMax);
            Rect btn = new Rect();

            btn.size = Vector2.one * Mathf.Clamp(20 * GlobalScale, 15, 30);
            for (int i = 0; i < decors.Count; i++)
            {
                h0            = decors[i].TextHeight * GlobalScale;
                h1            = decors[i].SubTextHeight * GlobalScale;
                rect.height   = h0 + h1;
                rect.position = new Vector2(x0, r.yMin);
                if (rect.Contains(Event.current.mousePosition))
                {
                    mRaycastDecorator = decors[i];
                }
                bool sel = mWindow.EditMode == BehaviourTreeDesignerWindow.ENodeEditMode.none && !mWindow.ContextMenu.Visible && decors[i] == mRaycastDecorator && rect.height >= btn.height;
                QuickGUI.DrawBox(rect, new Color(0.3f, 0.3f, 0.3f), sel ? Color.yellow : Color.black, sel ? 3 : 0);
                //GUI.Label(rect, "", sel ? "flow node 0 on" : "flow node 0");
                if (decors[i].BTMeta.Icon != null)
                {
                    Rect tmp = new Rect(rect.x + 1, rect.y + 1, h0, h0);
                    GUI.DrawTexture(tmp, decors[i].BTMeta.Icon, ScaleMode.ScaleToFit);
                }
                EBTTaskState stat = mWindow.IsPlaying ? decors[i].BTRuntimeState : EBTTaskState.inactive;
                if (stat == EBTTaskState.success)
                {
                    QuickGUI.DrawBox(rect, Color.clear, Color.green, 2);
                }
                else if (stat == EBTTaskState.faild)
                {
                    QuickGUI.DrawBox(rect, Color.clear, Color.red, 2);
                }
                r.height = h0;
                Installizer.contentStyle.alignment        = TextAnchor.MiddleCenter;
                Installizer.contentStyle.fontSize         = size0;
                Installizer.contentStyle.normal.textColor = Color.white;
                Installizer.contentContent.text           = decors[i].NotFlag ? decors[i].BTMeta.NotDisplayName : decors[i].BTMeta.DisplayName;
                //Installizer.contentContent.text = string.Format("<color=white>{0}</color>", decors[i].BTMeta.DisplayName);
                GUI.Label(r, Installizer.contentContent, Installizer.contentStyle);
                r.position += Vector2.up * h0;
                if (!string.IsNullOrEmpty(decors[i].PropertiesInfo))
                {
                    Installizer.contentStyle.alignment = TextAnchor.MiddleLeft;
                    r.height = h1;
                    Installizer.contentStyle.fontSize         = size1;
                    Installizer.contentStyle.normal.textColor = new Color(0.7f, 0.7f, 0.7f);
                    Installizer.contentContent.text           = decors[i].PropertiesInfo;
                    GUI.Label(r, Installizer.contentContent, Installizer.contentStyle);
                    r.position += Vector2.up * h1;
                }
                if (!mWindow.IsPlaying && sel)
                {
                    btn.position = new Vector2(rect.xMax - btn.width, rect.yMin);
                    if (GUI.Button(btn, "", "WinBtnCloseActiveMac"))
                    {
                        RemoveDecorator(decors[i].BTMeta);
                        Resize();
                        break;
                    }
                }
                if (stat == EBTTaskState.running)
                {
                    Rect  process = rect;
                    float dx      = Mathf.PingPong((mWindow.Runner.BehaviourTime - decors[i].TimeOffset) * 0.3f, 2f);
                    process.xMax = Mathf.Lerp(rect.xMin, rect.xMax, Mathf.Clamp01(dx));
                    process.xMin = Mathf.Lerp(rect.xMin, rect.xMax, Mathf.Clamp01(dx - 1));
                    //GUI.Label(process, "", "U2D.createRect");
                    QuickGUI.DrawBox(process, Color.blue * 0.3f, Color.blue, 1, true);
                    //U2D.createRect
                }
            }
        }