radial menu work as expected
This commit is contained in:
@@ -41,12 +41,12 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
Instance._inputSystem.Enable();
|
||||
Instance._inputSystem?.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Instance._inputSystem.Disable();
|
||||
Instance._inputSystem?.Disable();
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
|
||||
@@ -29,18 +29,18 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""PointClick"",
|
||||
""type"": ""Button"",
|
||||
""type"": ""PassThrough"",
|
||||
""id"": ""fb720cef-8db9-45ea-94b8-34ee20907014"",
|
||||
""expectedControlType"": """",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""CancelClick"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""a045f2ab-c0ec-42fc-9343-39839caf2ba4"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
@@ -354,11 +354,20 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""Click"",
|
||||
""type"": ""Button"",
|
||||
""type"": ""PassThrough"",
|
||||
""id"": ""cddc5ce5-b808-4da9-b23b-f24a5126f838"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Point"",
|
||||
""type"": ""PassThrough"",
|
||||
""id"": ""8fe62ab9-ffe9-4edc-8a1a-e66417e475c8"",
|
||||
""expectedControlType"": ""Vector2"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
@@ -373,6 +382,17 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
""action"": ""Click"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""6013fd8b-2f52-4b27-8549-249c73d113b2"",
|
||||
""path"": ""<Mouse>/{Point}"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Point"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -391,6 +411,7 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
// UI
|
||||
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
|
||||
m_UI_Click = m_UI.FindAction("Click", throwIfNotFound: true);
|
||||
m_UI_Point = m_UI.FindAction("Point", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
~@InputActions()
|
||||
@@ -576,11 +597,13 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
private readonly InputActionMap m_UI;
|
||||
private List<IUIActions> m_UIActionsCallbackInterfaces = new List<IUIActions>();
|
||||
private readonly InputAction m_UI_Click;
|
||||
private readonly InputAction m_UI_Point;
|
||||
public struct UIActions
|
||||
{
|
||||
private @InputActions m_Wrapper;
|
||||
public UIActions(@InputActions wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @Click => m_Wrapper.m_UI_Click;
|
||||
public InputAction @Point => m_Wrapper.m_UI_Point;
|
||||
public InputActionMap Get() { return m_Wrapper.m_UI; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
@@ -593,6 +616,9 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
@Click.started += instance.OnClick;
|
||||
@Click.performed += instance.OnClick;
|
||||
@Click.canceled += instance.OnClick;
|
||||
@Point.started += instance.OnPoint;
|
||||
@Point.performed += instance.OnPoint;
|
||||
@Point.canceled += instance.OnPoint;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(IUIActions instance)
|
||||
@@ -600,6 +626,9 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
@Click.started -= instance.OnClick;
|
||||
@Click.performed -= instance.OnClick;
|
||||
@Click.canceled -= instance.OnClick;
|
||||
@Point.started -= instance.OnPoint;
|
||||
@Point.performed -= instance.OnPoint;
|
||||
@Point.canceled -= instance.OnPoint;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(IUIActions instance)
|
||||
@@ -631,5 +660,6 @@ public partial class @InputActions: IInputActionCollection2, IDisposable
|
||||
public interface IUIActions
|
||||
{
|
||||
void OnClick(InputAction.CallbackContext context);
|
||||
void OnPoint(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
"actions": [
|
||||
{
|
||||
"name": "PointClick",
|
||||
"type": "Button",
|
||||
"type": "PassThrough",
|
||||
"id": "fb720cef-8db9-45ea-94b8-34ee20907014",
|
||||
"expectedControlType": "",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "CancelClick",
|
||||
"type": "Button",
|
||||
"id": "a045f2ab-c0ec-42fc-9343-39839caf2ba4",
|
||||
"expectedControlType": "Button",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
@@ -332,11 +332,20 @@
|
||||
"actions": [
|
||||
{
|
||||
"name": "Click",
|
||||
"type": "Button",
|
||||
"type": "PassThrough",
|
||||
"id": "cddc5ce5-b808-4da9-b23b-f24a5126f838",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "Point",
|
||||
"type": "PassThrough",
|
||||
"id": "8fe62ab9-ffe9-4edc-8a1a-e66417e475c8",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
@@ -351,6 +360,17 @@
|
||||
"action": "Click",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "6013fd8b-2f52-4b27-8549-249c73d113b2",
|
||||
"path": "<Mouse>/{Point}",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Point",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class RadialMenuItem : MonoBehaviour
|
||||
{
|
||||
var button = Instantiate(_radialMenuItemPrefab);
|
||||
button.transform.SetParent(transform, false);
|
||||
|
||||
//button.transform.localScale *= 2;
|
||||
float theta = (2 * Mathf.PI / actions.Count) * buttonsCount;
|
||||
float posX = Mathf.Sin(theta);
|
||||
float posY = Mathf.Cos(theta);
|
||||
|
||||
Reference in New Issue
Block a user