forked from Deadcows/MyBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AttributeBase.cs
47 lines (41 loc) · 1.19 KB
/
AttributeBase.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
using System;
using UnityEngine;
namespace MyBox.Internal
{
[AttributeUsage(AttributeTargets.Field)]
public abstract class AttributeBase : PropertyAttribute
{
#if UNITY_EDITOR
/// <summary>
/// Validation is called before all other methods.
/// Once in OnGUI and once in GetPropertyHeight
/// </summary>
public virtual void ValidateProperty(UnityEditor.SerializedProperty property)
{
}
public virtual void OnBeforeGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
{
}
/// <summary>
/// Called once per AttributeBase group.
/// I.e. if something with higher order is drawn, later will be skipped
/// </summary>
/// <returns>false if nothing is drawn</returns>
public virtual bool OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
{
return false;
}
public virtual void OnAfterGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
{
}
/// <summary>
/// Overriding occurs just like OnGUI. Once per group, attribute with higher priority first
/// </summary>
/// <returns>Null if not overrided</returns>
public virtual float? OverrideHeight()
{
return null;
}
#endif
}
}