示例#1
0
 protected void Start()
 {
     state              = InteractibleState.New;
     rb                 = GetComponent <Rigidbody>();
     grabbable          = GetComponent <OVRGrabbable>();
     ovrInputController = OVRInput.Controller.None;
     appear.Invoke();
 }
示例#2
0
    protected void Update()
    {
        switch (state)
        {
        case InteractibleState.New:
            if (grabbable.isGrabbed)
            {
                state = InteractibleState.PickedUp;
                ovrInputController = grabbable.grabbedBy.m_controller;
                CallPickedUp();
            }
            break;

        case InteractibleState.PickedUp:
            if (OVRInput.Get(activateButton, ovrInputController))
            {
                state = InteractibleState.ButtonDown;
                CallButtonPressed();
            }
            if (!grabbable.isGrabbed)
            {
                state = InteractibleState.Dropped;
            }
            break;

        case InteractibleState.ButtonDown:
            if (!OVRInput.Get(activateButton, ovrInputController))
            {
                state = InteractibleState.PickedUp;
                CallButtonReleased();
            }
            if (!grabbable.isGrabbed)
            {
                state = InteractibleState.Dropped;
                CallButtonReleased();
            }
            break;

        case InteractibleState.Dropped:
            CallDroppedEvent();
            state = InteractibleState.New;
            ovrInputController = OVRInput.Controller.None;

            break;

        default:
            break;
        }
    }