From fe2ed6c7ce5804b5ad80f4533e6a00203eb81bf5 Mon Sep 17 00:00:00 2001 From: Tima Zhum Date: Mon, 17 Apr 2017 20:00:24 +0600 Subject: [PATCH] Added a floating joystick (appears in a tap position) --- .../FloatingJoystick/FloatingJoystick.png | Bin 0 -> 8278 bytes .../FloatingJoystick.png.meta | 100 +++++++ .../FloatingJoystick/FloatingJoystick.unity | Bin 0 -> 34700 bytes .../FloatingJoystick.unity.meta | 8 + .../FloatingJoystick/FloatingJoystickTest.cs | 28 ++ .../FloatingJoystickTest.cs.meta | 12 + Examples/FloatingJoystick/README.txt | 10 + .../FloatingJoystick/FloatingJoystick.cs | 246 ++++++++++++++++++ .../FloatingJoystick/FloatingJoystick.cs.meta | 12 + .../FloatingJoystick/FloatingJoystickArea.cs | 54 ++++ .../FloatingJoystickArea.cs.meta | 12 + 11 files changed, 482 insertions(+) create mode 100755 Examples/FloatingJoystick/FloatingJoystick.png create mode 100644 Examples/FloatingJoystick/FloatingJoystick.png.meta create mode 100644 Examples/FloatingJoystick/FloatingJoystick.unity create mode 100644 Examples/FloatingJoystick/FloatingJoystick.unity.meta create mode 100644 Examples/FloatingJoystick/FloatingJoystickTest.cs create mode 100644 Examples/FloatingJoystick/FloatingJoystickTest.cs.meta create mode 100644 Examples/FloatingJoystick/README.txt create mode 100644 Scripts/Controls/FloatingJoystick/FloatingJoystick.cs create mode 100644 Scripts/Controls/FloatingJoystick/FloatingJoystick.cs.meta create mode 100644 Scripts/Controls/FloatingJoystick/FloatingJoystickArea.cs create mode 100644 Scripts/Controls/FloatingJoystick/FloatingJoystickArea.cs.meta diff --git a/Examples/FloatingJoystick/FloatingJoystick.png b/Examples/FloatingJoystick/FloatingJoystick.png new file mode 100755 index 0000000000000000000000000000000000000000..0a4df1dd80fe8588d5fc5c90a979dbcdcaee6ef7 GIT binary patch literal 8278 zcmaJ`cRbr&+y5nkpn_VpgWhKCh{TLqRkgLM_6Sm9kJzzFYgLCmYjv6}wP&f?v?w)O zqeW4**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@P~KDiYs46+UW@CqG3s6_Of^ojIKHWq?RN9saq|~O3uhTmQe0h0@g{!1y87@A ULv_4|U5Ef$PUnT~kJ?fH7u@wm2mk;8 literal 0 HcmV?d00001 diff --git a/Examples/FloatingJoystick/FloatingJoystick.unity.meta b/Examples/FloatingJoystick/FloatingJoystick.unity.meta new file mode 100644 index 0000000..985f36e --- /dev/null +++ b/Examples/FloatingJoystick/FloatingJoystick.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ae0e7a710bb34986a2cf96fc5918c33 +timeCreated: 1492422996 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Examples/FloatingJoystick/FloatingJoystickTest.cs b/Examples/FloatingJoystick/FloatingJoystickTest.cs new file mode 100644 index 0000000..1b7672b --- /dev/null +++ b/Examples/FloatingJoystick/FloatingJoystickTest.cs @@ -0,0 +1,28 @@ +/// Credit Tima Zhum + +using UnityEngine; + +#if CROSS_PLATFORM_INPUT +using UnityStandardAssets.CrossPlatformInput; +#endif + +namespace UnityEngine.UI.Extensions +{ + public class FloatingJoystickTest: MonoBehaviour + { + #if CROSS_PLATFORM_INPUT + + /// + /// Update this instance + /// + void Update() + { + float _horizontalAxis = CrossPlatformInputManager.GetAxis("Horizontal"); + float _verticalAxis = CrossPlatformInputManager.GetAxis("Vertical"); + + transform.position += 5f * (Vector3.right * _horizontalAxis + Vector3.up * _verticalAxis); + } + + #endif + } +} diff --git a/Examples/FloatingJoystick/FloatingJoystickTest.cs.meta b/Examples/FloatingJoystick/FloatingJoystickTest.cs.meta new file mode 100644 index 0000000..c05e754 --- /dev/null +++ b/Examples/FloatingJoystick/FloatingJoystickTest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dfff1a99ac1fc4ce99fa98f9ab61f79c +timeCreated: 1492424357 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Examples/FloatingJoystick/README.txt b/Examples/FloatingJoystick/README.txt new file mode 100644 index 0000000..424ddab --- /dev/null +++ b/Examples/FloatingJoystick/README.txt @@ -0,0 +1,10 @@ +Getting started with a floating joystick + +1. Open a FloatingJoystick scene +2. Import Unity Standard Assets/Cross Platfrom Input +- Assets -> Import Package -> CrossPlatformInput +3. Add scripting define symbols +- Edit -> Project Settings -> Player -> Other Settings -> Scripting Define symbols +- Add "CROSS_PLATFORM_INPUT;MOBILE_INPUT" (probably, there will be only "CROSS_PLATFORM_INPUT") +- Press Enter to submit changes (!important) +4. Play the scene \ No newline at end of file diff --git a/Scripts/Controls/FloatingJoystick/FloatingJoystick.cs b/Scripts/Controls/FloatingJoystick/FloatingJoystick.cs new file mode 100644 index 0000000..3510a28 --- /dev/null +++ b/Scripts/Controls/FloatingJoystick/FloatingJoystick.cs @@ -0,0 +1,246 @@ +/// Credit Tima Zhum +/// Based on Joystick.cs from Unity Standard Assets/Cross Platform Input + +using UnityEngine.EventSystems; + +#if CROSS_PLATFORM_INPUT +using UnityStandardAssets.CrossPlatformInput; +#endif + +namespace UnityEngine.UI.Extensions +{ + [RequireComponent(typeof(Image))] + [AddComponentMenu("Scripts/UnityEngine.UI.Extensions/FloatingJoystick")] + public class FloatingJoystick: MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler + { + /// + /// The joystick base point image + /// + [Tooltip("Pivot of a joystick (not required)")] + [SerializeField] private Image _joystickBasePoint = null; + + #if CROSS_PLATFORM_INPUT + + /// + /// The joystick image + /// + private Image _joystickImage = null; + + /// + /// The joystick enabled state + /// + private bool _joystickEnabled = false; + + /// + /// The previous joystick enabled state + /// + private bool _joystickPreviouslyEnabled = false; + + /// + /// The last point event data + /// + private PointerEventData _pedLast = null; + + /// + /// Start this instance + /// + protected void Awake() + { + _joystickImage = GetComponent(); + } + + /// + /// Update this instance + /// + protected void Update() + { + if (_joystickImage) _joystickImage.enabled = _joystickEnabled; + if (_joystickBasePoint) _joystickBasePoint.enabled = _joystickEnabled; + + if (_joystickEnabled) + { + if (!_joystickPreviouslyEnabled) + { + Vector3 _position = _pedLast.position; + ReinitializeAt(_position); + if (_joystickBasePoint) _joystickBasePoint.transform.position = _position; + } + } + + _joystickPreviouslyEnabled = _joystickEnabled; + } + + /// + /// Raises the pointer down event + /// + /// Ped + public void OnPointerDownHelper(PointerEventData _ped) + { + OnPointerDown(_ped); + _joystickEnabled = true; + _pedLast = _ped; + } + + /// + /// Raises the pointer up event + /// + /// Ped + public void OnPointerUpHelper(PointerEventData _ped) + { + OnPointerUp(_ped); + _joystickEnabled = false; + _pedLast = _ped; + } + + /// + /// Raises the drag event + /// + /// Ped + public void OnDragHelper(PointerEventData _ped) + { + OnDrag(_ped); + _pedLast = _ped; + } + + /// + /// Reinitializes the joystick at specific position + /// + /// Position + public void ReinitializeAt(Vector3 _position) + { + transform.position = _position; + Start(); + OnDisable(); + OnEnable(); + } + + #region STANDARDASSETSCODE + + /* + * This is a copy of the Joystick.cs script from Unity Standard Assets/Cross Platform Input + * The reason of copying: original script is not designed for inheriting (required for extending the functionalities) + */ + + public enum AxisOption + { + // Options for which axes to use + Both, // Use both + OnlyHorizontal, // Only horizontal + OnlyVertical // Only vertical + } + + private int InitialMovementRange; + public int MovementRange = 100; + public AxisOption axesToUse = AxisOption.Both; // The options for the axes that the still will use + public string horizontalAxisName = "Horizontal"; // The name given to the horizontal axis for the cross platform input + public string verticalAxisName = "Vertical"; // The name given to the vertical axis for the cross platform input + + Vector3 m_StartPos; + bool m_UseX; // Toggle for using the x axis + bool m_UseY; // Toggle for using the Y axis + CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis; // Reference to the joystick in the cross platform input + CrossPlatformInputManager.VirtualAxis m_VerticalVirtualAxis; // Reference to the joystick in the cross platform input + + + void OnEnable() + { + CreateVirtualAxes(); + } + + void Start() + { + m_StartPos = transform.position; + } + + void UpdateVirtualAxes(Vector3 value) + { + var delta = m_StartPos - value; + delta.y = -delta.y; + delta /= MovementRange; + if (m_UseX) + { + m_HorizontalVirtualAxis.Update(-delta.x); + } + + if (m_UseY) + { + m_VerticalVirtualAxis.Update(delta.y); + } + } + + void CreateVirtualAxes() + { + // set axes to use + m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal); + m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical); + + // create new axes based on axes to use + if (m_UseX) + { + m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName); + CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis); + } + if (m_UseY) + { + m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName); + CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis); + } + } + + + public void OnDrag(PointerEventData data) + { + Vector3 newPos = Vector3.zero; + + if (m_UseX) + { + int delta = (int)(data.position.x - m_StartPos.x); + delta = Mathf.Clamp(delta, - MovementRange, MovementRange); + newPos.x = delta; + } + + if (m_UseY) + { + int delta = (int)(data.position.y - m_StartPos.y); + delta = Mathf.Clamp(delta, -MovementRange, MovementRange); + newPos.y = delta; + } + + transform.position = new Vector3(m_StartPos.x + newPos.x, m_StartPos.y + newPos.y, m_StartPos.z + newPos.z); + UpdateVirtualAxes(transform.position); + } + + + public void OnPointerUp(PointerEventData data) + { + transform.position = m_StartPos; + UpdateVirtualAxes(m_StartPos); + } + + + public void OnPointerDown(PointerEventData data) { } + + void OnDisable() + { + // remove the joysticks from the cross platform input + if (m_UseX) + { + m_HorizontalVirtualAxis.Remove(); + } + if (m_UseY) + { + m_VerticalVirtualAxis.Remove(); + } + } + + #endregion + + #else + + public void OnDrag(PointerEventData data) {} + public void OnPointerUp(PointerEventData data) {} + public void OnPointerDown(PointerEventData data) {} + + #endif + } +} \ No newline at end of file diff --git a/Scripts/Controls/FloatingJoystick/FloatingJoystick.cs.meta b/Scripts/Controls/FloatingJoystick/FloatingJoystick.cs.meta new file mode 100644 index 0000000..e85b22a --- /dev/null +++ b/Scripts/Controls/FloatingJoystick/FloatingJoystick.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 54466c9d22a444d8d8e90e8d9ab83faa +timeCreated: 1492420430 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Controls/FloatingJoystick/FloatingJoystickArea.cs b/Scripts/Controls/FloatingJoystick/FloatingJoystickArea.cs new file mode 100644 index 0000000..864ac11 --- /dev/null +++ b/Scripts/Controls/FloatingJoystick/FloatingJoystickArea.cs @@ -0,0 +1,54 @@ +/// Credit Tima Zhum + +using UnityEngine.EventSystems; + +namespace UnityEngine.UI.Extensions +{ + [RequireComponent(typeof(Image))] + [AddComponentMenu("Scripts/UnityEngine.UI.Extensions/FloatingJoystickArea")] + public class FloatingJoystickArea: MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler + { + /// + /// The floating joystick controller + /// + [Tooltip("The floating joystick that should appear in the area on tap")] + [SerializeField] private FloatingJoystick _floatingJoystick = null; + + #if CROSS_PLATFORM_INPUT + + /// + /// Raises the pointer down event + /// + /// Ped + public void OnPointerDown(PointerEventData _ped) + { + if (_floatingJoystick) _floatingJoystick.OnPointerDownHelper(_ped); + } + + /// + /// Raises the pointer up event + /// + /// Ped + public void OnPointerUp(PointerEventData _ped) + { + if (_floatingJoystick) _floatingJoystick.OnPointerUpHelper(_ped); + } + + /// + /// Raises the drag event + /// + /// Ped + public void OnDrag(PointerEventData _ped) + { + if (_floatingJoystick) _floatingJoystick.OnDragHelper(_ped); + } + + #else + + public void OnDrag(PointerEventData data) {} + public void OnPointerUp(PointerEventData data) {} + public void OnPointerDown(PointerEventData data) {} + + #endif + } +} \ No newline at end of file diff --git a/Scripts/Controls/FloatingJoystick/FloatingJoystickArea.cs.meta b/Scripts/Controls/FloatingJoystick/FloatingJoystickArea.cs.meta new file mode 100644 index 0000000..a896f60 --- /dev/null +++ b/Scripts/Controls/FloatingJoystick/FloatingJoystickArea.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4b85a1b054bce497cbe13cf45ea6d7fc +timeCreated: 1492420430 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: