-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,7 @@ Extract the zip and add a reference to the dll file of the mod in Visual Studio | |
- Create a **subclass of `LcInputActions`** | ||
- An instance of this class will contain all `InputAction`s your mod wishes to bind inputs for | ||
- Name the class appropriately | ||
- **Create instance properties** for all desired `InputActions` | ||
- **Annotate** the instance properties with the `[InputAction(...)]` annotation | ||
- Create InputActions [using Attributes](#using-attributes) or [at Runtime](#at-runtime) | ||
|
||
```csharp | ||
public class MyExampleInputClass : LcInputActions | ||
|
@@ -34,6 +33,10 @@ public class MyExampleInputClass : LcInputActions | |
} | ||
``` | ||
|
||
### Using Attributes | ||
- **Create instance properties** for all desired `InputActions` | ||
- **Annotate** the instance properties with the `[InputAction(...)]` annotation | ||
|
||
> [!IMPORTANT] | ||
> For actions to be registered to the API, **Properties MUST be annotated with `[InputAction(...)]`** | ||
>```csharp | ||
|
@@ -66,6 +69,34 @@ public InputAction ExplodeKey { get; set; } | |
> [!NOTE] | ||
> In this case above the Hold Interaction is being used. This keybind triggers after being held for *5* seconds. See [Interactions Docs](https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.InputSystem.Interactions.html) | ||
### At Runtime | ||
- **Override Method** `void CreateInputActions(in InputActionMapBuilder builder)` | ||
- Use the builder to create InputActions | ||
- **Reference InputAction** by calling `Asset["actionId"]` in your class | ||
> [!IMPORTANT] | ||
> Make sure you call `Finish()` after you're done creating each InputAction. | ||
Here's an example usage of the runtime api | ||
```csharp | ||
public class MyExampleInputClass : LcInputActions | ||
{ | ||
public static readonly MyExampleInputClass Instance = new(); | ||
public InputAction ExplodeKey => Asset["explodekey"]; | ||
public override void CreateInputActions(in InputActionMapBuilder builder) | ||
{ | ||
builder.NewActionBinding() | ||
.WithActionId("explodekey") | ||
.WithActionType(InputActionType.Button) | ||
.WithKbmPath("<Keyboard>/j") | ||
.WithBindingName("Explode") | ||
.Finish(); | ||
} | ||
} | ||
``` | ||
### Referencing Your Binds | ||
To use your InputActions class, you need to instantiate it. | ||
|