From 97da432c35b8c7aaf9dd2c39e2aa4b1f55f36065 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Jan 2021 16:15:06 +0800 Subject: +behaviour designer --- .../Runtime/Basic Tasks/Input/GetAxis.cs | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Client/Assets/Behavior Designer/Runtime/Basic Tasks/Input/GetAxis.cs (limited to 'Client/Assets/Behavior Designer/Runtime/Basic Tasks/Input/GetAxis.cs') diff --git a/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Input/GetAxis.cs b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Input/GetAxis.cs new file mode 100644 index 00000000..64dfc476 --- /dev/null +++ b/Client/Assets/Behavior Designer/Runtime/Basic Tasks/Input/GetAxis.cs @@ -0,0 +1,45 @@ +using UnityEngine; +#if CROSS_PLATFORM_INPUT +using UnityStandardAssets.CrossPlatformInput; +#endif + + +namespace BehaviorDesigner.Runtime.Tasks.Basic.UnityInput +{ + [TaskCategory("Basic/Input")] + [TaskDescription("Stores the value of the specified axis and stores it in a float.")] + public class GetAxis : 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.GetAxis(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; + } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0