simple UI added

This commit is contained in:
Mausham
2025-12-11 18:20:42 -08:00
parent 60e58082ac
commit 2118bb7c36
576 changed files with 126744 additions and 13 deletions

View File

@@ -100,6 +100,15 @@ public partial class @GameInput: IInputActionCollection2, IDisposable
""processors"": """",
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""Click"",
""type"": ""Button"",
""id"": ""d08e73a2-d66c-4b94-8559-f0f33f595386"",
""expectedControlType"": """",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
@@ -124,6 +133,17 @@ public partial class @GameInput: IInputActionCollection2, IDisposable
""action"": ""Drag"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""d96e7abe-3a25-4e29-8565-e9e53cbf261f"",
""path"": ""<Mouse>/leftButton"",
""interactions"": ""Hold"",
""processors"": """",
""groups"": """",
""action"": ""Click"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
@@ -133,6 +153,7 @@ public partial class @GameInput: IInputActionCollection2, IDisposable
// Player
m_Player = asset.FindActionMap("Player", throwIfNotFound: true);
m_Player_Drag = m_Player.FindAction("Drag", throwIfNotFound: true);
m_Player_Click = m_Player.FindAction("Click", throwIfNotFound: true);
}
~@GameInput()
@@ -214,6 +235,7 @@ public partial class @GameInput: IInputActionCollection2, IDisposable
private readonly InputActionMap m_Player;
private List<IPlayerActions> m_PlayerActionsCallbackInterfaces = new List<IPlayerActions>();
private readonly InputAction m_Player_Drag;
private readonly InputAction m_Player_Click;
/// <summary>
/// Provides access to input actions defined in input action map "Player".
/// </summary>
@@ -230,6 +252,10 @@ public partial class @GameInput: IInputActionCollection2, IDisposable
/// </summary>
public InputAction @Drag => m_Wrapper.m_Player_Drag;
/// <summary>
/// Provides access to the underlying input action "Player/Click".
/// </summary>
public InputAction @Click => m_Wrapper.m_Player_Click;
/// <summary>
/// Provides access to the underlying input action map instance.
/// </summary>
public InputActionMap Get() { return m_Wrapper.m_Player; }
@@ -258,6 +284,9 @@ public partial class @GameInput: IInputActionCollection2, IDisposable
@Drag.started += instance.OnDrag;
@Drag.performed += instance.OnDrag;
@Drag.canceled += instance.OnDrag;
@Click.started += instance.OnClick;
@Click.performed += instance.OnClick;
@Click.canceled += instance.OnClick;
}
/// <summary>
@@ -272,6 +301,9 @@ public partial class @GameInput: IInputActionCollection2, IDisposable
@Drag.started -= instance.OnDrag;
@Drag.performed -= instance.OnDrag;
@Drag.canceled -= instance.OnDrag;
@Click.started -= instance.OnClick;
@Click.performed -= instance.OnClick;
@Click.canceled -= instance.OnClick;
}
/// <summary>
@@ -319,5 +351,12 @@ public partial class @GameInput: IInputActionCollection2, IDisposable
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnDrag(InputAction.CallbackContext context);
/// <summary>
/// Method invoked when associated input action "Click" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
/// </summary>
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
void OnClick(InputAction.CallbackContext context);
}
}

View File

@@ -14,6 +14,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Click",
"type": "Button",
"id": "d08e73a2-d66c-4b94-8559-f0f33f595386",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
@@ -38,6 +47,17 @@
"action": "Drag",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "d96e7abe-3a25-4e29-8565-e9e53cbf261f",
"path": "<Mouse>/leftButton",
"interactions": "Hold",
"processors": "",
"groups": "",
"action": "Click",
"isComposite": false,
"isPartOfComposite": false
}
]
}

View File

@@ -3,4 +3,6 @@ using UnityEngine;
public interface IInputReader
{
Vector2 dragInput{get;}
float clickInput { get;}
bool isclicked { get;}
}

View File

@@ -6,16 +6,23 @@ using UnityEngine.InputSystem;
public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActions
{
public Action<Vector2> OnDragValueChanged;
public Vector2 _dragInput;
public Vector2 dragInput
{
get=> _dragInput;
private set
{
_dragInput = value;
OnDragValueChanged?.Invoke(_dragInput);
}
}
public float clickInput { get; private set; }
public bool isclicked {get; private set; }
private GameInput inputActions;
private void OnEnable()
@@ -25,10 +32,11 @@ public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActi
inputActions = new GameInput();
inputActions.Player.SetCallbacks(this);
}
inputActions.Enable();
}
private void OnDisable()
public void OnDisable()
{
inputActions?.Player.Disable();
}
@@ -37,4 +45,11 @@ public class InputReader : ScriptableObject, IInputReader, GameInput.IPlayerActi
{
dragInput = context.ReadValue<Vector2>();
}
public void OnClick(InputAction.CallbackContext context)
{
clickInput = context.ReadValue<float>();
isclicked = clickInput == 1? true : false;
Debug.Log(isclicked);
}
}