Exemplo n.º 1
0
        void OnTriggerEnter(Collider other)
        {
            VRObject obj = other.GetComponent <VRObject> ();

            if (obj == null)
            {
                obj = other.GetComponentInParent <VRObject> ();
            }

            if (obj != null)
            {
                intersecting.Add(other);
            }
        }
Exemplo n.º 2
0
        public VRObject FindObject(Vector3 pos)
        {
            Collider closest = null;
            float    dist    = 0;

            foreach (Collider c in intersecting)
            {
                if (c && c.enabled && c.gameObject.activeInHierarchy)
                {
                    float d = Vector3.Distance(pos, c.ClosestPoint(pos));
                    if (closest == null || d < dist)
                    {
                        dist    = d;
                        closest = c;
                    }
                }
            }

            return(closest ? VRObject.GetOwner(closest) : null);
        }