Esempio n. 1
0
        public static GenericMenu CreateBehaviourTreeEditorMenu(BehaviourTreeEditor editor)
        {
            GenericMenu        menu       = new GenericMenu();
            BTEditorTreeLayout treeLayout = BTEditorStyle.TreeLayout;

            menu.AddItem(new GUIContent("New"), false, editor.CreateNewBehaviourTree);
            menu.AddItem(new GUIContent("Open"), false, editor.OpenBehaviourTree);
            if (BTEditorCanvas.Current.ReadOnly)
            {
                menu.AddDisabledItem(new GUIContent("Save"));
            }
            else
            {
                menu.AddItem(new GUIContent("Save"), false, editor.SaveBehaviourTree);
                AssetDatabase.SaveAssets();
            }

            var recentFiles = editor.NavigationHistory.RecentFiles;

            if (recentFiles.Count > 0)
            {
                GenericMenu.MenuFunction2 func = (obj) =>
                {
                    BTAsset asset = AssetDatabase.LoadAssetAtPath <BTAsset>((string)obj);
                    BehaviourTreeEditor.Open(asset);
                };

                foreach (var file in recentFiles)
                {
                    menu.AddItem(new GUIContent("Recent Files/" + file.Replace('/', '\\')), false, func, file);
                }
            }
            else
            {
                menu.AddItem(new GUIContent("Recent Files/Empty"), false, () => { });
            }

            menu.AddSeparator("");

            menu.AddItem(new GUIContent("Snap To Grid"), BTEditorCanvas.Current.SnapToGrid, () =>
            {
                BTEditorCanvas.Current.SnapToGrid = !BTEditorCanvas.Current.SnapToGrid;
            });

            // 树结构强制使用垂直布局

            /*foreach(BTEditorTreeLayout layout in Enum.GetValues(typeof(BTEditorTreeLayout)))
             * {
             *      menu.AddItem(new GUIContent("Layout/" + layout.ToString()), treeLayout == layout, (obj) =>
             *      {
             *              BTEditorStyle.TreeLayout = (BTEditorTreeLayout)obj;
             *      }, layout);
             * }*/

            return(menu);
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.LabelField("Title");
            m_asset.title = EditorGUILayout.TextArea(m_asset.title, EditorStyles.textField);
            EditorGUILayout.LabelField("Comment");
            m_asset.description = EditorGUILayout.TextArea(m_asset.description, EditorStyles.textField);

            if (GUILayout.Button("Open In Editor", GUILayout.Height(24.0f)))
            {
                BehaviourTreeEditor.Open(target as BTAsset);
            }
        }