Exemple #1
0
        public void ShowContext(BehaviourNodeGUI context)
        {
            if (EditorApplication.isPlaying || context == null)
            {
                return;
            }
            List <BehaviourMeta> lst;

            if (mDecoratorList.Count < 2 || !BehaviourModuleManager.GetOrNewInstance().Decorators.Contains(mDecoratorList[1].BTMeta))
            {
                mMinDecoratorWidth = 200;
                mDecoratorList.Clear();
                lst = BehaviourModuleManager.GetOrNewInstance().Decorators;
                string category = null;
                for (int i = 0; i < lst.Count; i++)
                {
                    MetaUI m = new MetaUI(lst[i]);
                    if (m.BTMeta.Category != category)
                    {
                        category      = m.BTMeta.Category;
                        mDropDownMeta = new MetaUI(category);
                        mDecoratorList.Add(mDropDownMeta);
                    }
                    mDecoratorList.Add(m);
                    mMinDecoratorWidth = Mathf.Max(mMinDecoratorWidth, m.Width);
                }
            }

            Mode    = EMode.alter_node;
            Visible = true;
            Context = context;
            Rect rect = new Rect();

            rect.size = new Vector2(mMinDecoratorWidth + mMinTaskWidth, 270);
            Vector2 gsize = rect.size * GlobalScale;
            Vector2 delta = Vector2.zero;

            if (mWindow.GlobalMousePosition.y + gsize.y > mWindow.RootCanvas.GlobalRect.height)
            {
                delta.y = -rect.size.y;
            }
            if (mWindow.GlobalMousePosition.x + gsize.x > mWindow.RootCanvas.GlobalRect.width)
            {
                delta.x = -rect.size.x;
            }
            rect.position = Parent.CalculateLocalPosition(mWindow.GlobalMousePosition) + delta;
            LocalRect     = rect;
            mWindow.SelectNodes((x) => x == context);
            mDragEnd = true;
        }
Exemple #2
0
 public void Hide()
 {
     if (mFocusProperty != null && mFocusProperty.ReguexData() && mFocusDecorator != null)
     {
         mFocusDecorator.UpdatePropertiesInfo();
     }
     Visible           = false;
     Context           = null;
     Mode              = EMode.none;
     mRaycastProperty  = null;
     mFocusProperty    = null;
     mFocusDecorator   = null;
     mRaycastDecorator = null;
     mDropDownMeta     = null;
     mSearchContext    = "";
 }
Exemple #3
0
        void OnDecoratorsListGUI()
        {
            mRaycastMeta = null;
            Vector2          tsize = new Vector2(mMinDecoratorWidth * GlobalScale, 30 * GlobalScale);
            Vector2          dsize = new Vector2(mMinDecoratorWidth * GlobalScale, 20 * GlobalScale);
            BehaviourNodeGUI node  = Context as BehaviourNodeGUI;
            Rect             r     = new Rect();
            float            delta = 0;

            r.size     = new Vector2(tsize.x, 22);
            r.position = new Vector2(GlobalRect.xMax - tsize.x, GlobalRect.yMin + 2);
            if (OnSearchFieldGUI(r))
            {
                delta += 22;
            }
            bool search = !string.IsNullOrEmpty(mSearchContext);

            r.size     = new Vector2(tsize.x, GlobalRect.height - delta);
            r.position = new Vector2(GlobalRect.xMax - tsize.x, GlobalRect.yMin + 20);
            OnMetaList(mDecoratorList, r, search, true);
        }
Exemple #4
0
        void OnTaskList()
        {
            mRaycastMeta = null;
            Installizer.contentStyle.alignment = TextAnchor.MiddleCenter;
            Vector2      tsize = new Vector2(mMinTaskWidth * GlobalScale, 30 * GlobalScale);
            Vector2      dsize = new Vector2(mMinTaskWidth * GlobalScale, 20 * GlobalScale);
            PaintElement node  = Context;
            Rect         r     = new Rect();
            float        delta = 0;

            r.size     = new Vector2(tsize.x, 22);
            r.position = new Vector2(GlobalRect.xMax - tsize.x, GlobalRect.yMin + 2);
            if (OnSearchFieldGUI(r))
            {
                delta += 22;
            }
            bool search = !string.IsNullOrEmpty(mSearchContext);

            r.size     = new Vector2(tsize.x, GlobalRect.height - delta);
            r.position = new Vector2(GlobalRect.xMax - tsize.x, GlobalRect.yMin + 20);

            OnMetaList(mTaskList, r, search, false);
        }
