12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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;
- }
-
- /// <summary>
- /// Key数据
- /// </summary>
- public InputKeys inputKeys;
- public InputKeyCode EnterKeyAlias = InputKeyCode.Trigger;
- public InputKeyCode CancelKeyAlias = InputKeyCode.Cancel;
- public InputKeyCode CalibrationKeyAlias = InputKeyCode.Function;
- bool _isVaild = false;
- /// <summary>
- /// 数据是否有效
- /// </summary>
- public bool isVaild {
- get {
- return _isVaild;
- }
- set {
- if(value != _isVaild) {
- _isVaild = value;
- DeviceVaildChanged(value);
- }
- }
- }
- /// <summary>
- /// 事件信息
- /// </summary>
- public SCPointEventData SCPointEventData;
- /// <summary>
- /// Posture,the inputDevice 6Dof Posture in the world
- /// </summary>
- 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;
- position = Vector3.zero;
- rotation = Quaternion.identity;
- SCPointEventData.Clear();
- }
- public override void OnSCDestroy() {
- base.OnSCDestroy();
- inputKeys = null;
- SCPointEventData = null;
- inputDevicePartBase = null;
- }
- #endregion
- void DeviceVaildChanged(bool newVaild) {
- inputKeys.VaildChanged();
- }
- }
- }
|