FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
InputSystem/Assets/Tests/InputSystem.Editor/TestData.cs at develop · LinusFl/InputSystem · GitHub
LinusFl
/
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
/
Tests
/
InputSystem.Editor
/
TestData.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (63 loc) · 2.84 KB
Breadcrumbs
InputSystem
/
Assets
/
Tests
/
InputSystem.Editor
/
TestData.cs
Copy path
File metadata and controls
74 lines (63 loc) · 2.84 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
#if
UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
using
System
.
Collections
.
Generic
;
using
UnityEditor
;
using
UnityEngine
;
using
UnityEngine
.
InputSystem
;
using
UnityEngine
.
InputSystem
.
Editor
;
using
InputAnalytics
=
UnityEngine
.
InputSystem
.
InputAnalytics
;
using
Random
=
UnityEngine
.
Random
;
public
static
class
TestData
{
private
const
string
kAlphaNumericCharacters
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
public
static
Generator
<
string
>
alphaNumericString
=
new
(
(
)
=>
{
var
length
=
(
int
)
(
Random
.
value
*
25
+
1
)
;
var
chars
=
new
char
[
length
]
;
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
chars
[
i
]
=
kAlphaNumericCharacters
[
(
int
)
(
Random
.
value
*
kAlphaNumericCharacters
.
Length
)
]
;
}
return
new
string
(
chars
)
;
}
)
;
public
static
Generator
<
InputActionAsset
>
inputActionAsset
=
new
(
(
)
=>
{
var
asset
=
ScriptableObject
.
CreateInstance
<
InputActionAsset
>
(
)
;
var
actionMap
=
asset
.
AddActionMap
(
alphaNumericString
.
Generate
(
)
)
;
var
action
=
actionMap
.
AddAction
(
alphaNumericString
.
Generate
(
)
)
;
action
.
AddBinding
(
"<Gamepad>/leftStick"
)
;
return
asset
;
}
)
;
internal
static
Generator
<
InputActionsEditorState
>
editorState
=
new
(
(
)
=>
new
InputActionsEditorState
(
new
InputActionsEditorSessionAnalytic
(
InputActionsEditorSessionAnalytic
.
Data
.
Kind
.
EditorWindow
)
,
new
SerializedObject
(
ScriptableObject
.
CreateInstance
<
InputActionAsset
>
(
)
)
)
)
;
internal
static
Generator
<
InputActionsEditorState
>
EditorStateWithAsset
(
ScriptableObject
asset
)
{
return
new
Generator
<
InputActionsEditorState
>
(
(
)
=>
new
InputActionsEditorState
(
null
,
new
SerializedObject
(
asset
)
)
)
;
}
public
static
Generator
<
InputControlScheme
.
DeviceRequirement
>
deviceRequirement
=
new
(
(
)
=>
new
InputControlScheme
.
DeviceRequirement
{
controlPath
=
$
"<
{
alphaNumericString
.
Generate
(
)
}
>"
}
)
;
public
static
Generator
<
InputControlScheme
>
controlScheme
=
new
(
(
)
=>
new
InputControlScheme
(
alphaNumericString
.
Generate
(
)
)
)
;
public
static
Generator
<
InputControlScheme
>
controlSchemeWithOneDeviceRequirement
=
new
(
(
)
=>
new
InputControlScheme
(
alphaNumericString
.
Generate
(
)
,
deviceRequirement
.
Generate
(
1
)
)
)
;
public
static
Generator
<
InputControlScheme
>
controlSchemeWithTwoDeviceRequirements
=
new
(
(
)
=>
new
InputControlScheme
(
alphaNumericString
.
Generate
(
)
,
deviceRequirement
.
Generate
(
2
)
)
)
;
public
static
Generator
<
IEnumerable
<
T
>
>
N
<
T
>
(
Generator
<
T
>
generator
,
int
count
)
{
return
new
Generator
<
IEnumerable
<
T
>
>
(
(
)
=>
{
var
array
=
new
T
[
count
]
;
for
(
var
i
=
0
;
i
<
count
;
i
++
)
{
array
[
i
]
=
generator
.
Generate
(
)
;
}
return
array
;
}
)
;
}
}
#endif
Back
|
FazBrowse Home
|
New Git URL