Ejemplo n.º 1
0
        private void RefreshColliders()
        {
            // Initialize new collider array
            Collider[] grabColliders = new Collider[1];
            grabColliders = NonConvexMeshCollider.Calculate(gameObject);

            // If there is no OVRGrabbable, we can't make these colliders meaningful
            PublicOVRGrabbable ovr = GetComponent <PublicOVRGrabbable>();

            if (ovr == null)
            {
                ovr = gameObject.AddComponent <PublicOVRGrabbable>();
            }
            ovr.M_GrabPoints = grabColliders;
        }
Ejemplo n.º 2
0
        // Start is called before the first frame update
        void Start()
        {
            // Initialize new collider array
            Collider[] allColliders = new Collider[1];
            if (source == null)
            {
                allColliders = gameObject.GetComponentsInChildren <Collider>();
            }
            else
            {
                allColliders = source;
            }

            List <Collider> grabColliders = new List <Collider>(allColliders.Length / 2);

            for (int i = 0; i < allColliders.Length; i++)
            {
                if (!allColliders[i].name.Contains("RaycastTarget"))
                {
                    allColliders[i].gameObject.layer = LayerMask.NameToLayer("Grabbable");
                    allColliders[i].isTrigger        = true;
                    grabColliders.Add(allColliders[i]);
                }
            }

            allColliders = grabColliders.ToArray();

            // If there is no OVRGrabbable, we can't make these colliders meaningful
            PublicOVRGrabbable ovr = GetComponent <PublicOVRGrabbable>();

            if (ovr == null)
            {
                ovr = gameObject.AddComponent <PublicOVRGrabbable>();
            }
            ovr.M_GrabPoints = grabColliders.ToArray();

            //Destroy(this);
        }