diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Base/Joystick.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Base/Joystick.cs index e19633d0..02771b97 100644 --- a/Assets/LoadedAssets/Joystick Pack/Scripts/Base/Joystick.cs +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Base/Joystick.cs @@ -35,7 +35,8 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint [SerializeField] private bool snapY = false; [SerializeField] protected RectTransform background = null; - [SerializeField] private RectTransform handle = null; + [SerializeField] protected RectTransform handle = null; + private RectTransform baseRect = null; private Canvas canvas; diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/DynamicJoystickEditor.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/DynamicJoystickEditor.cs index 1da7f723..48033947 100644 --- a/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/DynamicJoystickEditor.cs +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/DynamicJoystickEditor.cs @@ -1,10 +1,9 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using LoadedAssets.Joystick_Pack.Scripts.Editor; using UnityEditor; +using UnityEngine; [CustomEditor(typeof(DynamicJoystick))] -public class DynamicJoystickEditor : JoystickEditor +public class DynamicJoystickEditor : OpacityJoystickEditor { private SerializedProperty moveThreshold; diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/FloatingJoystickEditor.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/FloatingJoystickEditor.cs index a9b079c7..bdd06014 100644 --- a/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/FloatingJoystickEditor.cs +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/FloatingJoystickEditor.cs @@ -1,10 +1,9 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using LoadedAssets.Joystick_Pack.Scripts.Editor; using UnityEditor; +using UnityEngine; [CustomEditor(typeof(FloatingJoystick))] -public class FloatingJoystickEditor : JoystickEditor +public class FloatingJoystickEditor : OpacityJoystickEditor { public override void OnInspectorGUI() { @@ -12,7 +11,7 @@ public class FloatingJoystickEditor : JoystickEditor if (background != null) { - RectTransform backgroundRect = (RectTransform)background.objectReferenceValue; + RectTransform backgroundRect = (RectTransform) background.objectReferenceValue; backgroundRect.anchorMax = Vector2.zero; backgroundRect.anchorMin = Vector2.zero; backgroundRect.pivot = center; diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/OpacityJoystickEditor.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/OpacityJoystickEditor.cs new file mode 100644 index 00000000..1610e810 --- /dev/null +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/OpacityJoystickEditor.cs @@ -0,0 +1,28 @@ +using LoadedAssets.Joystick_Pack.Scripts.Joysticks; +using UnityEditor; +using UnityEngine; + +namespace LoadedAssets.Joystick_Pack.Scripts.Editor +{ + [CustomEditor(typeof(OpacityJoystick), true)] + public class OpacityJoystickEditor : JoystickEditor + { + private SerializedProperty _idleStateOpacity; + private SerializedProperty _activeStateOpacity; + + protected override void OnEnable() + { + base.OnEnable(); + _idleStateOpacity = serializedObject.FindProperty("_idleStateOpacity"); + _activeStateOpacity = serializedObject.FindProperty("_activeStateOpacity"); + } + + protected override void DrawValues() + { + base.DrawValues(); + EditorGUILayout.PropertyField(_idleStateOpacity, new GUIContent("Idle State Opacity", "Joystick opacity when player doesn't touch it.")); + EditorGUILayout.PropertyField(_activeStateOpacity, new GUIContent("Active State Opacity", "Joystick opacity when player touches it.")); + } + + } +} \ No newline at end of file diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/OpacityJoystickEditor.cs.meta b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/OpacityJoystickEditor.cs.meta new file mode 100644 index 00000000..c745c75a --- /dev/null +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/OpacityJoystickEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5a2026769f544d69991c8dd5dc12399b +timeCreated: 1634048125 \ No newline at end of file diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/VariableJoystickEditor.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/VariableJoystickEditor.cs index 888e0203..3eba131d 100644 --- a/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/VariableJoystickEditor.cs +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Editor/VariableJoystickEditor.cs @@ -1,11 +1,9 @@ -using System.Collections; -using System.Collections.Generic; +using LoadedAssets.Joystick_Pack.Scripts.Editor; +using UnityEditor; using UnityEngine; -using UnityEditor; - [CustomEditor(typeof(VariableJoystick))] -public class VariableJoystickEditor : JoystickEditor +public class VariableJoystickEditor : OpacityJoystickEditor { private SerializedProperty moveThreshold; private SerializedProperty joystickType; diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/DynamicJoystick.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/DynamicJoystick.cs index 3ca48c9a..f0406f24 100644 --- a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/DynamicJoystick.cs +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/DynamicJoystick.cs @@ -1,9 +1,8 @@ -using System.Collections; -using System.Collections.Generic; +using LoadedAssets.Joystick_Pack.Scripts.Joysticks; using UnityEngine; using UnityEngine.EventSystems; -public class DynamicJoystick : Joystick +public class DynamicJoystick : OpacityJoystick { public float MoveThreshold { get { return moveThreshold; } set { moveThreshold = Mathf.Abs(value); } } @@ -13,22 +12,14 @@ public class DynamicJoystick : Joystick { MoveThreshold = moveThreshold; base.Start(); - background.gameObject.SetActive(false); } public override void OnPointerDown(PointerEventData eventData) { background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position); - background.gameObject.SetActive(true); base.OnPointerDown(eventData); } - public override void OnPointerUp(PointerEventData eventData) - { - background.gameObject.SetActive(false); - base.OnPointerUp(eventData); - } - protected override void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, Camera cam) { if (magnitude > moveThreshold) diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/FixedJoystick.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/FixedJoystick.cs index 34ffec07..5c0a0600 100644 --- a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/FixedJoystick.cs +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/FixedJoystick.cs @@ -1,8 +1,6 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using LoadedAssets.Joystick_Pack.Scripts.Joysticks; -public class FixedJoystick : Joystick +public class FixedJoystick : OpacityJoystick { } \ No newline at end of file diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/FloatingJoystick.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/FloatingJoystick.cs index ae29decf..5fcd42bc 100644 --- a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/FloatingJoystick.cs +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/FloatingJoystick.cs @@ -1,31 +1,11 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using LoadedAssets.Joystick_Pack.Scripts.Joysticks; using UnityEngine.EventSystems; -public class FloatingJoystick : Joystick +public class FloatingJoystick : OpacityJoystick { - //public Action OnTouchDown, OnTouchUp; - public bool isPressed { get; set; } - protected override void Start() - { - base.Start(); - background.gameObject.SetActive(false); - } - public override void OnPointerDown(PointerEventData eventData) { background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position); - background.gameObject.SetActive(true); base.OnPointerDown(eventData); - //OnTouchDown?.Invoke(); } - - public override void OnPointerUp(PointerEventData eventData) - { - background.gameObject.SetActive(false); - base.OnPointerUp(eventData); - //OnTouchUp?.Invoke(); - } } \ No newline at end of file diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/OpacityJoystick.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/OpacityJoystick.cs new file mode 100644 index 00000000..26820a48 --- /dev/null +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/OpacityJoystick.cs @@ -0,0 +1,62 @@ +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace LoadedAssets.Joystick_Pack.Scripts.Joysticks +{ + public class OpacityJoystick : Joystick + { + [SerializeField] private float _idleStateOpacity = 1f; + [SerializeField] private float _activeStateOpacity = 1f; + + private Image _backgroundImage; + private Image _handleImage; + + private bool _hasBackgroundImage; + private bool _hasHandleImage; + + + protected override void Start() + { + _backgroundImage = background.GetComponent(); + _handleImage = handle.GetComponent(); + + _hasBackgroundImage = _backgroundImage != null; + _hasHandleImage = _handleImage != null; + SetOpacity(_idleStateOpacity); + base.Start(); + } + + + public override void OnPointerDown(PointerEventData eventData) + { + SetOpacity(_activeStateOpacity); + base.OnPointerDown(eventData); + } + + + public override void OnPointerUp(PointerEventData eventData) + { + SetOpacity(_idleStateOpacity); + base.OnPointerUp(eventData); + } + + + private void SetOpacity(float opacity) + { + if (_hasBackgroundImage) + { + var backgroundColor = _backgroundImage.color; + backgroundColor.a = opacity; + _backgroundImage.color = backgroundColor; + } + + if (_hasHandleImage) + { + var handleColor = _handleImage.color; + handleColor.a = opacity; + _handleImage.color = handleColor; + } + } + } +} \ No newline at end of file diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/OpacityJoystick.cs.meta b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/OpacityJoystick.cs.meta new file mode 100644 index 00000000..c6214cd9 --- /dev/null +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/OpacityJoystick.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: eb73ee9cab394bc3bdcc13b1e39be28b +timeCreated: 1634045936 \ No newline at end of file diff --git a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/VariableJoystick.cs b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/VariableJoystick.cs index fdd23150..f9ff0ffa 100644 --- a/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/VariableJoystick.cs +++ b/Assets/LoadedAssets/Joystick Pack/Scripts/Joysticks/VariableJoystick.cs @@ -1,9 +1,8 @@ -using System.Collections; -using System.Collections.Generic; +using LoadedAssets.Joystick_Pack.Scripts.Joysticks; using UnityEngine; using UnityEngine.EventSystems; -public class VariableJoystick : Joystick +public class VariableJoystick : OpacityJoystick { public float MoveThreshold { get { return moveThreshold; } set { moveThreshold = Mathf.Abs(value); } } diff --git a/Assets/Prefabs_NEW/UI/GameCanvas.prefab b/Assets/Prefabs_NEW/UI/GameCanvas.prefab index 52c762f7..7e87944d 100644 --- a/Assets/Prefabs_NEW/UI/GameCanvas.prefab +++ b/Assets/Prefabs_NEW/UI/GameCanvas.prefab @@ -1,5 +1,27 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!114 &7117637459513898660 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1415495982521125429} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ba0d0e7a039f526499c356a3c5cd6d3f, type: 3} + m_Name: + m_EditorClassIdentifier: + handleRange: 1 + deadZone: 0.3 + axisOptions: 0 + snapX: 0 + snapY: 0 + background: {fileID: 1415495983658094506} + handle: {fileID: 1415495981690910128} + _idleStateOpacity: 0.3 + _activeStateOpacity: 1 + moveThreshold: 1 --- !u!1 &7117637457422693166 GameObject: m_ObjectHideFlags: 0 @@ -1586,26 +1608,6 @@ Animator: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorControllerStateOnDisable: 0 ---- !u!114 &7117637459513898660 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1415495982521125429} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ba0d0e7a039f526499c356a3c5cd6d3f, type: 3} - m_Name: - m_EditorClassIdentifier: - handleRange: 1 - deadZone: 0.3 - axisOptions: 0 - snapX: 0 - snapY: 0 - background: {fileID: 1415495983658094506} - handle: {fileID: 1415495981690910128} - moveThreshold: 1 --- !u!1 &7117637459520280379 GameObject: m_ObjectHideFlags: 0 @@ -2913,6 +2915,11 @@ PrefabInstance: propertyPath: deadZone value: 0.3 objectReference: {fileID: 0} + - target: {fileID: 8170153791668043265, guid: 0d230cc8be529a542a08cb878ab14b18, + type: 3} + propertyPath: _idleStateOpacity + value: 0.3 + objectReference: {fileID: 0} - target: {fileID: 8170153791668043268, guid: 0d230cc8be529a542a08cb878ab14b18, type: 3} propertyPath: m_Pivot.x diff --git a/Assets/Scenes/Level_1.unity b/Assets/Scenes/Level_1.unity index 7cfda986..7342ab10 100644 --- a/Assets/Scenes/Level_1.unity +++ b/Assets/Scenes/Level_1.unity @@ -55771,11 +55771,106 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 1415495983215601304, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: _idleStateOpacity + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 5557455103468811314, guid: a72be70db1163c14b8b7a3cb1c00a59d, type: 3} propertyPath: bonusController value: objectReference: {fileID: 1801060033} + - target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 7117637458793366621, guid: a72be70db1163c14b8b7a3cb1c00a59d, type: 3} propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target @@ -55911,6 +56006,36 @@ PrefabInstance: propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target value: objectReference: {fileID: 185995048} + - target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: a72be70db1163c14b8b7a3cb1c00a59d, type: 3} --- !u!1 &7121823489171206717