30 lines
952 B
C#
30 lines
952 B
C#
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) {
|
|
GrabTypes GrabType = GrabTypes.Grip;
|
|
if (Hand.grabGripAction.state) {
|
|
StillInitiallyAttached = false;
|
|
GrabType = GrabTypes.Grip;
|
|
} else if (Hand.grabPinchAction.state) {
|
|
StillInitiallyAttached = false;
|
|
GrabType = GrabTypes.Pinch;
|
|
}
|
|
if (!StillInitiallyAttached) {
|
|
foreach (MonoBehaviour Component in EnableOnDeattach) {
|
|
Component.enabled = true;
|
|
}
|
|
}
|
|
Hand.AttachObject(gameObject, GrabType, Flags);
|
|
}
|
|
}
|
|
}
|