net.dreditor.input 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/AnyInputDetector.cs +131 -131
- package/AnyInputDetector.cs.meta +1 -1
- package/DREditor.Input.asmdef +17 -17
- package/DREditor.Input.asmdef.meta +7 -7
- package/IInputManager.cs +50 -50
- package/IInputManager.cs.meta +1 -1
- package/PlayerInputHandler.cs +306 -306
- package/PlayerInputHandler.cs.meta +11 -11
- package/{Samples → Samples~}/Player_Input_Handler.prefab +135 -135
- package/{Samples → Samples~}/Player_Input_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/Set_Scheme_From_Device.prefab +46 -46
- package/{Samples → Samples~}/Set_Scheme_From_Device.prefab.meta +7 -7
- package/SetSchemeFromDevice.cs +145 -145
- package/SetSchemeFromDevice.cs.meta +11 -11
- package/package.json +40 -35
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
package/SetSchemeFromDevice.cs
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.Services;
|
|
3
|
-
using System.Collections.Generic;
|
|
4
|
-
using UnityEngine.InputSystem;
|
|
5
|
-
|
|
6
|
-
namespace DREditor.Input
|
|
7
|
-
{
|
|
8
|
-
/// <summary>
|
|
9
|
-
///
|
|
10
|
-
/// </summary>
|
|
11
|
-
[ClassHeader(nameof(AnyInputDetector) +
|
|
12
|
-
"\n\n")]
|
|
13
|
-
public class SetSchemeFromDevice : AnyInputDetector
|
|
14
|
-
{
|
|
15
|
-
/// <summary>
|
|
16
|
-
///
|
|
17
|
-
/// </summary>
|
|
18
|
-
protected InputDevice latestDevice = null;
|
|
19
|
-
|
|
20
|
-
/// <summary>
|
|
21
|
-
///
|
|
22
|
-
/// </summary>
|
|
23
|
-
protected IInputManager inputManager = null;
|
|
24
|
-
|
|
25
|
-
/// <summary>
|
|
26
|
-
///
|
|
27
|
-
/// </summary>
|
|
28
|
-
protected readonly Dictionary<string, List<string>> schemeDevices = new();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/// <summary>
|
|
32
|
-
///
|
|
33
|
-
/// </summary>
|
|
34
|
-
protected virtual void OnEnable() => Subscribe();
|
|
35
|
-
|
|
36
|
-
/// <summary>
|
|
37
|
-
///
|
|
38
|
-
/// </summary>
|
|
39
|
-
protected virtual void OnDisable() => Unsubscribe();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/// <summary>
|
|
43
|
-
///
|
|
44
|
-
/// </summary>
|
|
45
|
-
protected override void OnValidInputFound()
|
|
46
|
-
{
|
|
47
|
-
if (SchemeShouldChange())
|
|
48
|
-
ChangeScheme();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/// <summary>
|
|
52
|
-
///
|
|
53
|
-
/// </summary>
|
|
54
|
-
/// <returns></returns>
|
|
55
|
-
protected virtual bool SchemeShouldChange() =>
|
|
56
|
-
InputManagerValid() && DeviceIsValid() && !DeviceEntryAlreadyRegistered();
|
|
57
|
-
|
|
58
|
-
/// <summary>
|
|
59
|
-
///
|
|
60
|
-
/// </summary>
|
|
61
|
-
/// <returns></returns>
|
|
62
|
-
protected virtual bool InputManagerValid() => ServiceLocator.HasService(out inputManager);
|
|
63
|
-
|
|
64
|
-
/// <summary>
|
|
65
|
-
///
|
|
66
|
-
/// </summary>
|
|
67
|
-
/// <returns></returns>
|
|
68
|
-
protected virtual bool DeviceIsValid() => device != null && device != latestDevice;
|
|
69
|
-
|
|
70
|
-
/// <summary>
|
|
71
|
-
///
|
|
72
|
-
/// </summary>
|
|
73
|
-
/// <returns></returns>
|
|
74
|
-
protected virtual bool DeviceEntryAlreadyRegistered() => SchemeRegistered() && RegisteredSchemeMatchesDevice();
|
|
75
|
-
|
|
76
|
-
/// <summary>
|
|
77
|
-
///
|
|
78
|
-
/// </summary>
|
|
79
|
-
/// <returns></returns>
|
|
80
|
-
protected virtual bool SchemeRegistered() => schemeDevices.ContainsKey(inputManager.GetCurrentScheme());
|
|
81
|
-
|
|
82
|
-
/// <summary>
|
|
83
|
-
///
|
|
84
|
-
/// </summary>
|
|
85
|
-
/// <returns></returns>
|
|
86
|
-
protected virtual bool RegisteredSchemeMatchesDevice() =>
|
|
87
|
-
schemeDevices[inputManager.GetCurrentScheme()].Contains(device.name);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/// <summary>
|
|
91
|
-
///
|
|
92
|
-
/// </summary>
|
|
93
|
-
protected virtual void ChangeScheme()
|
|
94
|
-
{
|
|
95
|
-
LogUpdatedDevice();
|
|
96
|
-
|
|
97
|
-
UpdateSchemeUsingDevice();
|
|
98
|
-
|
|
99
|
-
UpdateRegistryWithLatest();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/// <summary>
|
|
103
|
-
///
|
|
104
|
-
/// </summary>
|
|
105
|
-
protected virtual void LogUpdatedDevice()
|
|
106
|
-
{
|
|
107
|
-
string log = latestDevice != null ?
|
|
108
|
-
device.name + " from: " + latestDevice.name :
|
|
109
|
-
device.name;
|
|
110
|
-
|
|
111
|
-
UnityEngine.Debug.Log($"{ToString()}: Input Detect Update: " + log);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/// <summary>
|
|
115
|
-
///
|
|
116
|
-
/// </summary>
|
|
117
|
-
protected virtual void UpdateSchemeUsingDevice()
|
|
118
|
-
{
|
|
119
|
-
latestDevice = device;
|
|
120
|
-
|
|
121
|
-
inputManager.SetSchemeByDevice(latestDevice);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/// <summary>
|
|
125
|
-
///
|
|
126
|
-
/// </summary>
|
|
127
|
-
protected virtual void UpdateRegistryWithLatest()
|
|
128
|
-
{
|
|
129
|
-
if (SchemeRegistered())
|
|
130
|
-
UpdateScheme();
|
|
131
|
-
else
|
|
132
|
-
RegisterScheme();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/// <summary>
|
|
136
|
-
///
|
|
137
|
-
/// </summary>
|
|
138
|
-
protected virtual void UpdateScheme() => schemeDevices[inputManager.GetCurrentScheme()].Add(device.name);
|
|
139
|
-
|
|
140
|
-
/// <summary>
|
|
141
|
-
///
|
|
142
|
-
/// </summary>
|
|
143
|
-
protected virtual void RegisterScheme() =>
|
|
144
|
-
schemeDevices.Add(inputManager.GetCurrentScheme(), new List<string>() { device.name });
|
|
145
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Services;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine.InputSystem;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Input
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
[ClassHeader(nameof(AnyInputDetector) +
|
|
12
|
+
"\n\n")]
|
|
13
|
+
public class SetSchemeFromDevice : AnyInputDetector
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
protected InputDevice latestDevice = null;
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
protected IInputManager inputManager = null;
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
protected readonly Dictionary<string, List<string>> schemeDevices = new();
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
protected virtual void OnEnable() => Subscribe();
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
protected virtual void OnDisable() => Unsubscribe();
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
///
|
|
44
|
+
/// </summary>
|
|
45
|
+
protected override void OnValidInputFound()
|
|
46
|
+
{
|
|
47
|
+
if (SchemeShouldChange())
|
|
48
|
+
ChangeScheme();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
/// <returns></returns>
|
|
55
|
+
protected virtual bool SchemeShouldChange() =>
|
|
56
|
+
InputManagerValid() && DeviceIsValid() && !DeviceEntryAlreadyRegistered();
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
///
|
|
60
|
+
/// </summary>
|
|
61
|
+
/// <returns></returns>
|
|
62
|
+
protected virtual bool InputManagerValid() => ServiceLocator.HasService(out inputManager);
|
|
63
|
+
|
|
64
|
+
/// <summary>
|
|
65
|
+
///
|
|
66
|
+
/// </summary>
|
|
67
|
+
/// <returns></returns>
|
|
68
|
+
protected virtual bool DeviceIsValid() => device != null && device != latestDevice;
|
|
69
|
+
|
|
70
|
+
/// <summary>
|
|
71
|
+
///
|
|
72
|
+
/// </summary>
|
|
73
|
+
/// <returns></returns>
|
|
74
|
+
protected virtual bool DeviceEntryAlreadyRegistered() => SchemeRegistered() && RegisteredSchemeMatchesDevice();
|
|
75
|
+
|
|
76
|
+
/// <summary>
|
|
77
|
+
///
|
|
78
|
+
/// </summary>
|
|
79
|
+
/// <returns></returns>
|
|
80
|
+
protected virtual bool SchemeRegistered() => schemeDevices.ContainsKey(inputManager.GetCurrentScheme());
|
|
81
|
+
|
|
82
|
+
/// <summary>
|
|
83
|
+
///
|
|
84
|
+
/// </summary>
|
|
85
|
+
/// <returns></returns>
|
|
86
|
+
protected virtual bool RegisteredSchemeMatchesDevice() =>
|
|
87
|
+
schemeDevices[inputManager.GetCurrentScheme()].Contains(device.name);
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/// <summary>
|
|
91
|
+
///
|
|
92
|
+
/// </summary>
|
|
93
|
+
protected virtual void ChangeScheme()
|
|
94
|
+
{
|
|
95
|
+
LogUpdatedDevice();
|
|
96
|
+
|
|
97
|
+
UpdateSchemeUsingDevice();
|
|
98
|
+
|
|
99
|
+
UpdateRegistryWithLatest();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// <summary>
|
|
103
|
+
///
|
|
104
|
+
/// </summary>
|
|
105
|
+
protected virtual void LogUpdatedDevice()
|
|
106
|
+
{
|
|
107
|
+
string log = latestDevice != null ?
|
|
108
|
+
device.name + " from: " + latestDevice.name :
|
|
109
|
+
device.name;
|
|
110
|
+
|
|
111
|
+
UnityEngine.Debug.Log($"{ToString()}: Input Detect Update: " + log);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/// <summary>
|
|
115
|
+
///
|
|
116
|
+
/// </summary>
|
|
117
|
+
protected virtual void UpdateSchemeUsingDevice()
|
|
118
|
+
{
|
|
119
|
+
latestDevice = device;
|
|
120
|
+
|
|
121
|
+
inputManager.SetSchemeByDevice(latestDevice);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// <summary>
|
|
125
|
+
///
|
|
126
|
+
/// </summary>
|
|
127
|
+
protected virtual void UpdateRegistryWithLatest()
|
|
128
|
+
{
|
|
129
|
+
if (SchemeRegistered())
|
|
130
|
+
UpdateScheme();
|
|
131
|
+
else
|
|
132
|
+
RegisterScheme();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// <summary>
|
|
136
|
+
///
|
|
137
|
+
/// </summary>
|
|
138
|
+
protected virtual void UpdateScheme() => schemeDevices[inputManager.GetCurrentScheme()].Add(device.name);
|
|
139
|
+
|
|
140
|
+
/// <summary>
|
|
141
|
+
///
|
|
142
|
+
/// </summary>
|
|
143
|
+
protected virtual void RegisterScheme() =>
|
|
144
|
+
schemeDevices.Add(inputManager.GetCurrentScheme(), new List<string>() { device.name });
|
|
145
|
+
}
|
|
146
146
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: c161be8ecfd9f584d875b14094e10917
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: c161be8ecfd9f584d875b14094e10917
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/package.json
CHANGED
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "net.dreditor.input",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"displayName": "DREditor Input",
|
|
5
|
-
"description": "The beta for DREditor. A tool to create death game style projects without having to code.",
|
|
6
|
-
"unity": "6000.4",
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"com.unity.inputsystem": "1.19.0",
|
|
9
|
-
"net.dreditor.core": "0.1.
|
|
10
|
-
},
|
|
11
|
-
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
13
|
-
},
|
|
14
|
-
"author": {
|
|
15
|
-
"name": "Benjamin \"Sweden\" Jillson",
|
|
16
|
-
"email": "dreditortool@gmail.com",
|
|
17
|
-
"url": "https://dreditor.net"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"editor",
|
|
21
|
-
"tool",
|
|
22
|
-
"dreditor"
|
|
23
|
-
],
|
|
24
|
-
"samples": [
|
|
25
|
-
{
|
|
26
|
-
"displayName": "Samples",
|
|
27
|
-
"description": "",
|
|
28
|
-
"path": "Samples~"
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"documentationUrl": "https://dreditor.net",
|
|
32
|
-
"license": "Apache-2.0",
|
|
33
|
-
"licensesUrl": "https://dreditor.net/docs/LICENSE.html",
|
|
34
|
-
"changelogUrl": "https://dreditor.net/docs/CHANGELOG.html"
|
|
35
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "net.dreditor.input",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"displayName": "DREditor Input",
|
|
5
|
+
"description": "The beta for DREditor. A tool to create death game style projects without having to code.",
|
|
6
|
+
"unity": "6000.4",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"com.unity.inputsystem": "1.19.0",
|
|
9
|
+
"net.dreditor.core": "0.1.7"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Benjamin \"Sweden\" Jillson",
|
|
16
|
+
"email": "dreditortool@gmail.com",
|
|
17
|
+
"url": "https://dreditor.net"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"editor",
|
|
21
|
+
"tool",
|
|
22
|
+
"dreditor"
|
|
23
|
+
],
|
|
24
|
+
"samples": [
|
|
25
|
+
{
|
|
26
|
+
"displayName": "Samples",
|
|
27
|
+
"description": "",
|
|
28
|
+
"path": "Samples~"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"documentationUrl": "https://dreditor.net",
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"licensesUrl": "https://dreditor.net/docs/LICENSE.html",
|
|
34
|
+
"changelogUrl": "https://dreditor.net/docs/CHANGELOG.html",
|
|
35
|
+
"repository": {
|
|
36
|
+
"url": "https://github.com/CertifiedSharp/DREditor",
|
|
37
|
+
"type": "git",
|
|
38
|
+
"revision": "14ca252fbb33eb6f53557ecaed1c10902877698f"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json.meta
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 65a94664771f0af4abe37899f130286c
|
|
3
|
-
TextScriptImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
userData:
|
|
6
|
-
assetBundleName:
|
|
7
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 65a94664771f0af4abe37899f130286c
|
|
3
|
+
TextScriptImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
userData:
|
|
6
|
+
assetBundleName:
|
|
7
|
+
assetBundleVariant:
|