Skip to content

Commit 46f2670

Browse files
committed
change default behavior folder to Behaviors
1 parent 5d4543f commit 46f2670

File tree

88 files changed

+1560
-1529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1560
-1529
lines changed

Assets/Visual Behavior Tree.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor.meta renamed to Assets/Visual Behavior Tree/Editor.meta

Lines changed: 8 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,96 @@
1-
using Assets.Scripts.AI;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.ComponentModel;
5-
using System.Reflection;
6-
using UnityEditor;
7-
using UnityEngine;
8-
9-
namespace Assets.Editor
10-
{
11-
public class BaseEditor<T> : UnityEditor.Editor where T : MonoBehaviour
12-
{
13-
T data;
14-
protected virtual void OnEnable()
15-
{
16-
data = (T)serializedObject.targetObject;
17-
}
18-
19-
public override void OnInspectorGUI()
20-
{
21-
serializedObject.Update();
22-
23-
GUIContent label = new GUIContent();
24-
label.text = "Properties";
25-
26-
DrawDefaultInspectors(label, data);
27-
28-
if (GUI.changed)
29-
{
30-
EditorUtility.SetDirty(target);
31-
}
32-
33-
serializedObject.ApplyModifiedProperties();
34-
}
35-
36-
protected void DrawDefaultInspectors(GUIContent label, T target)
37-
{
38-
EditorGUILayout.Separator();
39-
Type type = typeof(T);
40-
FieldInfo[] fields = type.GetFields();
41-
EditorGUI.indentLevel++;
42-
43-
foreach (FieldInfo field in fields)
44-
{
45-
if (field.IsPublic)
46-
{
47-
if (field.FieldType == typeof(int))
48-
{
49-
field.SetValue(target, EditorGUILayout.IntField(
50-
MakeLabel(field), (int)field.GetValue(target)));
51-
}
52-
else if (field.FieldType == typeof(float))
53-
{
54-
field.SetValue(target, EditorGUILayout.FloatField(
55-
MakeLabel(field), (float)field.GetValue(target)));
56-
}
57-
else if(field.FieldType == typeof(List<BehaviorTreeManagerAsset>))
58-
{
59-
var fieldProp = serializedObject.FindProperty(field.Name);
60-
EditorList.Show(fieldProp, EditorListOption.Buttons | EditorListOption.ElementLabels);
61-
}
62-
else if(serializedObject != null)
63-
{
64-
//Debug.Log("Trying to draw: " + field.Name);
65-
EditorGUILayout.PropertyField(serializedObject.FindProperty(field.Name));
66-
}
67-
else
68-
{
69-
Debug.LogError(
70-
"DrawDefaultInspectors does not support fields of type " +
71-
field.FieldType);
72-
}
73-
}
74-
}
75-
76-
EditorGUI.indentLevel--;
77-
}
78-
79-
private static GUIContent MakeLabel(FieldInfo field)
80-
{
81-
GUIContent guiContent = new GUIContent();
82-
guiContent.text = field.Name;
83-
object[] descriptions =
84-
field.GetCustomAttributes(typeof(DescriptionAttribute), true);
85-
86-
if (descriptions.Length > 0)
87-
{
88-
//just use the first one.
89-
guiContent.tooltip =
90-
(descriptions[0] as DescriptionAttribute).Description;
91-
}
92-
93-
return guiContent;
94-
}
95-
}
1+
using Assets.Scripts.AI;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel;
5+
using System.Reflection;
6+
using UnityEditor;
7+
using UnityEngine;
8+
9+
namespace Assets.Editor
10+
{
11+
public class BaseEditor<T> : UnityEditor.Editor where T : MonoBehaviour
12+
{
13+
T data;
14+
protected virtual void OnEnable()
15+
{
16+
data = (T)serializedObject.targetObject;
17+
}
18+
19+
public override void OnInspectorGUI()
20+
{
21+
serializedObject.Update();
22+
23+
GUIContent label = new GUIContent();
24+
label.text = "Properties";
25+
26+
DrawDefaultInspectors(label, data);
27+
28+
if (GUI.changed)
29+
{
30+
EditorUtility.SetDirty(target);
31+
}
32+
33+
serializedObject.ApplyModifiedProperties();
34+
}
35+
36+
protected void DrawDefaultInspectors(GUIContent label, T target)
37+
{
38+
EditorGUILayout.Separator();
39+
Type type = typeof(T);
40+
FieldInfo[] fields = type.GetFields();
41+
EditorGUI.indentLevel++;
42+
43+
foreach (FieldInfo field in fields)
44+
{
45+
if (field.IsPublic)
46+
{
47+
if (field.FieldType == typeof(int))
48+
{
49+
field.SetValue(target, EditorGUILayout.IntField(
50+
MakeLabel(field), (int)field.GetValue(target)));
51+
}
52+
else if (field.FieldType == typeof(float))
53+
{
54+
field.SetValue(target, EditorGUILayout.FloatField(
55+
MakeLabel(field), (float)field.GetValue(target)));
56+
}
57+
else if(field.FieldType == typeof(List<BehaviorTreeManagerAsset>))
58+
{
59+
var fieldProp = serializedObject.FindProperty(field.Name);
60+
EditorList.Show(fieldProp, EditorListOption.Buttons | EditorListOption.ElementLabels);
61+
}
62+
else if(serializedObject != null)
63+
{
64+
//Debug.Log("Trying to draw: " + field.Name);
65+
EditorGUILayout.PropertyField(serializedObject.FindProperty(field.Name));
66+
}
67+
else
68+
{
69+
Debug.LogError(
70+
"DrawDefaultInspectors does not support fields of type " +
71+
field.FieldType);
72+
}
73+
}
74+
}
75+
76+
EditorGUI.indentLevel--;
77+
}
78+
79+
private static GUIContent MakeLabel(FieldInfo field)
80+
{
81+
GUIContent guiContent = new GUIContent();
82+
guiContent.text = field.Name;
83+
object[] descriptions =
84+
field.GetCustomAttributes(typeof(DescriptionAttribute), true);
85+
86+
if (descriptions.Length > 0)
87+
{
88+
//just use the first one.
89+
guiContent.tooltip =
90+
(descriptions[0] as DescriptionAttribute).Description;
91+
}
92+
93+
return guiContent;
94+
}
95+
}
9696
}

Assets/Editor/BaseEditor.cs.meta renamed to Assets/Visual Behavior Tree/Editor/BaseEditor.cs.meta

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
using Assets.Editor.BehaviorTreeViewEditor;
2-
using Assets.Scripts.AI;
3-
using UnityEditor;
4-
using UnityEngine;
5-
6-
namespace Assets.Editor
7-
{
8-
[CustomEditor(typeof(BehaviorManager))]
9-
public class BehaviorManagerEditor : BaseEditor<BehaviorManager>
10-
{
11-
BehaviorManager BTreeManager;
12-
BehaviorTreeManagerAsset _BTreeAsset;
13-
14-
protected override void OnEnable()
15-
{
16-
base.OnEnable();
17-
BTreeManager = (BehaviorManager)serializedObject.targetObject;
18-
}
19-
20-
public override void OnInspectorGUI()
21-
{
22-
base.OnInspectorGUI();
23-
24-
if (GUILayout.Button("Reload"))
25-
{
26-
BTreeManager.Reinitialize();
27-
}
28-
29-
if(GUILayout.Button("Debug"))
30-
{
31-
TreeDebuggerWindow.ShowWindow();
32-
}
33-
}
34-
}
1+
using Assets.Editor.BehaviorTreeViewEditor;
2+
using Assets.Scripts.AI;
3+
using UnityEditor;
4+
using UnityEngine;
5+
6+
namespace Assets.Editor
7+
{
8+
[CustomEditor(typeof(BehaviorManager))]
9+
public class BehaviorManagerEditor : BaseEditor<BehaviorManager>
10+
{
11+
BehaviorManager BTreeManager;
12+
BehaviorTreeManagerAsset _BTreeAsset;
13+
14+
protected override void OnEnable()
15+
{
16+
base.OnEnable();
17+
BTreeManager = (BehaviorManager)serializedObject.targetObject;
18+
}
19+
20+
public override void OnInspectorGUI()
21+
{
22+
base.OnInspectorGUI();
23+
24+
if (GUILayout.Button("Reload"))
25+
{
26+
BTreeManager.Reinitialize();
27+
}
28+
29+
if(GUILayout.Button("Debug"))
30+
{
31+
TreeDebuggerWindow.ShowWindow();
32+
}
33+
}
34+
}
3535
}

Assets/Editor/BehaviorManagerEditor.cs.meta renamed to Assets/Visual Behavior Tree/Editor/BehaviorManagerEditor.cs.meta

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/BehaviorTreeViewEditor.meta renamed to Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor.meta

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/BehaviorTreeViewEditor/BackendData.meta renamed to Assets/Visual Behavior Tree/Editor/BehaviorTreeViewEditor/BackendData.meta

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)