Skip to content

Commit 3a458d2

Browse files
committed
Simplified UnityEngine.Object into UnityObject.
1 parent 020f0e2 commit 3a458d2

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

Assets/Script Tester/Editor/ComponentMethodDrawer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using System.Reflection;
88
using ScriptTester;
9+
using UnityObject = UnityEngine.Object;
910

1011
namespace ScriptTester {
1112
class ComponentMethodDrawer:IReflectorDrawer {
@@ -138,15 +139,15 @@ public void Call() {
138139
public void Draw() {
139140
if(drawHeader) {
140141
EditorGUI.BeginDisabledGroup(component == null);
141-
titleFolded = EditorGUILayout.InspectorTitlebar(titleFolded, component as UnityEngine.Object) || component == null;
142+
titleFolded = EditorGUILayout.InspectorTitlebar(titleFolded, component as UnityObject) || component == null;
142143
EditorGUI.EndDisabledGroup();
143144
}
144145
GUI.changed = false;
145146
if(component == null || titleFolded || !drawHeader) {
146147
if(drawHeader) {
147148
EditorGUI.indentLevel++;
148149
EditorGUILayout.BeginVertical();
149-
component = EditorGUILayout.ObjectField("Target", component as UnityEngine.Object, typeof(UnityEngine.Object), true);
150+
component = EditorGUILayout.ObjectField("Target", component as UnityObject, typeof(UnityObject), true);
150151
}
151152
if(component != null || ctorMode) {
152153
if(GUI.changed) {

Assets/Script Tester/Editor/Helpers.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Reflection;
77
using System.Linq;
88
using System.Text;
9+
using UnityObject = UnityEngine.Object;
910

1011
namespace ScriptTester {
1112
enum PropertyType {
@@ -38,7 +39,7 @@ struct ComponentMethod {
3839
struct ComponentFields {
3940
public FieldInfo field;
4041
public PropertyInfo property;
41-
public UnityEngine.Object target;
42+
public UnityObject target;
4243
}
4344

4445
interface IReflectorDrawer {
@@ -78,7 +79,7 @@ internal static void InitPropertyTypeMapper() {
7879
propertyTypeMapper.Add(typeof(Rect), PropertyType.Rect);
7980
propertyTypeMapper.Add(typeof(Bounds), PropertyType.Bounds);
8081
propertyTypeMapper.Add(typeof(AnimationCurve), PropertyType.Curve);
81-
propertyTypeMapper.Add(typeof(UnityEngine.Object), PropertyType.Object);
82+
propertyTypeMapper.Add(typeof(UnityObject), PropertyType.Object);
8283
propertyTypeMapper.Add(typeof(Array), PropertyType.Array);
8384
}
8485

@@ -328,7 +329,7 @@ internal static string StringField(Rect position, string label, string value, bo
328329
return value;
329330
}
330331

331-
internal static UnityEngine.Object ObjectField(string label, UnityEngine.Object value, Type objectType, bool allowScreenObjs, bool readOnly, params GUILayoutOption[] options) {
332+
internal static UnityObject ObjectField(string label, UnityObject value, Type objectType, bool allowScreenObjs, bool readOnly, params GUILayoutOption[] options) {
332333
if(!readOnly)
333334
return EditorGUILayout.ObjectField(label, value, objectType, allowScreenObjs, options);
334335
EditorGUILayout.BeginHorizontal();
@@ -341,7 +342,7 @@ internal static UnityEngine.Object ObjectField(string label, UnityEngine.Object
341342
return value;
342343
}
343344

344-
internal static UnityEngine.Object ObjectField(Rect position, string label, UnityEngine.Object value, Type objectType, bool allowScreenObjs, bool readOnly) {
345+
internal static UnityObject ObjectField(Rect position, string label, UnityObject value, Type objectType, bool allowScreenObjs, bool readOnly) {
345346
if(!readOnly)
346347
return EditorGUI.ObjectField(position, label, value, objectType, allowScreenObjs);
347348
EditorGUI.PrefixLabel(ScaleRect(position, widthScale: 0.5F), new GUIContent(label));
@@ -350,7 +351,7 @@ internal static UnityEngine.Object ObjectField(Rect position, string label, Unit
350351
return value;
351352
}
352353

353-
static void ClickObject(UnityEngine.Object obj) {
354+
static void ClickObject(UnityObject obj) {
354355
var newClickTime = EditorApplication.timeSinceStartup;
355356
if(newClickTime - clickTime < 0.3 && obj != null)
356357
Selection.activeObject = obj;
@@ -429,7 +430,7 @@ internal static bool FetchValue(MemberInfo info, object target, out object value
429430
}
430431

431432
internal static int ObjIdOrHashCode(object obj) {
432-
var unityObj = obj as UnityEngine.Object;
433+
var unityObj = obj as UnityObject;
433434
if(unityObj != null)
434435
return unityObj.GetInstanceID();
435436
if(obj != null)

Assets/Script Tester/Editor/InspectorDrawer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Reflection;
66
using System.Linq;
7+
using UnityObject = UnityEngine.Object;
78

89
namespace ScriptTester {
910
class InspectorDrawer {
@@ -59,7 +60,7 @@ public InspectorDrawer(object target, bool shown, bool showProps, bool showPriva
5960

6061
public void Draw(bool drawHeader = true, bool readOnly = false) {
6162
if(drawHeader) {
62-
shown = EditorGUILayout.InspectorTitlebar(shown, target as UnityEngine.Object);
63+
shown = EditorGUILayout.InspectorTitlebar(shown, target as UnityObject);
6364
Helper.StoreState(target, shown);
6465
if(!shown)
6566
return;

Assets/Script Tester/Editor/InspectorPlus.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Reflection;
77
using ScriptTester;
8+
using UnityObject = UnityEngine.Object;
89

910
namespace ScriptTester {
1011
class InspectorPlus : EditorWindow {
@@ -159,7 +160,7 @@ InspectorDrawer[] CreateDrawers(int instanceID) {
159160
return ret.ToArray();
160161
}
161162

162-
InspectorDrawer CreateDrawer(UnityEngine.Object target, bool shown) {
163+
InspectorDrawer CreateDrawer(UnityObject target, bool shown) {
163164
var drawer = new InspectorDrawer(target, shown, showProps, privateFields, showObsolete, showMethods);
164165
drawer.OnRequireRedraw += Repaint;
165166
return drawer;

Assets/Script Tester/Editor/MethodPropertyDrawer.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Linq;
77
using System.Reflection;
88
using ScriptTester;
9+
using UnityObject = UnityEngine.Object;
910

1011
namespace ScriptTester {
1112
class MethodPropertyDrawer:IReflectorDrawer {
@@ -18,7 +19,7 @@ class MethodPropertyDrawer:IReflectorDrawer {
1819
bool referenceMode;
1920
int grabValueMode;
2021

21-
UnityEngine.Object component;
22+
UnityObject component;
2223
readonly List<ComponentFields> fields;
2324
string[] fieldNames;
2425
int selectedFieldIndex;
@@ -44,7 +45,7 @@ class MethodPropertyDrawer:IReflectorDrawer {
4445
readonly List<MethodPropertyDrawer> arrayContentDrawer;
4546
ReorderableList arrayHandler;
4647

47-
public UnityEngine.Object Component {
48+
public UnityObject Component {
4849
get { return component; }
4950
set {
5051
component = value;
@@ -310,7 +311,7 @@ public void Draw(bool readOnly, Rect? rect = null) {
310311
EditorGUILayout.HelpBox(getException.Message, MessageType.Error);
311312
}
312313

313-
void AddField(UnityEngine.Object target) {
314+
void AddField(UnityObject target) {
314315
if(target == null)
315316
return;
316317
BindingFlags flag = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
@@ -384,9 +385,9 @@ void DrawCtorField() {
384385

385386
void DrawReferencedField(Rect? rect) {
386387
if(rect.HasValue)
387-
component = EditorGUI.ObjectField(Helper.ScaleRect(rect.Value, 0, 0, 0.5F, 1), name, component, typeof(UnityEngine.Object), true);
388+
component = EditorGUI.ObjectField(Helper.ScaleRect(rect.Value, 0, 0, 0.5F, 1), name, component, typeof(UnityObject), true);
388389
else
389-
component = EditorGUILayout.ObjectField(name, component, typeof(UnityEngine.Object), true);
390+
component = EditorGUILayout.ObjectField(name, component, typeof(UnityObject), true);
390391
if(component == null) {
391392
EditorGUI.BeginDisabledGroup(true);
392393
if(rect.HasValue)
@@ -518,9 +519,9 @@ void DrawDirectField(bool readOnly, Rect? rect) {
518519
break;
519520
case PropertyType.Object:
520521
if(rect.HasValue)
521-
value = Helper.ObjectField(rect.Value, name, (UnityEngine.Object)value, requiredType, true, readOnly);
522+
value = Helper.ObjectField(rect.Value, name, (UnityObject)value, requiredType, true, readOnly);
522523
else
523-
value = Helper.ObjectField(name, (UnityEngine.Object)value, requiredType, true, readOnly);
524+
value = Helper.ObjectField(name, (UnityObject)value, requiredType, true, readOnly);
524525
break;
525526
case PropertyType.Array:
526527
if(rect.HasValue) {

0 commit comments

Comments
 (0)