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/Scripts/Editor/JoystickEditor.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/Scripts/Editor/JoystickEditor.cs')
| -rw-r--r-- | Assets/Thirdparty/Joystick Pack/Scripts/Editor/JoystickEditor.cs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Assets/Thirdparty/Joystick Pack/Scripts/Editor/JoystickEditor.cs b/Assets/Thirdparty/Joystick Pack/Scripts/Editor/JoystickEditor.cs new file mode 100644 index 0000000..782c9f3 --- /dev/null +++ b/Assets/Thirdparty/Joystick Pack/Scripts/Editor/JoystickEditor.cs @@ -0,0 +1,64 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEditor;
+
+[CustomEditor(typeof(Joystick), true)]
+public class JoystickEditor : Editor
+{
+ private SerializedProperty handleRange;
+ private SerializedProperty deadZone;
+ private SerializedProperty axisOptions;
+ private SerializedProperty snapX;
+ private SerializedProperty snapY;
+ protected SerializedProperty background;
+ private SerializedProperty handle;
+
+ protected Vector2 center = new Vector2(0.5f, 0.5f);
+
+ protected virtual void OnEnable()
+ {
+ handleRange = serializedObject.FindProperty("handleRange");
+ deadZone = serializedObject.FindProperty("deadZone");
+ axisOptions = serializedObject.FindProperty("axisOptions");
+ snapX = serializedObject.FindProperty("snapX");
+ snapY = serializedObject.FindProperty("snapY");
+ background = serializedObject.FindProperty("background");
+ handle = serializedObject.FindProperty("handle");
+ }
+
+ public override void OnInspectorGUI()
+ {
+ serializedObject.Update();
+
+ DrawValues();
+ EditorGUILayout.Space();
+ DrawComponents();
+
+ serializedObject.ApplyModifiedProperties();
+
+ if(handle != null)
+ {
+ RectTransform handleRect = (RectTransform)handle.objectReferenceValue;
+ handleRect.anchorMax = center;
+ handleRect.anchorMin = center;
+ handleRect.pivot = center;
+ handleRect.anchoredPosition = Vector2.zero;
+ }
+ }
+
+ protected virtual void DrawValues()
+ {
+ EditorGUILayout.PropertyField(handleRange, new GUIContent("Handle Range", "The distance the visual handle can move from the center of the joystick."));
+ EditorGUILayout.PropertyField(deadZone, new GUIContent("Dead Zone", "The distance away from the center input has to be before registering."));
+ EditorGUILayout.PropertyField(axisOptions, new GUIContent("Axis Options", "Which axes the joystick uses."));
+ EditorGUILayout.PropertyField(snapX, new GUIContent("Snap X", "Snap the horizontal input to a whole value."));
+ EditorGUILayout.PropertyField(snapY, new GUIContent("Snap Y", "Snap the vertical input to a whole value."));
+ }
+
+ protected virtual void DrawComponents()
+ {
+ EditorGUILayout.ObjectField(background, new GUIContent("Background", "The background's RectTransform component."));
+ EditorGUILayout.ObjectField(handle, new GUIContent("Handle", "The handle's RectTransform component."));
+ }
+}
\ No newline at end of file |
