blob: 4f3e89169734c36f93ec24135666ea019dbdd458 (
plain)
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
|
using UnityEngine;
#if CROSS_PLATFORM_INPUT
using UnityStandardAssets.CrossPlatformInput;
#endif
namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityInput
{
[TaskCategory("Basic/Input")]
[TaskDescription("Stores the raw value of the specified axis and stores it in a float.")]
public class GetAxisRaw : Action
{
[Tooltip("The name of the axis")]
public SharedString axisName;
[Tooltip("Axis values are in the range -1 to 1. Use the multiplier to set a larger range")]
public SharedFloat multiplier;
[RequiredField]
[Tooltip("The stored result")]
public SharedFloat storeResult;
public override TaskStatus OnUpdate()
{
#if CROSS_PLATFORM_INPUT
var axisValue = CrossPlatformInputManager.GetAxisRaw(axisName.Value);
#else
var axisValue = Input.GetAxis(axisName.Value);
#endif
// if variable set to none, assume multiplier of 1
if (!multiplier.IsNone) {
axisValue *= multiplier.Value;
}
storeResult.Value = axisValue;
return TaskStatus.Success;
}
public override void OnReset()
{
axisName = "";
multiplier = 1.0f;
storeResult = 0;
}
}
}
|