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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2013 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
using UnityEditor;
[CanEditMultipleObjects]
[CustomEditor(typeof(UICamera))]
public class UICameraEditor : Editor
{
public override void OnInspectorGUI ()
{
UICamera cam = target as UICamera;
GUILayout.Space(3f);
serializedObject.Update();
if (UICamera.eventHandler != cam)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("eventType"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("eventReceiverMask"), new GUIContent("Event Mask"));
serializedObject.ApplyModifiedProperties();
EditorGUILayout.HelpBox("All other settings are inherited from the First Camera.", MessageType.Info);
if (GUILayout.Button("Select the First Camera"))
{
Selection.activeGameObject = UICamera.eventHandler.gameObject;
}
}
else
{
SerializedProperty mouse = serializedObject.FindProperty("useMouse");
SerializedProperty touch = serializedObject.FindProperty("useTouch");
SerializedProperty keyboard = serializedObject.FindProperty("useKeyboard");
SerializedProperty controller = serializedObject.FindProperty("useController");
EditorGUILayout.PropertyField(serializedObject.FindProperty("eventType"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("eventReceiverMask"), new GUIContent("Event Mask"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("debug"));
EditorGUI.BeginDisabledGroup(!mouse.boolValue && !touch.boolValue);
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("allowMultiTouch"));
}
EditorGUI.EndDisabledGroup();
EditorGUI.BeginDisabledGroup(!mouse.boolValue);
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("stickyTooltip"));
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(serializedObject.FindProperty("tooltipDelay"));
GUILayout.Label("seconds", GUILayout.MinWidth(60f));
GUILayout.EndHorizontal();
}
EditorGUI.EndDisabledGroup();
GUILayout.BeginHorizontal();
SerializedProperty rd = serializedObject.FindProperty("rangeDistance");
EditorGUILayout.PropertyField(rd, new GUIContent("Raycast Range"));
GUILayout.Label(rd.floatValue < 0f ? "unlimited" : "units", GUILayout.MinWidth(60f));
GUILayout.EndHorizontal();
NGUIEditorTools.SetLabelWidth(80f);
if (NGUIEditorTools.DrawHeader("Event Sources"))
{
NGUIEditorTools.BeginContents();
{
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(mouse, new GUIContent("Mouse"), GUILayout.MinWidth(100f));
EditorGUILayout.PropertyField(touch, new GUIContent("Touch"), GUILayout.MinWidth(100f));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(keyboard, new GUIContent("Keyboard"), GUILayout.MinWidth(100f));
EditorGUILayout.PropertyField(controller, new GUIContent("Controller"), GUILayout.MinWidth(100f));
GUILayout.EndHorizontal();
}
NGUIEditorTools.EndContents();
}
if ((mouse.boolValue || touch.boolValue) && NGUIEditorTools.DrawHeader("Thresholds"))
{
NGUIEditorTools.BeginContents();
{
EditorGUI.BeginDisabledGroup(!mouse.boolValue);
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(serializedObject.FindProperty("mouseDragThreshold"), new GUIContent("Mouse Drag"), GUILayout.Width(120f));
GUILayout.Label("pixels");
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(serializedObject.FindProperty("mouseClickThreshold"), new GUIContent("Mouse Click"), GUILayout.Width(120f));
GUILayout.Label("pixels");
GUILayout.EndHorizontal();
EditorGUI.EndDisabledGroup();
EditorGUI.BeginDisabledGroup(!touch.boolValue);
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(serializedObject.FindProperty("touchDragThreshold"), new GUIContent("Touch Drag"), GUILayout.Width(120f));
GUILayout.Label("pixels");
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(serializedObject.FindProperty("touchClickThreshold"), new GUIContent("Touch Tap"), GUILayout.Width(120f));
GUILayout.Label("pixels");
GUILayout.EndHorizontal();
EditorGUI.EndDisabledGroup();
}
NGUIEditorTools.EndContents();
}
if ((mouse.boolValue || keyboard.boolValue || controller.boolValue) && NGUIEditorTools.DrawHeader("Axes and Keys"))
{
NGUIEditorTools.BeginContents();
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("horizontalAxisName"), new GUIContent("Horizontal"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("verticalAxisName"), new GUIContent("Vertical"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("scrollAxisName"), new GUIContent("Scroll"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("submitKey0"), new GUIContent("Submit 1"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("submitKey1"), new GUIContent("Submit 2"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("cancelKey0"), new GUIContent("Cancel 1"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("cancelKey1"), new GUIContent("Cancel 2"));
}
NGUIEditorTools.EndContents();
}
serializedObject.ApplyModifiedProperties();
}
}
}
|