Exemplo n.º 1
0
        public void DrawGUI()
        {
            BTUndo.CheckUndo(this, "NodeBlackboard Inspector");
            GUIStyle titleStyle = new GUIStyle("label");

            titleStyle.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label("Tree Blackboard", titleStyle);
            GUI.backgroundColor = new Color(0.8f, 0.8f, 1);
            if (GUILayout.Button("AddData", GUILayout.ExpandWidth(true), GUILayout.Height(30)))
            {
                var menu = new UnityEditor.GenericMenu();
                menu.AddItem(new GUIContent("bool"), false, ContextNew, false);
                menu.AddItem(new GUIContent("float"), false, ContextNew, 0.2f);
                menu.AddItem(new GUIContent("int"), false, ContextNew, 1);
                menu.AddItem(new GUIContent("string"), false, ContextNew, "some string");
                menu.AddItem(new GUIContent("Vector2"), false, ContextNew, Vector2.zero);
                menu.AddItem(new GUIContent("Vector3"), false, ContextNew, Vector3.zero);
                menu.AddItem(new GUIContent("Color"), false, ContextNew, Color.white);
                menu.AddItem(new GUIContent("GameObject"), false, ContextNew, mRootObj);
                menu.AddItem(new GUIContent("List<GameObject>"), false, ContextNew, new List <GameObject>());
                menu.AddItem(new GUIContent("Component"), false, ContextNew, mRootObj.transform);
                menu.AddItem(new GUIContent("Transform"), false, ContextNew, mRootObj.transform);
                menu.ShowAsContext();
            }
            GUILayout.BeginHorizontal();
            GUI.backgroundColor = Color.yellow;
            GUILayout.Label("Key", GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true));
            GUILayout.Label("Value", GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true));
            GUI.backgroundColor = Color.white;
            GUILayout.EndHorizontal();

            for (int i = 0; i < Data.Count; i++)
            {
                FValue v = Data[i];
                if (v != null)
                {
                    GUILayout.BeginHorizontal();
                    v.DrawGUI();
                    GUI.backgroundColor = new Color(1f, 0.6f, 0.6f);
                    if (GUILayout.Button("X", GUILayout.MaxWidth(20)))
                    {
                        DelData(v.GetKey());
                    }
                    GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f);
                    GUILayout.EndHorizontal();
                }
            }

            GUI.backgroundColor = new Color(0.8f, 0.8f, 1);
            if (GUILayout.Button("ClearNullData", GUILayout.ExpandWidth(true), GUILayout.Height(30)))
            {
                ClearNullData();
            }
        }
Exemplo n.º 2
0
 public void DrawGUI()
 {
     if (Tree == null)
     {
         Tree = GetComponentInParent <NodeTree>();
     }
     if (Tree.First == this)
     {
         GUI.Box(new Rect(NodeRect.x, NodeRect.y - 20, NodeRect.width, 20), "<b>START</b>");
     }
     DrawNodeWindow();
     DrawNodeComments();
     DrawNodeConnections();
     BTUndo.CheckDirty(this);
 }
Exemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            if (IsPrefab())
            {
                return;
            }
            if (Tree.IsRunning)
            {
                return;
            }
            BTUndo.CheckUndo(this, "NodeTree Inspector");
            Tree.ID   = EditorGUILayout.IntField("Tree ID", Tree.ID);
            Tree.Name = EditorGUILayout.TextField("Tree Name", Tree.Name);
            Tree.Loop = EditorGUILayout.Toggle("Tree Loop", Tree.Loop);
            EditorGUILayout.LabelField("Tree Desc");
            Tree.Desc = EditorGUILayout.TextArea(Tree.Desc, GUILayout.Height(50));


            GUI.backgroundColor = new Color(0.8f, 0.8f, 1);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Open Editor", GUILayout.Width(100), GUILayout.Height(30)))
            {
                BTTreeWindow.OpenWindow(Tree);
            }
            if (GUILayout.Button("Shut", GUILayout.MaxWidth(60), GUILayout.Height(30)))
            {
                BTTreeWindow.ShutWindow();
            }

            if (GUILayout.Button("Save", GUILayout.MaxWidth(60), GUILayout.Height(30)))
            {
            }
            if (GUILayout.Button("Load", GUILayout.MaxWidth(60), GUILayout.Height(30)))
            {
            }
            EditorGUILayout.EndHorizontal();
            GUI.backgroundColor = Color.black;
            GUILayout.Space(10);

            Tree.Blackboard.SetRoot(Tree.transform);
            Tree.Blackboard.DrawGUI();
            base.serializedObject.ApplyModifiedProperties();
        }