diff --git a/Runtime/HumanoidControl/Scripts/Extensions/ArmSensor.cs b/Runtime/HumanoidControl/Scripts/Extensions/ArmSensor.cs index 2a1960e..6b88c35 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/ArmSensor.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/ArmSensor.cs @@ -41,37 +41,42 @@ namespace Passer.Humanoid { return null; } + /// + /// Checks if a sensorComponent is present and will create one if it does not exist + /// + /// The HandTarget to which the sensor is assigned public virtual void CheckSensor(HandTarget _handTarget) { if (handTarget == null) target = _handTarget; + } - public virtual void CheckSensor(HandTarget handTarget, HumanoidTracker tracker) { - if (this.handTarget == null) - this.target = handTarget; - if (this.handTarget == null) - return; +// public virtual void CheckSensor(HandTarget handTarget, HumanoidTracker tracker) { +// if (this.handTarget == null) +// this.target = handTarget; +// if (this.handTarget == null) +// return; - //if (this.tracker == null) - // this.tracker = tracker; +// //if (this.tracker == null) +// // this.tracker = tracker; - if (enabled && tracker.enabled) { - if (handSkeleton == null) { - handSkeleton = FindHandSkeleton(handTarget.isLeft); - if (handSkeleton == null) - handSkeleton = CreateHandSkeleton(handTarget.isLeft, handTarget.showRealObjects); - } - } - else { -#if UNITY_EDITOR - if (!Application.isPlaying) { - if (handSkeleton != null) - Object.DestroyImmediate(handSkeleton.gameObject, true); - } -#endif - handSkeleton = null; - } - } +// if (enabled && tracker.enabled) { +// if (handSkeleton == null) { +// handSkeleton = FindHandSkeleton(handTarget.isLeft); +// if (handSkeleton == null) +// handSkeleton = CreateHandSkeleton(handTarget.isLeft, handTarget.showRealObjects); +// } +// } +// else { +//#if UNITY_EDITOR +// if (!Application.isPlaying) { +// if (handSkeleton != null) +// Object.DestroyImmediate(handSkeleton.gameObject, true); +// } +//#endif +// handSkeleton = null; +// } +// } #endregion diff --git a/Runtime/HumanoidControl/Scripts/Extensions/UnityXR/UnityXRHand.cs b/Runtime/HumanoidControl/Scripts/Extensions/UnityXR/UnityXRHand.cs index 592eb80..e324392 100644 --- a/Runtime/HumanoidControl/Scripts/Extensions/UnityXR/UnityXRHand.cs +++ b/Runtime/HumanoidControl/Scripts/Extensions/UnityXR/UnityXRHand.cs @@ -9,28 +9,7 @@ namespace Passer.Humanoid { public override string name => "Unity XR"; public override HumanoidTracker tracker => humanoid.unityXR; - // public override SensorComponent GetSensorComponent() { - // if (sensorComponent != null) - // return sensorComponent; - - // Vector3 position = handTarget.transform.TransformPoint(handTarget.isLeft ? -0.1F : 0.1F, -0.05F, 0.04F); - // Quaternion localRotation = handTarget.isLeft ? Quaternion.Euler(180, 90, 90) : Quaternion.Euler(180, -90, -90); - // Quaternion rotation = handTarget.transform.rotation * localRotation; - //#if hSTEAMVR - // if (UnityXRDevice.xrDevice == UnityXRDevice.XRDeviceType.OpenVR) { - // SteamVR steamVR = unityXR.trackerComponent as SteamVR; - // controller = steamVR.GetController(handTarget.isLeft, position, rotation); - // } - // else - //#endif - // { - // UnityXR unityXRcomponent = unityXR.trackerComponent as UnityXR; - // controller = unityXRcomponent.GetController(handTarget.isLeft, position, rotation); - // } - // return controller as SensorComponent; - // } - - protected UnityXR unityXR => tracker.trackerComponent as UnityXR; + protected UnityXR unityXR => humanoid.unityXR.trackerComponent as UnityXR; #region Manage @@ -48,6 +27,7 @@ namespace Passer.Humanoid { Vector3 position = handTarget.transform.TransformPoint(handTarget.isLeft ? -0.1F : 0.1F, -0.05F, 0.04F); Quaternion localRotation = handTarget.isLeft ? Quaternion.Euler(180, 90, 90) : Quaternion.Euler(180, -90, -90); Quaternion rotation = handTarget.transform.rotation * localRotation; + // This is depreciated, use solution like Leap or Vive Tracker sensorComponent = unityXR.GetController(handTarget.isLeft, position, rotation); }