public override void OnInspectorGUI() { if (GUILayout.Button("Open In Editor", GUILayout.Height(24.0f))) { BehaviourTreeEditor.Open(target as BTAsset); } }
public override void OnInspectorGUI() { LogicObject lo = (LogicObject)target; if (EditorApplication.isPlaying) { if (!lo.ShowAttrs && GUILayout.Button("ShowAttributes")) { lo.ShowAttrs = true; } if (lo.ShowAttrs && GUILayout.Button("HideAttributes")) { lo.ShowAttrs = false; } } serializedObject.Update(); GUI.enabled = !EditorApplication.isPlaying; GUI.color = Color.white; serializedObject.ApplyModifiedProperties(); var agent = lo.so.GetComponent <AIAgent>(); if (agent != null) { BTAsset btAsset = agent.BehaviourTree as BTAsset; BehaviourTree btInstance = agent.GetBehaviourTree(); GUI.enabled = btAsset != null; if (EditorApplication.isPlaying && btInstance != null) { if (GUILayout.Button("Preview", GUILayout.Height(24.0f))) { BehaviourTreeEditor.OpenDebug(btAsset, btInstance); } } else { if (GUILayout.Button("Edit", GUILayout.Height(24.0f))) { BehaviourTreeEditor.Open(btAsset); } } } if (m_inspector != null) { BTEditorStyle.EnsureStyle(); m_inspector.DrawGUI(); Repaint(); } else { EditorGUILayout.HelpBox("There are no values to display!", MessageType.Error); } GUI.enabled = true; }
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); } CreateHelpOptions(menu); return(menu); }
public override void OnInspectorGUI() { serializedObject.Update(); GUI.enabled = !EditorApplication.isPlaying; EditorGUILayout.PropertyField(m_behaviourTree); EditorGUILayout.PropertyField(m_body); EditorGUILayout.PropertyField(m_updateMode); if (m_updateMode.enumValueIndex == (int)UpdateMode.AtInterval) { EditorGUILayout.PropertyField(m_updateInterval); } GUI.enabled = true; GUI.color = m_debugMode.boolValue ? Color.green : Color.red; m_debugMode.boolValue = GUILayout.Toggle(m_debugMode.boolValue, "Debug", "Button", GUILayout.Height(24.0f)); GUI.color = Color.white; serializedObject.ApplyModifiedProperties(); AIAgent agent = (AIAgent)target; BTAsset btAsset = m_behaviourTree.objectReferenceValue as BTAsset; BehaviourTree btInstance = agent.GetBehaviourTree(); GUI.enabled = btAsset != null; if (EditorApplication.isPlaying && btInstance != null) { if (GUILayout.Button("Preview", GUILayout.Height(24.0f))) { BehaviourTreeEditor.OpenDebug(btAsset, btInstance); } } else { if (GUILayout.Button("Edit", GUILayout.Height(24.0f))) { BehaviourTreeEditor.Open(btAsset); } } GUI.enabled = true; }