using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.EventSystems; namespace SC.XR.Unity.Module_InputSystem { public abstract class InputDataBase : SCModule { public InputDevicePartBase inputDevicePartBase; public InputDataBase(InputDevicePartBase inputDevicePartBase) { this.inputDevicePartBase = inputDevicePartBase; } /// /// Key数据 /// public InputKeys inputKeys; public InputKeyCode EnterKeyAlias = InputKeyCode.Trigger; public InputKeyCode AnotherEnterKeyAlias = InputKeyCode.NULL; public InputKeyCode ThreeEnterKeyAlias = InputKeyCode.NULL; public InputKeyCode CancelKeyAlias = InputKeyCode.Cancel; public InputKeyCode CalibrationKeyAlias = InputKeyCode.Function; bool _isVaild = false; /// /// 数据是否有效 /// public bool isVaild { get { return _isVaild; } set { if(value != _isVaild) { _isVaild = value; DeviceVaildChanged(value); } } } /// /// 事件信息 /// public SCPointEventData SCPointEventData; /// /// Posture,the inputDevice 6Dof Posture in the world /// public Vector3 position; public Quaternion rotation; #region Module Behavior public override void OnSCAwake() { base.OnSCAwake(); isVaild = false; position = Vector3.zero; rotation = Quaternion.identity; SCPointEventData = new SCPointEventData(inputDevicePartBase, EventSystem.current); AddModule(inputKeys = new InputKeys(this)); } public override void OnSCStart() { base.OnSCStart(); inputKeys.ModuleStart(); } public override void OnSCDisable() { base.OnSCDisable(); isVaild = false; SCPointEventData.Clear(); } public override void OnSCDestroy() { base.OnSCDestroy(); position = Vector3.zero; rotation = Quaternion.identity; inputKeys = null; SCPointEventData = null; inputDevicePartBase = null; } #endregion void DeviceVaildChanged(bool newVaild) { inputKeys.VaildChanged(); } } }