예제 #1
0
 void Intract()
 {
     //We set up the input "OculusTouchpad" in the Input manager
     if (Input.GetButtonDown("Jump") || OVRInput.GetDown(OVRInput.Button.PrimaryTouchpad))
     {
         selectVisual.ClearObject();
         //Check if you are holding something you can throw first
         if (inHand != null)
         {
             inHand.Release(controllerRef.forward, throwForce);
             inHand = null;
             //We do this check here to prevent Errors if you have nothing selected
         }
         else if (selectedObject != null)
         {
             //Check if you can pick up the selected object second
             if (selectedObject.GetComponent <PickUp> ())
             {
                 //Beacuse PickUp is a child of PropBase, we can ask InHand to store selectedObject as PickUp, rather than use GetComponent
                 inHand = selectedObject as PickUp;
                 inHand.Store(holdingRef);
                 //If non of the above were valid then simple call the trigger function of the selected object
             }
             else
             {
                 selectedObject.Trigger();
             }
         }
         //If you have a object that you need to hold down a button to intract with
     }
     else if (Input.GetButton("Jump") && selectedObject != null || OVRInput.Get(OVRInput.Button.PrimaryTouchpad) && selectedObject != null)
     {
         selectedObject.Pulse();
         //When you are not pressing down the touchpad button, the selected object can be updated
     }
     else if (pointerOver != null)
     {
         if (pointerOver.GetComponent <PropBase> ())
         {
             selectedObject = pointerOver.GetComponent <PropBase> ();
         }
         else
         {
             selectedObject = null;
         }
     }
     else
     {
         selectedObject = null;
     }
 }