diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-08-20 23:40:50 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-08-20 23:40:50 -0400 |
| commit | 3af4c218c0e70167db23a6303d2af30aff37d2fe (patch) | |
| tree | 927f29edcf54ab562f40f3d1c6cb69287c7f5980 /Assets/Thirdparty/Joystick Pack/Examples/JoystickSetterExample.cs | |
| parent | b6daed0af784f4e9bc13329dd87c671b06ee1c65 (diff) | |
| download | Project-Sandbox-3af4c218c0e70167db23a6303d2af30aff37d2fe.tar.gz Project-Sandbox-3af4c218c0e70167db23a6303d2af30aff37d2fe.tar.bz2 Project-Sandbox-3af4c218c0e70167db23a6303d2af30aff37d2fe.zip | |
Removed a bunch of stuff; Changes
Diffstat (limited to 'Assets/Thirdparty/Joystick Pack/Examples/JoystickSetterExample.cs')
| -rw-r--r-- | Assets/Thirdparty/Joystick Pack/Examples/JoystickSetterExample.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Assets/Thirdparty/Joystick Pack/Examples/JoystickSetterExample.cs b/Assets/Thirdparty/Joystick Pack/Examples/JoystickSetterExample.cs new file mode 100644 index 0000000..0a22e47 --- /dev/null +++ b/Assets/Thirdparty/Joystick Pack/Examples/JoystickSetterExample.cs @@ -0,0 +1,66 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class JoystickSetterExample : MonoBehaviour
+{
+ public VariableJoystick variableJoystick;
+ public Text valueText;
+ public Image background;
+ public Sprite[] axisSprites;
+
+ public void ModeChanged(int index)
+ {
+ switch(index)
+ {
+ case 0:
+ variableJoystick.SetMode(JoystickType.Fixed);
+ break;
+ case 1:
+ variableJoystick.SetMode(JoystickType.Floating);
+ break;
+ case 2:
+ variableJoystick.SetMode(JoystickType.Dynamic);
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void AxisChanged(int index)
+ {
+ switch (index)
+ {
+ case 0:
+ variableJoystick.AxisOptions = AxisOptions.Both;
+ background.sprite = axisSprites[index];
+ break;
+ case 1:
+ variableJoystick.AxisOptions = AxisOptions.Horizontal;
+ background.sprite = axisSprites[index];
+ break;
+ case 2:
+ variableJoystick.AxisOptions = AxisOptions.Vertical;
+ background.sprite = axisSprites[index];
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void SnapX(bool value)
+ {
+ variableJoystick.SnapX = value;
+ }
+
+ public void SnapY(bool value)
+ {
+ variableJoystick.SnapY = value;
+ }
+
+ private void Update()
+ {
+ valueText.text = "Current Value: " + variableJoystick.Direction;
+ }
+}
\ No newline at end of file |
