-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMonoPropertyReference.cs
48 lines (39 loc) · 1.03 KB
/
MonoPropertyReference.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Reflection;
namespace TypeInspector
{
/// <summary>
/// Make property reference for specific MonoBehaviour target object
/// </summary>
[Serializable]
public class MonoPropertyReference : PropertyReferenceBase
{
public UnityEngine.Object Target;
public string PropertyName;
public void Set(object data)
{
Set(Target, data);
}
public object Get()
{
return Get(Target);
}
public override Type GetSourceType()
{
return Target.GetType();
}
public override PropertyInfo GetProperty()
{
if (Target == null || string.IsNullOrEmpty(PropertyName))
{
return null;
}
if (_propertyCache != null)
{
return _propertyCache;
}
_propertyCache = Target.GetType().GetProperty(PropertyName);
return _propertyCache;
}
}
}