Removed TOTU 103
This commit is contained in:
377
Assets/Common/InputSystem/LightshipInput.cs
Normal file
377
Assets/Common/InputSystem/LightshipInput.cs
Normal file
@@ -0,0 +1,377 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||
// version 1.11.0
|
||||
// from Assets/Common/InputSystem/LightshipInput.inputactions
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
public partial class @LightshipInput: IInputActionCollection2, IDisposable
|
||||
{
|
||||
public InputActionAsset asset { get; }
|
||||
public @LightshipInput()
|
||||
{
|
||||
asset = InputActionAsset.FromJson(@"{
|
||||
""name"": ""LightshipInput"",
|
||||
""maps"": [
|
||||
{
|
||||
""name"": ""Input"",
|
||||
""id"": ""0441efd8-cf4a-4f54-9575-e620f871d873"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""PrimaryTouch"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""5587b327-fc71-48bf-ad8d-e78e9560da96"",
|
||||
""expectedControlType"": ""Touch"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""SecondaryTouch"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""0e25d142-0aa1-408a-b1c2-d8128da03184"",
|
||||
""expectedControlType"": ""Touch"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""MouseScroll"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""999680a4-775f-4be4-85b9-ebe9d80d052b"",
|
||||
""expectedControlType"": ""Vector2"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""MousePan"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""dbf4bfe6-227d-4c8c-9394-44aab5af9e12"",
|
||||
""expectedControlType"": ""Vector2"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""MouseHold"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""7eb15c42-52e1-4803-80ae-e3521cdfcdd4"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Point"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""eb3d0780-4e38-48ef-bf2f-9bc2186c1f8c"",
|
||||
""expectedControlType"": ""Vector2"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""8b99124f-47cf-4ca4-90df-4317fefd9b3c"",
|
||||
""path"": ""<Touchscreen>/touch0"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""PrimaryTouch"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""da48dbed-bb28-40bc-a4ef-64b45c4aa545"",
|
||||
""path"": ""<Touchscreen>/touch1"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""SecondaryTouch"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""9a2527ae-2e1b-4e87-85c4-eebb3539109b"",
|
||||
""path"": ""<Mouse>/scroll"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""MouseScroll"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""One Modifier"",
|
||||
""id"": ""ecf34196-58c5-4614-b0a2-8287b515b50b"",
|
||||
""path"": ""OneModifier"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""MousePan"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""modifier"",
|
||||
""id"": ""813b8f15-fafc-4898-8678-ce51d3f54545"",
|
||||
""path"": ""<Mouse>/leftButton"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""MousePan"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""binding"",
|
||||
""id"": ""b49fa1e5-ecbf-46c1-a2be-a66aade8702f"",
|
||||
""path"": ""<Mouse>/delta"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""MousePan"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""dd2cea80-3525-4cb3-897a-a7c2b2f322de"",
|
||||
""path"": ""<Mouse>/leftButton"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""MouseHold"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""61de2db2-e936-483e-9f19-6ed8da5219b7"",
|
||||
""path"": ""<Touchscreen>/primaryTouch/position"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Point"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""One Modifier"",
|
||||
""id"": ""30e7dbb0-a98c-4b5c-8f7e-3abda5647833"",
|
||||
""path"": ""OneModifier"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Point"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""modifier"",
|
||||
""id"": ""8e81916c-99cc-4086-b086-9fadb0b378e4"",
|
||||
""path"": ""<Mouse>/leftButton"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Point"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""binding"",
|
||||
""id"": ""b43654fb-edca-4222-9b9b-bfeb517b32ab"",
|
||||
""path"": ""<Mouse>/position"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Point"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
""controlSchemes"": []
|
||||
}");
|
||||
// Input
|
||||
m_Input = asset.FindActionMap("Input", throwIfNotFound: true);
|
||||
m_Input_PrimaryTouch = m_Input.FindAction("PrimaryTouch", throwIfNotFound: true);
|
||||
m_Input_SecondaryTouch = m_Input.FindAction("SecondaryTouch", throwIfNotFound: true);
|
||||
m_Input_MouseScroll = m_Input.FindAction("MouseScroll", throwIfNotFound: true);
|
||||
m_Input_MousePan = m_Input.FindAction("MousePan", throwIfNotFound: true);
|
||||
m_Input_MouseHold = m_Input.FindAction("MouseHold", throwIfNotFound: true);
|
||||
m_Input_Point = m_Input.FindAction("Point", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
~@LightshipInput()
|
||||
{
|
||||
UnityEngine.Debug.Assert(!m_Input.enabled, "This will cause a leak and performance issues, LightshipInput.Input.Disable() has not been called.");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnityEngine.Object.Destroy(asset);
|
||||
}
|
||||
|
||||
public InputBinding? bindingMask
|
||||
{
|
||||
get => asset.bindingMask;
|
||||
set => asset.bindingMask = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputDevice>? devices
|
||||
{
|
||||
get => asset.devices;
|
||||
set => asset.devices = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||
|
||||
public bool Contains(InputAction action)
|
||||
{
|
||||
return asset.Contains(action);
|
||||
}
|
||||
|
||||
public IEnumerator<InputAction> GetEnumerator()
|
||||
{
|
||||
return asset.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
asset.Enable();
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
asset.Disable();
|
||||
}
|
||||
|
||||
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||
|
||||
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||
{
|
||||
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||
}
|
||||
|
||||
public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||
{
|
||||
return asset.FindBinding(bindingMask, out action);
|
||||
}
|
||||
|
||||
// Input
|
||||
private readonly InputActionMap m_Input;
|
||||
private List<IInputActions> m_InputActionsCallbackInterfaces = new List<IInputActions>();
|
||||
private readonly InputAction m_Input_PrimaryTouch;
|
||||
private readonly InputAction m_Input_SecondaryTouch;
|
||||
private readonly InputAction m_Input_MouseScroll;
|
||||
private readonly InputAction m_Input_MousePan;
|
||||
private readonly InputAction m_Input_MouseHold;
|
||||
private readonly InputAction m_Input_Point;
|
||||
public struct InputActions
|
||||
{
|
||||
private @LightshipInput m_Wrapper;
|
||||
public InputActions(@LightshipInput wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @PrimaryTouch => m_Wrapper.m_Input_PrimaryTouch;
|
||||
public InputAction @SecondaryTouch => m_Wrapper.m_Input_SecondaryTouch;
|
||||
public InputAction @MouseScroll => m_Wrapper.m_Input_MouseScroll;
|
||||
public InputAction @MousePan => m_Wrapper.m_Input_MousePan;
|
||||
public InputAction @MouseHold => m_Wrapper.m_Input_MouseHold;
|
||||
public InputAction @Point => m_Wrapper.m_Input_Point;
|
||||
public InputActionMap Get() { return m_Wrapper.m_Input; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
public bool enabled => Get().enabled;
|
||||
public static implicit operator InputActionMap(InputActions set) { return set.Get(); }
|
||||
public void AddCallbacks(IInputActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_InputActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_InputActionsCallbackInterfaces.Add(instance);
|
||||
@PrimaryTouch.started += instance.OnPrimaryTouch;
|
||||
@PrimaryTouch.performed += instance.OnPrimaryTouch;
|
||||
@PrimaryTouch.canceled += instance.OnPrimaryTouch;
|
||||
@SecondaryTouch.started += instance.OnSecondaryTouch;
|
||||
@SecondaryTouch.performed += instance.OnSecondaryTouch;
|
||||
@SecondaryTouch.canceled += instance.OnSecondaryTouch;
|
||||
@MouseScroll.started += instance.OnMouseScroll;
|
||||
@MouseScroll.performed += instance.OnMouseScroll;
|
||||
@MouseScroll.canceled += instance.OnMouseScroll;
|
||||
@MousePan.started += instance.OnMousePan;
|
||||
@MousePan.performed += instance.OnMousePan;
|
||||
@MousePan.canceled += instance.OnMousePan;
|
||||
@MouseHold.started += instance.OnMouseHold;
|
||||
@MouseHold.performed += instance.OnMouseHold;
|
||||
@MouseHold.canceled += instance.OnMouseHold;
|
||||
@Point.started += instance.OnPoint;
|
||||
@Point.performed += instance.OnPoint;
|
||||
@Point.canceled += instance.OnPoint;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(IInputActions instance)
|
||||
{
|
||||
@PrimaryTouch.started -= instance.OnPrimaryTouch;
|
||||
@PrimaryTouch.performed -= instance.OnPrimaryTouch;
|
||||
@PrimaryTouch.canceled -= instance.OnPrimaryTouch;
|
||||
@SecondaryTouch.started -= instance.OnSecondaryTouch;
|
||||
@SecondaryTouch.performed -= instance.OnSecondaryTouch;
|
||||
@SecondaryTouch.canceled -= instance.OnSecondaryTouch;
|
||||
@MouseScroll.started -= instance.OnMouseScroll;
|
||||
@MouseScroll.performed -= instance.OnMouseScroll;
|
||||
@MouseScroll.canceled -= instance.OnMouseScroll;
|
||||
@MousePan.started -= instance.OnMousePan;
|
||||
@MousePan.performed -= instance.OnMousePan;
|
||||
@MousePan.canceled -= instance.OnMousePan;
|
||||
@MouseHold.started -= instance.OnMouseHold;
|
||||
@MouseHold.performed -= instance.OnMouseHold;
|
||||
@MouseHold.canceled -= instance.OnMouseHold;
|
||||
@Point.started -= instance.OnPoint;
|
||||
@Point.performed -= instance.OnPoint;
|
||||
@Point.canceled -= instance.OnPoint;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(IInputActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_InputActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
public void SetCallbacks(IInputActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_InputActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_InputActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
public InputActions @Input => new InputActions(this);
|
||||
public interface IInputActions
|
||||
{
|
||||
void OnPrimaryTouch(InputAction.CallbackContext context);
|
||||
void OnSecondaryTouch(InputAction.CallbackContext context);
|
||||
void OnMouseScroll(InputAction.CallbackContext context);
|
||||
void OnMousePan(InputAction.CallbackContext context);
|
||||
void OnMouseHold(InputAction.CallbackContext context);
|
||||
void OnPoint(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
11
Assets/Common/InputSystem/LightshipInput.cs.meta
Normal file
11
Assets/Common/InputSystem/LightshipInput.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00ec2e85088d948928dc5b4fcac92c31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
189
Assets/Common/InputSystem/LightshipInput.inputactions
Normal file
189
Assets/Common/InputSystem/LightshipInput.inputactions
Normal file
@@ -0,0 +1,189 @@
|
||||
{
|
||||
"name": "LightshipInput",
|
||||
"maps": [
|
||||
{
|
||||
"name": "Input",
|
||||
"id": "0441efd8-cf4a-4f54-9575-e620f871d873",
|
||||
"actions": [
|
||||
{
|
||||
"name": "PrimaryTouch",
|
||||
"type": "Value",
|
||||
"id": "5587b327-fc71-48bf-ad8d-e78e9560da96",
|
||||
"expectedControlType": "Touch",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "SecondaryTouch",
|
||||
"type": "Value",
|
||||
"id": "0e25d142-0aa1-408a-b1c2-d8128da03184",
|
||||
"expectedControlType": "Touch",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "MouseScroll",
|
||||
"type": "Value",
|
||||
"id": "999680a4-775f-4be4-85b9-ebe9d80d052b",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "MousePan",
|
||||
"type": "Value",
|
||||
"id": "dbf4bfe6-227d-4c8c-9394-44aab5af9e12",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "MouseHold",
|
||||
"type": "Button",
|
||||
"id": "7eb15c42-52e1-4803-80ae-e3521cdfcdd4",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Point",
|
||||
"type": "Value",
|
||||
"id": "eb3d0780-4e38-48ef-bf2f-9bc2186c1f8c",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "8b99124f-47cf-4ca4-90df-4317fefd9b3c",
|
||||
"path": "<Touchscreen>/touch0",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "PrimaryTouch",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "da48dbed-bb28-40bc-a4ef-64b45c4aa545",
|
||||
"path": "<Touchscreen>/touch1",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "SecondaryTouch",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "9a2527ae-2e1b-4e87-85c4-eebb3539109b",
|
||||
"path": "<Mouse>/scroll",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MouseScroll",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "One Modifier",
|
||||
"id": "ecf34196-58c5-4614-b0a2-8287b515b50b",
|
||||
"path": "OneModifier",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MousePan",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "modifier",
|
||||
"id": "813b8f15-fafc-4898-8678-ce51d3f54545",
|
||||
"path": "<Mouse>/leftButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MousePan",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "binding",
|
||||
"id": "b49fa1e5-ecbf-46c1-a2be-a66aade8702f",
|
||||
"path": "<Mouse>/delta",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MousePan",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "dd2cea80-3525-4cb3-897a-a7c2b2f322de",
|
||||
"path": "<Mouse>/leftButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "MouseHold",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "61de2db2-e936-483e-9f19-6ed8da5219b7",
|
||||
"path": "<Touchscreen>/primaryTouch/position",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Point",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "One Modifier",
|
||||
"id": "30e7dbb0-a98c-4b5c-8f7e-3abda5647833",
|
||||
"path": "OneModifier",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Point",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "modifier",
|
||||
"id": "8e81916c-99cc-4086-b086-9fadb0b378e4",
|
||||
"path": "<Mouse>/leftButton",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Point",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "binding",
|
||||
"id": "b43654fb-edca-4222-9b9b-bfeb517b32ab",
|
||||
"path": "<Mouse>/position",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Point",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": []
|
||||
}
|
||||
14
Assets/Common/InputSystem/LightshipInput.inputactions.meta
Normal file
14
Assets/Common/InputSystem/LightshipInput.inputactions.meta
Normal file
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5afb89d680e044867b0883cfea8624bf
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 1
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace:
|
||||
298
Assets/Common/InputSystem/TouchManager.cs
Normal file
298
Assets/Common/InputSystem/TouchManager.cs
Normal file
@@ -0,0 +1,298 @@
|
||||
// Copyright 2022-2024 Niantic.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Controls;
|
||||
using UnityEngine.InputSystem.LowLevel;
|
||||
using UnityEngine.UI;
|
||||
using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;
|
||||
using TouchPhase = UnityEngine.TouchPhase;
|
||||
|
||||
|
||||
public class TouchManager : MonoBehaviour
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
public class FloatEvent : UnityEvent<float> { };
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class Vector2Event : UnityEvent<Vector2> { };
|
||||
|
||||
[SerializeField] private float _pinchScrollSpeed;
|
||||
[SerializeField] private float _mouseScrollSpeed;
|
||||
[SerializeField] private float _touchPanSpeed;
|
||||
[SerializeField] private float _mousePanSpeed;
|
||||
|
||||
private LightshipInput _lightshipInput;
|
||||
private bool _isPointerDown;
|
||||
private bool IsPointerDown
|
||||
{
|
||||
|
||||
get { return _isPointerDown; }
|
||||
set
|
||||
{
|
||||
_isPointerDown = value;
|
||||
if ((value == false) && (_IsPanActive))
|
||||
{
|
||||
_IsPanActive = false;
|
||||
PanEnded?.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private bool _IsPanActive = false;
|
||||
private Dictionary<int, TouchState> _activeTouches = new Dictionary<int, TouchState>();
|
||||
|
||||
|
||||
|
||||
private float _lastPinchDistance = 0f;
|
||||
private bool _resetPinchDistance = false;
|
||||
private Coroutine activePinchCoroutine = null;
|
||||
|
||||
[SerializeField] public FloatEvent PinchEvent = new FloatEvent();
|
||||
[SerializeField] public Vector2Event PanEvent = new Vector2Event();
|
||||
[SerializeField] public UnityEvent PanEnded = new UnityEvent();
|
||||
[SerializeField] public Vector2Event TouchUpEvent = new Vector2Event();
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_lightshipInput = new LightshipInput();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_lightshipInput.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_lightshipInput.Disable();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_lightshipInput.Input.PrimaryTouch.performed += ctx => PrimaryTouchCallback(ctx);
|
||||
_lightshipInput.Input.PrimaryTouch.started += ctx => PrimaryTouchCallback(ctx);
|
||||
_lightshipInput.Input.PrimaryTouch.canceled += ctx => PrimaryTouchCallback(ctx);
|
||||
|
||||
_lightshipInput.Input.SecondaryTouch.performed += ctx => SecondaryTouchCallback(ctx);
|
||||
_lightshipInput.Input.SecondaryTouch.started += ctx => SecondaryTouchCallback(ctx);
|
||||
_lightshipInput.Input.SecondaryTouch.canceled += ctx => SecondaryTouchCallback(ctx);
|
||||
|
||||
_lightshipInput.Input.MouseScroll.performed += ctx => MouseScrollCallback(ctx);
|
||||
_lightshipInput.Input.MousePan.performed += ctx => MousePanCallback(ctx);
|
||||
_lightshipInput.Input.MousePan.canceled += ctx => MousePanCallback(ctx);
|
||||
|
||||
_lightshipInput.Input.MouseHold.started += ctx => MouseHoldCallback(ctx);
|
||||
_lightshipInput.Input.MouseHold.performed += ctx => MouseHoldCallback(ctx);
|
||||
_lightshipInput.Input.MouseHold.canceled += ctx => MouseHoldCallback(ctx);
|
||||
|
||||
}
|
||||
|
||||
private void MouseHoldCallback(InputAction.CallbackContext ctx)
|
||||
{
|
||||
switch (ctx.phase)
|
||||
{
|
||||
case InputActionPhase.Started :
|
||||
IsPointerDown = true;
|
||||
break;
|
||||
case InputActionPhase.Canceled :
|
||||
IsPointerDown = false;
|
||||
if (!_IsPanActive)
|
||||
{
|
||||
TouchUpEvent?.Invoke(Mouse.current.position.ReadValue());
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void MousePanCallback(InputAction.CallbackContext ctx)
|
||||
{
|
||||
var mousepan = ctx.ReadValue<Vector2>();
|
||||
if (ctx.phase == InputActionPhase.Performed)
|
||||
{
|
||||
_IsPanActive = true;
|
||||
}
|
||||
ProcessPan(mousepan * _mousePanSpeed);
|
||||
}
|
||||
|
||||
private void MouseScrollCallback(InputAction.CallbackContext ctx)
|
||||
{
|
||||
|
||||
var mousecroll = ctx.ReadValue<Vector2>();
|
||||
ProcessScrollZoom(mousecroll);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SecondaryTouchCallback(InputAction.CallbackContext ctx)
|
||||
{
|
||||
var touch = ctx.ReadValue<TouchState>();
|
||||
PreprocessTouch(touch);
|
||||
|
||||
}
|
||||
|
||||
private void PrimaryTouchCallback(InputAction.CallbackContext ctx)
|
||||
{
|
||||
var touch = ctx.ReadValue<TouchState>();
|
||||
PreprocessTouch(touch);
|
||||
|
||||
}
|
||||
|
||||
private void PreprocessTouch(TouchState touch)
|
||||
{
|
||||
|
||||
switch (touch.phase)
|
||||
{
|
||||
case UnityEngine.InputSystem.TouchPhase.Began :
|
||||
|
||||
_activeTouches.TryAdd(touch.touchId, touch);
|
||||
break;
|
||||
case UnityEngine.InputSystem.TouchPhase.Ended :
|
||||
_activeTouches.Remove(touch.touchId);
|
||||
break;
|
||||
case UnityEngine.InputSystem.TouchPhase.Canceled :
|
||||
_activeTouches.Remove(touch.touchId);
|
||||
break;
|
||||
case UnityEngine.InputSystem.TouchPhase.None :
|
||||
break;
|
||||
default :
|
||||
_activeTouches[touch.touchId] = touch;
|
||||
break;
|
||||
}
|
||||
|
||||
if (_activeTouches.Count > 1)
|
||||
{
|
||||
if (activePinchCoroutine == null)
|
||||
{
|
||||
activePinchCoroutine = StartCoroutine(ProcessPinch());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (activePinchCoroutine != null)
|
||||
{
|
||||
StopCoroutine(activePinchCoroutine);
|
||||
activePinchCoroutine = null;
|
||||
}
|
||||
|
||||
if (_activeTouches.Count == 1)
|
||||
{
|
||||
ProcessTouch();
|
||||
}
|
||||
else
|
||||
{
|
||||
IsPointerDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsPointerDown == false)
|
||||
if (_IsPanActive)
|
||||
{
|
||||
_IsPanActive = false;
|
||||
PanEnded?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
TouchUpEvent?.Invoke(touch.position);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Process Gestures
|
||||
|
||||
private void ProcessPan(Vector2 delta)
|
||||
{
|
||||
|
||||
PanEvent?.Invoke(delta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private IEnumerator ProcessPinch()
|
||||
{
|
||||
_resetPinchDistance = true;
|
||||
while (true)
|
||||
{
|
||||
|
||||
yield return null;
|
||||
|
||||
var orderedTouches = _activeTouches.OrderBy(x => x.Key).ToArray();
|
||||
|
||||
var touchOne = orderedTouches[0];
|
||||
var touchTwo = orderedTouches[1];
|
||||
|
||||
var pinchDistance = Vector2.Distance(touchOne.Value.position, touchTwo.Value.position);
|
||||
if (_resetPinchDistance)
|
||||
{
|
||||
_lastPinchDistance = pinchDistance;
|
||||
_resetPinchDistance = false;
|
||||
}
|
||||
|
||||
float pinchDelta = (pinchDistance - _lastPinchDistance);
|
||||
_lastPinchDistance = pinchDistance;
|
||||
|
||||
|
||||
PinchEvent?.Invoke(pinchDelta * _pinchScrollSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessScrollZoom(Vector2 MouseScrollDelta)
|
||||
{
|
||||
var yScrollDelta = MouseScrollDelta.y * _mouseScrollSpeed;
|
||||
PinchEvent?.Invoke(yScrollDelta);
|
||||
}
|
||||
|
||||
private void ProcessMouseMap()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ProcessTouch()
|
||||
{
|
||||
var orderedTouches = _activeTouches.OrderBy(x => x.Key).ToArray();
|
||||
var touch = orderedTouches[0].Value;
|
||||
switch (touch.phase)
|
||||
{
|
||||
case UnityEngine.InputSystem.TouchPhase.Began :
|
||||
IsPointerDown = true;
|
||||
break;
|
||||
case UnityEngine.InputSystem.TouchPhase.Ended :
|
||||
break;
|
||||
case UnityEngine.InputSystem.TouchPhase.Moved:
|
||||
_IsPanActive = true;
|
||||
var delta = touch.delta;
|
||||
if (delta.x + delta.y != 0)
|
||||
{
|
||||
ProcessPan(delta);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Common/InputSystem/TouchManager.cs.meta
Normal file
11
Assets/Common/InputSystem/TouchManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 527e4ecf5ade44e01a972d1269464503
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user