FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
InputSystem/Assets/Samples/Visualizers/InputVisualizer.cs at develop · hosepha/InputSystem · GitHub
hosepha
/
InputSystem
Public
forked from
Unity-Technologies/InputSystem
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
InputSystem
/
Assets
/
Samples
/
Visualizers
/
InputVisualizer.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
83 lines (69 loc) · 2.67 KB
Breadcrumbs
InputSystem
/
Assets
/
Samples
/
Visualizers
/
InputVisualizer.cs
Copy path
File metadata and controls
83 lines (69 loc) · 2.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
using
System
;
// Some fields assigned through only through serialization.
#pragma warning disable
CS0649
namespace
UnityEngine
.
InputSystem
.
Samples
{
/// <summary>
/// Base class for <see cref="InputActionVisualizer"/> and <see cref="InputControlVisualizer"/>.
/// Not meant to be extended outside of input system.
/// </summary>
public
abstract
class
InputVisualizer
:
MonoBehaviour
{
protected
void
OnEnable
(
)
{
ResolveParent
(
)
;
}
protected
void
OnDisable
(
)
{
m_Parent
=
null
;
m_Visualizer
=
null
;
}
protected
void
OnGUI
(
)
{
if
(
Event
.
current
.
type
!=
EventType
.
Repaint
)
return
;
// If we have a parent, offset our rect by the parent.
var
rect
=
m_Rect
;
if
(
m_Parent
!=
null
)
rect
.
position
+=
m_Parent
.
m_Rect
.
position
;
if
(
m_Visualizer
!=
null
)
m_Visualizer
.
OnDraw
(
rect
)
;
else
VisualizationHelpers
.
DrawRectangle
(
rect
,
new
Color
(
1
,
1
,
1
,
0.1f
)
)
;
// Draw label, if we have one.
if
(
!
string
.
IsNullOrEmpty
(
m_Label
)
)
{
if
(
m_LabelContent
==
null
)
m_LabelContent
=
new
GUIContent
(
m_Label
)
;
if
(
s_LabelStyle
==
null
)
{
s_LabelStyle
=
new
GUIStyle
(
)
;
s_LabelStyle
.
normal
.
textColor
=
Color
.
yellow
;
}
////FIXME: why does CalcSize not calculate the rect width correctly?
var
labelSize
=
s_LabelStyle
.
CalcSize
(
m_LabelContent
)
;
var
labelRect
=
new
Rect
(
rect
.
x
+
4
,
rect
.
y
,
labelSize
.
x
+
4
,
rect
.
height
)
;
s_LabelStyle
.
Draw
(
labelRect
,
m_LabelContent
,
false
,
false
,
false
,
false
)
;
}
}
protected
void
OnValidate
(
)
{
ResolveParent
(
)
;
m_LabelContent
=
null
;
}
protected
void
ResolveParent
(
)
{
var
parentTransform
=
transform
.
parent
;
if
(
parentTransform
!=
null
)
m_Parent
=
parentTransform
.
GetComponent
<
InputControlVisualizer
>
(
)
;
}
[
SerializeField
]
internal
string
m_Label
;
[
SerializeField
]
internal
int
m_HistorySamples
=
500
;
[
SerializeField
]
internal
float
m_TimeWindow
=
3
;
[
SerializeField
]
internal
Rect
m_Rect
=
new
Rect
(
10
,
10
,
300
,
30
)
;
[
NonSerialized
]
internal
GUIContent
m_LabelContent
;
[
NonSerialized
]
internal
VisualizationHelpers
.
Visualizer
m_Visualizer
;
[
NonSerialized
]
internal
InputVisualizer
m_Parent
;
private
static
GUIStyle
s_LabelStyle
;
}
}
Back
|
FazBrowse Home
|
New Git URL