joystick pack assets 추가
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(DynamicJoystick))]
|
||||
public class DynamicJoystickEditor : JoystickEditor
|
||||
{
|
||||
private SerializedProperty moveThreshold;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
moveThreshold = serializedObject.FindProperty("moveThreshold");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (background != null)
|
||||
{
|
||||
RectTransform backgroundRect = (RectTransform)background.objectReferenceValue;
|
||||
backgroundRect.anchorMax = Vector2.zero;
|
||||
backgroundRect.anchorMin = Vector2.zero;
|
||||
backgroundRect.pivot = center;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DrawValues()
|
||||
{
|
||||
base.DrawValues();
|
||||
EditorGUILayout.PropertyField(moveThreshold, new GUIContent("Move Threshold", "The distance away from the center input has to be before the joystick begins to move."));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52071c88a467b46438b3cbf159bf988b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(FloatingJoystick))]
|
||||
public class FloatingJoystickEditor : JoystickEditor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (background != null)
|
||||
{
|
||||
RectTransform backgroundRect = (RectTransform)background.objectReferenceValue;
|
||||
backgroundRect.anchorMax = Vector2.zero;
|
||||
backgroundRect.anchorMin = Vector2.zero;
|
||||
backgroundRect.pivot = center;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 614d06243900d764f9c50b4da2c950a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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."));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4b2b0d911a01a64ebfca9918e2b90b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(VariableJoystick))]
|
||||
public class VariableJoystickEditor : JoystickEditor
|
||||
{
|
||||
private SerializedProperty moveThreshold;
|
||||
private SerializedProperty joystickType;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
moveThreshold = serializedObject.FindProperty("moveThreshold");
|
||||
joystickType = serializedObject.FindProperty("joystickType");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (background != null)
|
||||
{
|
||||
RectTransform backgroundRect = (RectTransform)background.objectReferenceValue;
|
||||
backgroundRect.pivot = center;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DrawValues()
|
||||
{
|
||||
base.DrawValues();
|
||||
EditorGUILayout.PropertyField(moveThreshold, new GUIContent("Move Threshold", "The distance away from the center input has to be before the joystick begins to move."));
|
||||
EditorGUILayout.PropertyField(joystickType, new GUIContent("Joystick Type", "The type of joystick the variable joystick is current using."));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58b5a2db95af76c4c9d4116a09ec3697
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user