コード例 #1
0
 void acceptAction(VRSimPickupObject pickupObj)
 {
     strobeColour(AcceptColor, NormalColor, 0.5f);
     if (AcceptSound)
     {
         AudioSource.PlayClipAtPoint(AcceptSound, transform.position);
     }
 }
コード例 #2
0
    /// <summary>
    ///   Attempts to pickup an object of type VRSimPickupObject
    /// </summary>
    /// <returns>The object.</returns>
    public VRSimPickupObject pickupObject(VRSimHandInteraction hand)
    {
        VRSimPickupObject nearestObject = NearestObjectToHand(hand);

        if (nearestObject)
        {
            nearestObject.Hilight = false;
        }
        return(nearestObject);
    }
コード例 #3
0
 // Clear all the colour, state, and receivedObjects.
 void resetReceived()
 {
     for (int i = 0; i < m_receivedObjects.Count; i++)
     {
         VRSimPickupObject o = m_receivedObjects[i];
         if (o != null)
         {
             o.returnHome();
             m_receivedObjects[i] = null;
         }
     }
 }
コード例 #4
0
    protected void pickupObject()
    {
        if (m_pickupArea == null)
        {
            return;
        }

        VRSimPickupObject obj = m_pickupArea.pickupObject(this);

        if (obj != null)
        {
            PickupObject = obj;
            m_pickupObject.ParentHand = this;
        }
        else
        {
            // Nothing to pickup, so attempt picking up from the other hand.
        }
    }
コード例 #5
0
    public bool receiveObject(VRSimPickupObject pickupObj)
    {
        for (int i = 0; i < AcceptList.Count; i++)
        {
            if (m_receivedObjects[i] == null &&
                AcceptList[i].Equals(pickupObj.gameObject.name))
            {
                m_receivedObjects[i]       = pickupObj;
                pickupObj.transform.parent = transform;

                acceptAction(pickupObj);
                return(true);
            }
        }

        pickupObj.returnHome();
        rejectAction();
        return(false);
    }
コード例 #6
0
    protected VRSimPickupObject NearestObjectToHand(VRSimHandInteraction hand)
    {
        Component[] pickupObjects = gameObject.GetComponentsInChildren <VRSimPickupObject>();

        VRSimPickupObject nearest          = null;
        float             nearestMagnitude = float.MaxValue;
        float             pickDistSquared  = PickDistance * PickDistance;

        foreach (VRSimPickupObject obj in pickupObjects)
        {
            float magnitude = (hand.PickupPoint - obj.transform.position).sqrMagnitude;
            if (magnitude < nearestMagnitude && magnitude < pickDistSquared)
            {
                nearest          = obj;
                nearestMagnitude = magnitude;
            }
        }

        return(nearest);
    }
コード例 #7
0
    // Check through all pickupObjects that we are the parent of,
    // hilight the nearest if a Hand Interaction is in the volume.
    void Update()
    {
        Component[] pickupObjects = gameObject.GetComponentsInChildren <VRSimPickupObject>();
        if (pickupObjects == null)
        {
            return;
        }

        List <VRSimPickupObject> nearestPickupObjects = new List <VRSimPickupObject>(m_hands.Count);

        foreach (VRSimHandInteraction hand in m_hands)
        {
            // Skip hands with something in them.
            if (hand.PickupObject != null)
            {
                continue;
            }

            VRSimPickupObject nearest = NearestObjectToHand(hand);
            if (nearest)
            {
                nearestPickupObjects.Add(nearest);
            }
        }

        foreach (VRSimPickupObject obj in pickupObjects)
        {
            if (obj.Hilight == true && nearestPickupObjects.Contains(obj) == false)
            {
                obj.Hilight = false;
            }
            else if (obj.Hilight == false && nearestPickupObjects.Contains(obj))
            {
                obj.Hilight = true;
            }
        }
    }