forked from mob-sakai/SoftMaskForUGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectTransformFitterEditor.cs
45 lines (38 loc) · 1.47 KB
/
RectTransformFitterEditor.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
using UnityEditor;
using UnityEngine;
namespace Coffee.UISoftMask
{
[CustomEditor(typeof(RectTransformFitter))]
[CanEditMultipleObjects]
public class RectTransformFitterEditor : Editor
{
private static readonly GUIContent s_TargetPropertiesContent = new GUIContent("Target Properties");
private SerializedProperty _target;
private SerializedProperty _targetProperties;
protected void OnEnable()
{
_target = serializedObject.FindProperty("m_Target");
_targetProperties = serializedObject.FindProperty("m_TargetProperties");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
// Target
EditorGUILayout.PropertyField(_target);
// TargetProperties
EditorGUI.BeginChangeCheck();
{
EditorGUI.showMixedValue = _targetProperties.hasMultipleDifferentValues;
var value = (RectTransformFitter.RectTransformProperties)_targetProperties.intValue;
value = (RectTransformFitter.RectTransformProperties)EditorGUILayout.EnumFlagsField(
s_TargetPropertiesContent, value);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
{
_targetProperties.intValue = (int)value;
}
}
serializedObject.ApplyModifiedProperties();
}
}
}