Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1df22b4

Browse files
authoredMay 7, 2021
chore: added docu for the new input system
1 parent 97124f2 commit 1df22b4

File tree

4 files changed

+95
-2
lines changed

4 files changed

+95
-2
lines changed
 

‎.Documentation/articles/developer/11-lockable-properties.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ public override IEnumerable<LockablePropertyData> GetLockableProperties()
7171
}
7272
```
7373

74-
[To the next chapter!](12-text-to-speech.md)
74+
[To the next chapter!](input-system.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Input System
2+
3+
The input system within the Innoactive Creator is implemented similar to Unity's Input System (new) and adds an additional abstraction layer. This allows template developers to implement their own input handling. The default one used in the Creator is based on the Unity Input System.
4+
5+
## Edit Key bindings
6+
To edit your key bindings go to the Creator Settings > Spectator and click _Edit key bindings_.
7+
8+
## To implement your own actions for your MonoBehavior, follow these steps:
9+
1. Instead of extending MonoBehavior, extend InputActionListener
10+
```
11+
public class SpectatorController : InputActionListener
12+
```
13+
2. Add methods which are named after the event name you want to listen to
14+
```
15+
protected virtual void SetToTrainee(InputController.InputEventArgs args)
16+
{
17+
SetToSpecificCamera(traineeCamera);
18+
}
19+
```
20+
21+
3. Call the RegisterInputEvent/UnregisterInputEvent in OnEnable/OnDisable
22+
```
23+
protected new void OnEnable()
24+
{
25+
base.OnEnable();
26+
RegisterInputEvent(SetToTrainee);
27+
}
28+
29+
protected new void OnDisable()
30+
{
31+
UnregisterInputEvent(SetToTrainee);
32+
base.OnDisable();
33+
}
34+
```
35+
4. Add the action to your custom key bindings, which should be under Assets/Resources/KeyBindings/CreatorCustomKeyBindings
36+
37+
![Key Bindings menu](../images/input-system/keybindings.png)
38+
39+
5. If you want to overwrite the default bindings you will have to extend the BaseRuntimeConfiguration, overwriting the DefaultInputActionAssetPath and CustomInputActionAssetPath property.
40+
41+
## Set Focus / Disable Key bindings
42+
43+
The InputController allows to focus a specific listener, which is for example required to limit the input during text input in a text field or browser. A specific focus target can be set by calling `void Focus(IInputFocus target)` and also released via `void ReleaseFocus()`. Setting a specific focus has two effects:
44+
45+
1. All events generated by the InputController will only be sent to the focused target
46+
2. If the `IInputFocus` implementation does define a specific action map, this action map will be set active.
47+
48+
For example, if we want to ignore all input actions (to not accidentally call any UI actions) while the trainee has to work within a browser we can create a new `LockableProperty` which is also an `IInputFocus`. In the case of the Desktop Mode the focus handling is done automatically, in VR we would still have to set the focus. After setting the focus to this script, the new ActionMap would be set active, which is missing any actions we dont want to allow. In result no input will trigger any UI actions until the browser is unfocused again.
49+
50+
```
51+
using Innoactive.Creator.Core.Input;
52+
using Innoactive.Creator.Core.Properties;
53+
using UnityEngine;
54+
55+
/// <summary>
56+
/// Can be used to focus a ZFBrowser, will lock down all keyboard input besides the browser itself.
57+
/// To interact with the browser this property has to be unlocked in the according step.
58+
///
59+
/// <remarks>You also have to create a new action map in your input controlls which is named "FocusKeyboard".</remarks>
60+
/// </summary>
61+
public class ZFBrowserProperty : LockableProperty, IInputFocus
62+
{
63+
public string ActionMapName { get; } = "FocusKeyboard";
64+
65+
public bool CanBeFocused => IsLocked == false;
66+
67+
public void OnFocus()
68+
{
69+
// Highlight that the browser is selected.
70+
}
71+
72+
public void OnReleaseFocus()
73+
{
74+
// Remove highlight.
75+
}
76+
77+
protected override void InternalSetLocked(bool lockState)
78+
{
79+
// Without active collider no interaction possible.
80+
foreach (Collider collider in GetComponents<Collider>())
81+
{
82+
collider.enabled = !lockState;
83+
}
84+
}
85+
}
86+
```
87+
88+
[To the next chapter!](12-text-to-speech.md)
Loading

‎.Documentation/articles/toc.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
- name: Properties
8383
href: developer/10-properties.md
8484
- name: Lockable Properties
85-
href: developer/11-lockable-properties.md
85+
href: developer/11-lockable-properties.md
86+
- name: Input System
87+
href: developer/input-system.md
8688
- name: Text-To-Speech
8789
href: developer/12-text-to-speech.md
8890
- name: Dependency Manager

0 commit comments

Comments
 (0)
This repository has been archived.