Exemple #5
0
        public void NewNode(PaintElement context)
        {
            if (EditorApplication.isPlaying)
            {
                return;
            }
            if (mTaskList.Count < 2 || !BehaviourModuleManager.GetOrNewInstance().Composites.Contains(mTaskList[1].BTMeta))
            {
                mTaskList.Clear();
                mMinTaskWidth = 200;
                List <BehaviourMeta> lst;
                lst = BehaviourModuleManager.GetOrNewInstance().Composites;
                string category = null;
                for (int i = 0; i < lst.Count; i++)
                {
                    MetaUI m = new MetaUI(lst[i]);
                    if (m.BTMeta.Category != category)
                    {
                        category      = m.BTMeta.Category;
                        mDropDownMeta = new MetaUI(category);
                        mTaskList.Add(mDropDownMeta);
                    }
                    mTaskList.Add(m);
                    mMinTaskWidth = Mathf.Max(mMinTaskWidth, m.Width);
                }
            }

            Mode    = EMode.new_node;
            Visible = true;
            Context = context;
            Rect rect = new Rect();

            rect.size     = new Vector2(mMinTaskWidth, 270); // 170 + 200
            rect.position = Parent.CalculateLocalPosition(mWindow.GlobalMousePosition) - new Vector2(mMinTaskWidth * 0.5f, 0);
            LocalRect     = rect;
            mDragEnd      = true;
        }
Exemple #6
0
        void OnMetaList(List <MetaUI> metas, Rect r, bool search, bool skipExist)
        {
            Vector2 dsize = new Vector2(r.width, BehaviourNodeGUI.SUB_FONT_SIZE * GlobalScale);

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

            BeginScroll(r, ref mScrollRect);

            Installizer.contentStyle.fontSize = (int)Mathf.Max(1, BehaviourNodeGUI.SUB_FONT_SIZE * GlobalScale);
            r.size     = tsize;
            r.position = new Vector2(0, mScrollOffset);

            // controllers
            r.size = dsize;
            int len = metas.Count;

            Installizer.contentStyle.alignment = TextAnchor.MiddleCenter;
            BehaviourNodeGUI context = Context as BehaviourNodeGUI;
            Color            color   = Color.gray;
            bool             collape = false;

            for (int i = 0; i < len; i++)
            {
                MetaUI meta = metas[i];
                if (!meta.IsTitle)
                {
                    if (collape && !search)
                    {
                        continue;
                    }
                    if (search && !meta.BTMeta.SearchName.Contains(mSearchContext))
                    {
                        continue;
                    }
                    if (skipExist && context != null && context.ContainsDecorator(meta.BTMeta))
                    {
                        continue;
                    }
                }
                else
                {
                    collape = meta.Collaped;// != mDropDownMeta;
                }
                r.height = meta.Height * GlobalScale;
                if (r.yMax >= 0 && r.yMin < GlobalRect.height)
                {
                    bool inter = r.Contains(Event.current.mousePosition);
                    if (inter)
                    {
                        //GUI.Label(r, "", "flow node 0");// "Icon.ClipSelected");
                        mRaycastMeta = meta;//SelectionRect
                    }
                    meta.OnGUI(r, GlobalScale);
                    //QuickGUI.DrawBox(r, new Color(0.3f, 0.3f, 0.3f), Color.yellow, inter ? 2 : 0);
                    //Installizer.contentContent.text = meta.DisplayName;
                    //GUI.Label(r, Installizer.contentContent, Installizer.contentStyle);
                }
                r.y += meta.Height * GlobalScale;
            }

            EndScroll(r.yMax, ref mScrollRect, ref mScrollOffset);
        }