-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIButtonEditor.cs
More file actions
93 lines (81 loc) · 3.06 KB
/
UIButtonEditor.cs
File metadata and controls
93 lines (81 loc) · 3.06 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2014 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
#if UNITY_3_5
[CustomEditor(typeof(UIButton))]
#else
[CustomEditor(typeof(UIButton), true)]
#endif
public class UIButtonEditor : UIButtonColorEditor
{
enum Highlight
{
DoNothing,
Press,
}
protected override void DrawProperties ()
{
SerializedProperty sp = serializedObject.FindProperty("dragHighlight");
Highlight ht = sp.boolValue ? Highlight.Press : Highlight.DoNothing;
GUILayout.BeginHorizontal();
bool highlight = (Highlight)EditorGUILayout.EnumPopup("Drag Over", ht) == Highlight.Press;
NGUIEditorTools.DrawPadding();
GUILayout.EndHorizontal();
if (sp.boolValue != highlight) sp.boolValue = highlight;
DrawTransition();
DrawColors();
UIButton btn = target as UIButton;
if (btn.tweenTarget != null)
{
UISprite sprite = btn.tweenTarget.GetComponent<UISprite>();
UI2DSprite s2d = btn.tweenTarget.GetComponent<UI2DSprite>();
if (sprite != null)
{
if (NGUIEditorTools.DrawHeader("Sprites", "Sprites", false, true))
{
NGUIEditorTools.BeginContents(true);
EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
{
SerializedObject obj = new SerializedObject(sprite);
obj.Update();
SerializedProperty atlas = obj.FindProperty("mAtlas");
NGUIEditorTools.DrawSpriteField("Normal", obj, atlas, obj.FindProperty("mSpriteName"));
obj.ApplyModifiedProperties();
NGUIEditorTools.DrawSpriteField("Hover", serializedObject, atlas, serializedObject.FindProperty("hoverSprite"), true);
NGUIEditorTools.DrawSpriteField("Pressed", serializedObject, atlas, serializedObject.FindProperty("pressedSprite"), true);
NGUIEditorTools.DrawSpriteField("Disabled", serializedObject, atlas, serializedObject.FindProperty("disabledSprite"), true);
}
EditorGUI.EndDisabledGroup();
NGUIEditorTools.DrawProperty("Pixel Snap", serializedObject, "pixelSnap");
NGUIEditorTools.EndContents();
}
}
else if (s2d != null)
{
if (NGUIEditorTools.DrawHeader("Sprites", "Sprites", false, true))
{
NGUIEditorTools.BeginContents(true);
EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
{
SerializedObject obj = new SerializedObject(s2d);
obj.Update();
NGUIEditorTools.DrawProperty("Normal", obj, "mSprite");
obj.ApplyModifiedProperties();
NGUIEditorTools.DrawProperty("Hover", serializedObject, "hoverSprite2D");
NGUIEditorTools.DrawProperty("Pressed", serializedObject, "pressedSprite2D");
NGUIEditorTools.DrawProperty("Disabled", serializedObject, "disabledSprite2D");
}
EditorGUI.EndDisabledGroup();
NGUIEditorTools.DrawProperty("Pixel Snap", serializedObject, "pixelSnap");
NGUIEditorTools.EndContents();
}
}
}
UIButton button = target as UIButton;
NGUIEditorTools.DrawEvents("On Click", button, button.onClick, false);
}
}