forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.cs
More file actions
116 lines (114 loc) · 2.99 KB
/
Button.cs
File metadata and controls
116 lines (114 loc) · 2.99 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
using UnityEditor;
using UnityEngine;
namespace UnityEditorInternal
{
internal class Button
{
[Obsolete("DrawCapFunction is obsolete. Use the version with CapFunction instead. Example: Change SphereCap to SphereHandleCap.")]
public static bool Do(int id, Vector3 position, Quaternion direction, float size, float pickSize, Handles.DrawCapFunction capFunc)
{
Event current = Event.current;
bool result;
switch (current.GetTypeForControl(id))
{
case EventType.MouseDown:
if (HandleUtility.nearestControl == id && (current.button == 0 || current.button == 2))
{
GUIUtility.hotControl = id;
current.Use();
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == id && (current.button == 0 || current.button == 2))
{
GUIUtility.hotControl = 0;
current.Use();
if (HandleUtility.nearestControl == id)
{
result = true;
return result;
}
}
break;
case EventType.MouseMove:
if ((HandleUtility.nearestControl == id && current.button == 0) || (GUIUtility.keyboardControl == id && current.button == 2))
{
HandleUtility.Repaint();
}
break;
case EventType.Repaint:
{
Color color = Handles.color;
if (HandleUtility.nearestControl == id && GUI.enabled)
{
Handles.color = Handles.selectedColor;
}
capFunc(id, position, direction, size);
Handles.color = color;
break;
}
case EventType.Layout:
if (GUI.enabled)
{
HandleUtility.AddControl(id, HandleUtility.DistanceToCircle(position, pickSize));
}
break;
}
result = false;
return result;
}
public static bool Do(int id, Vector3 position, Quaternion direction, float size, float pickSize, Handles.CapFunction capFunction)
{
Event current = Event.current;
bool result;
switch (current.GetTypeForControl(id))
{
case EventType.MouseDown:
if (HandleUtility.nearestControl == id && (current.button == 0 || current.button == 2))
{
GUIUtility.hotControl = id;
current.Use();
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == id && (current.button == 0 || current.button == 2))
{
GUIUtility.hotControl = 0;
current.Use();
if (HandleUtility.nearestControl == id)
{
result = true;
return result;
}
}
break;
case EventType.MouseMove:
if ((HandleUtility.nearestControl == id && current.button == 0) || (GUIUtility.keyboardControl == id && current.button == 2))
{
HandleUtility.Repaint();
}
break;
case EventType.Repaint:
{
Color color = Handles.color;
if (HandleUtility.nearestControl == id && GUI.enabled)
{
Handles.color = Handles.selectedColor;
}
capFunction(id, position, direction, size, EventType.Repaint);
Handles.color = color;
break;
}
case EventType.Layout:
if (GUI.enabled)
{
capFunction(id, position, direction, pickSize, EventType.Layout);
}
break;
}
result = false;
return result;
}
}
}