Code improvement
This commit is contained in:
parent
2bcf3e5c10
commit
704559e150
@ -41,37 +41,42 @@ namespace Passer.Humanoid {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if a sensorComponent is present and will create one if it does not exist
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_handTarget">The HandTarget to which the sensor is assigned</param>
|
||||||
public virtual void CheckSensor(HandTarget _handTarget) {
|
public virtual void CheckSensor(HandTarget _handTarget) {
|
||||||
if (handTarget == null)
|
if (handTarget == null)
|
||||||
target = _handTarget;
|
target = _handTarget;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void CheckSensor(HandTarget handTarget, HumanoidTracker tracker) {
|
// public virtual void CheckSensor(HandTarget handTarget, HumanoidTracker tracker) {
|
||||||
if (this.handTarget == null)
|
// if (this.handTarget == null)
|
||||||
this.target = handTarget;
|
// this.target = handTarget;
|
||||||
if (this.handTarget == null)
|
// if (this.handTarget == null)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
//if (this.tracker == null)
|
// //if (this.tracker == null)
|
||||||
// this.tracker = tracker;
|
// // this.tracker = tracker;
|
||||||
|
|
||||||
if (enabled && tracker.enabled) {
|
// if (enabled && tracker.enabled) {
|
||||||
if (handSkeleton == null) {
|
// if (handSkeleton == null) {
|
||||||
handSkeleton = FindHandSkeleton(handTarget.isLeft);
|
// handSkeleton = FindHandSkeleton(handTarget.isLeft);
|
||||||
if (handSkeleton == null)
|
// if (handSkeleton == null)
|
||||||
handSkeleton = CreateHandSkeleton(handTarget.isLeft, handTarget.showRealObjects);
|
// handSkeleton = CreateHandSkeleton(handTarget.isLeft, handTarget.showRealObjects);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
#if UNITY_EDITOR
|
//#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying) {
|
// if (!Application.isPlaying) {
|
||||||
if (handSkeleton != null)
|
// if (handSkeleton != null)
|
||||||
Object.DestroyImmediate(handSkeleton.gameObject, true);
|
// Object.DestroyImmediate(handSkeleton.gameObject, true);
|
||||||
}
|
// }
|
||||||
#endif
|
//#endif
|
||||||
handSkeleton = null;
|
// handSkeleton = null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -9,28 +9,7 @@ namespace Passer.Humanoid {
|
|||||||
public override string name => "Unity XR";
|
public override string name => "Unity XR";
|
||||||
|
|
||||||
public override HumanoidTracker tracker => humanoid.unityXR;
|
public override HumanoidTracker tracker => humanoid.unityXR;
|
||||||
// public override SensorComponent GetSensorComponent() {
|
protected UnityXR unityXR => humanoid.unityXR.trackerComponent as UnityXR;
|
||||||
// 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;
|
|
||||||
|
|
||||||
#region Manage
|
#region Manage
|
||||||
|
|
||||||
@ -48,6 +27,7 @@ namespace Passer.Humanoid {
|
|||||||
Vector3 position = handTarget.transform.TransformPoint(handTarget.isLeft ? -0.1F : 0.1F, -0.05F, 0.04F);
|
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 localRotation = handTarget.isLeft ? Quaternion.Euler(180, 90, 90) : Quaternion.Euler(180, -90, -90);
|
||||||
Quaternion rotation = handTarget.transform.rotation * localRotation;
|
Quaternion rotation = handTarget.transform.rotation * localRotation;
|
||||||
|
// This is depreciated, use solution like Leap or Vive Tracker
|
||||||
sensorComponent = unityXR.GetController(handTarget.isLeft, position, rotation);
|
sensorComponent = unityXR.GetController(handTarget.isLeft, position, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user