Ejemplo n.º 1
0
        public string DrawSearchList()
        {
            List <string> targetList = new List <string>();

            if (mSubWinType == SubWinType.CreateNode)
            {
                targetList = GraphDesigner.GetCanCreateList();
            }
            else if (mSubWinType == SubWinType.ReplaceNode)
            {
                targetList = GraphDesigner.GetCanRepalceList();
            }

            List <string> nodeNameList = Filter(targetList, mSearchNode);

            GUILayout.BeginHorizontal();
            GUI.SetNextControlName("Search");
            this.mSearchNode = GUILayout.TextField(this.mSearchNode, GUI.skin.FindStyle("ToolbarSeachTextField"));
            GUI.FocusControl("Search");
            GUILayout.EndHorizontal();
            //
            toolbarRect = new Rect(0f, 15f + 20, mWidth, 25f);
            GUILayout.BeginArea(toolbarRect, EditorStyles.toolbar);
            GUILayout.BeginHorizontal();

            GUILayout.Label("Filter");
            Array         strArr  = Enum.GetValues(typeof(NodeClassifyType));
            List <string> strList = new List <string>();

            strList.Add("All");
            foreach (object str in strArr)
            {
                strList.Add(str.ToString());
            }
            mEnumNodeTypeArr       = strList.ToArray();
            mEnumNodeTypeSelection = EditorGUILayout.Popup(mEnumNodeTypeSelection, mEnumNodeTypeArr);
            if (GUILayout.Button("Clear"))
            {
                ClearNodes();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            //

            GUILayout.BeginArea(new Rect(0, 0, windowRect.width, windowRect.height));
            float topSpace = 60;

            this.mTreeScrollPos = GUI.BeginScrollView(new Rect(0f, topSpace, windowRect.width, windowRect.height - topSpace), this.mTreeScrollPos,
                                                      new Rect(0f, 0f, windowRect.width - 20f, nodeNameList.Count * 19), false, true);

            foreach (string name in nodeNameList)
            {
                NodeMeta proto = BTEntity.Instance.GetNodeMeta(name);
                if (GUILayout.Button(name + $"({proto.describe})", GetButtonStyle()))
                {
                    if (SubWinType.CreateNode == mSubWinType)
                    {
                        GraphDesigner.onCreateNode(name, Vector2.zero);
                    }
                    else if (SubWinType.ReplaceNode == mSubWinType)
                    {
                        GraphDesigner.onChangeNodeType(name, Vector2.zero);
                    }
                    BTEditorWindow.Instance.CloseSubWin();
                }
            }

            GUI.EndScrollView();
            GUILayout.EndArea();

            return("");
        }
Ejemplo n.º 2
0
 public void onChangeNodeType(string name, Vector2 pos)
 {
     mGraphDesigner.onChangeNodeType(name, pos);
 }