6 #if UNITY_WSA && UNITY_2017_2_OR_NEWER 10 namespace HoloToolkit.Unity.InputModule.Examples.Grabbables
19 private LayerMask grabbableLayers = ~0;
21 #if UNITY_WSA && UNITY_2017_2_OR_NEWER 23 private InteractionSourcePressType pressType = InteractionSourcePressType.None;
30 #if UNITY_WSA && UNITY_2017_2_OR_NEWER 31 InteractionManager.InteractionSourcePressed += InteractionSourcePressed;
32 InteractionManager.InteractionSourceReleased += InteractionSourceReleased;
38 #if UNITY_WSA && UNITY_2017_2_OR_NEWER 39 InteractionManager.InteractionSourcePressed -= InteractionSourcePressed;
40 InteractionManager.InteractionSourceReleased -= InteractionSourceReleased;
45 #if UNITY_WSA && UNITY_2017_2_OR_NEWER 46 private void InteractionSourcePressed(InteractionSourcePressedEventArgs obj)
48 if (obj.pressType == pressType && obj.state.source.handedness == handedness)
54 private void InteractionSourceReleased(InteractionSourceReleasedEventArgs obj)
56 if (obj.pressType == pressType && obj.state.source.handedness == handedness)
58 TrySetThrowableObject(GrabbedObjects.Count > 0 ? GrabbedObjects[0] : null, obj.state.sourcePose);
70 Debug.Log(
"Entered trigger with " + other.name);
71 if (((1 << other.gameObject.layer) & grabbableLayers.value) == 0)
77 if (bg == null && other.attachedRigidbody != null)
87 Debug.Log(
"Adding contact");
94 Debug.Log(
"Exited trigger with " + other.name);
95 if (((1 << other.gameObject.layer) & grabbableLayers.value) == 0)
101 if (bg == null && other.attachedRigidbody != null)
111 Debug.Log(
"Removing contact");
116 #if UNITY_WSA && UNITY_2017_2_OR_NEWER 117 public bool TrySetThrowableObject(
BaseGrabbable grabbable, InteractionSourcePose poseInfo)
119 if (grabbable == null)
129 if (!grabbable.GetComponent<Rigidbody>())
134 Rigidbody rb = grabbable.GetComponent<Rigidbody>();
135 Debug.Log(
"name of our rb.center of mass ========= " + rb.name);
136 ControllerReleaseData controlReleaseData = grabbable.GetComponent<Rigidbody>().GetThrowReleasedVelocityAndAngularVelocity(rb.centerOfMass, poseInfo);