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);
        }
Пример #2
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);
        }
Пример #3
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 OnContentLayer(Rect rect)
 {
     QuickGUI.DrawBox(rect, color, selected ? SELECTED_COLOR : BOARDER_COLOR, selected ? 2 : 1, true);
     if (!string.IsNullOrEmpty(title))
     {
         GUITitle(rect, title);
     }
 }
Пример #5
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);
            }
        }
Пример #6
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();
                }
            }
        }
Пример #7
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;
            }
        }
Пример #8
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;
        }
Пример #9
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);
     }
 }
Пример #10
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);
        }
        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);
                }
            }
        }
Пример #12
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");
            }
        }
Пример #13
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));
            }
        }
Пример #14
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
                }
            }
        }
Пример #15
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;
        }