Skip to content

Commit 822e4f3

Browse files
committed
feat(Locomotion): add unity event helper for slingshot jump
The Slingshot Jumpt script now has a Unity Event Helper script to allow for unity events to be used in place of C# delegates.
1 parent c00d177 commit 822e4f3

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

Assets/VRTK/Documentation/API.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,6 +2519,12 @@ Provides the ability for the SDK Camera Rig to be thrown around with a jumping m
25192519

25202520
* `SlingshotJumped` - Emitted when a slingshot jump occurs
25212521

2522+
### Unity Events
2523+
2524+
Adding the `VRTK_SlingshotJump_UnityEvents` component to `VRTK_SlingshotJump` object allows access to `UnityEvents` that will react identically to the Class Events.
2525+
2526+
* All C# delegate events are mapped to a Unity Event with the `On` prefix. e.g. `MyEvent` -> `OnMyEvent`.
2527+
25222528
### Class Methods
25232529

25242530
#### GetActivationButton/0
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace VRTK.UnityEventHelper
2+
{
3+
using UnityEngine;
4+
using UnityEngine.Events;
5+
using System;
6+
7+
[AddComponentMenu("VRTK/Scripts/Utilities/Unity Events/VRTK_SlingshotJump_UnityEvents")]
8+
public sealed class VRTK_SlingshotJump_UnityEvents : VRTK_UnityEvents<VRTK_SlingshotJump>
9+
{
10+
[Serializable]
11+
public sealed class SlingshotJumpEvent : UnityEvent<object> { }
12+
13+
public SlingshotJumpEvent OnSlingshotJumped = new SlingshotJumpEvent();
14+
15+
protected override void AddListeners(VRTK_SlingshotJump component)
16+
{
17+
component.SlingshotJumped += SlingshotJumped;
18+
}
19+
20+
protected override void RemoveListeners(VRTK_SlingshotJump component)
21+
{
22+
component.SlingshotJumped -= SlingshotJumped;
23+
}
24+
25+
private void SlingshotJumped(object o)
26+
{
27+
OnSlingshotJumped.Invoke(o);
28+
}
29+
}
30+
}

Assets/VRTK/Source/Scripts/Utilities/UnityEvents/VRTK_SlingshotJump_UnityEvents.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)