diff options
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 |
