2020-05-03 23:09:44 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Valve.VR.InteractionSystem;
|
|
|
|
|
using Valve.VR;
|
|
|
|
|
|
|
|
|
|
public class StartsInHand : MonoBehaviour {
|
|
|
|
|
public Hand Hand;
|
|
|
|
|
public Hand.AttachmentFlags Flags;
|
|
|
|
|
public bool StillInitiallyAttached = true;
|
|
|
|
|
public MonoBehaviour[] EnableOnDeattach;
|
|
|
|
|
|
|
|
|
|
private void Update() {
|
|
|
|
|
if (StillInitiallyAttached) {
|
2020-06-11 21:49:16 +02:00
|
|
|
|
GrabTypes GrabType = GrabTypes.Grip;
|
|
|
|
|
if (Hand.grabGripAction.state) {
|
2020-05-03 23:09:44 +02:00
|
|
|
|
StillInitiallyAttached = false;
|
|
|
|
|
GrabType = GrabTypes.Grip;
|
2020-06-11 21:49:16 +02:00
|
|
|
|
} else if (Hand.grabPinchAction.state) {
|
2020-05-03 23:09:44 +02:00
|
|
|
|
StillInitiallyAttached = false;
|
|
|
|
|
GrabType = GrabTypes.Pinch;
|
|
|
|
|
}
|
|
|
|
|
if (!StillInitiallyAttached) {
|
|
|
|
|
foreach (MonoBehaviour Component in EnableOnDeattach) {
|
|
|
|
|
Component.enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Hand.AttachObject(gameObject, GrabType, Flags);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|