예제 #1
0
        private void IgnoreAllBut(HVRLayers one, HVRLayers but)
        {
            var layerOne = LayerMask.NameToLayer(one.ToString());
            var layerTwo = LayerMask.NameToLayer(but.ToString());

            if (layerOne < 0)
            {
                Debug.LogWarning($"{one} layer does not exist.");
            }

            if (layerTwo < 0)
            {
                Debug.LogWarning($"{but} layer does not exist.");
            }

            if (layerOne < 0 || layerTwo < 0)
            {
                return;
            }

            for (int i = 0; i < 32; i++)
            {
                if (i == layerTwo)
                {
                    Physics.IgnoreLayerCollision(layerOne, i, false);
                }
                else
                {
                    Physics.IgnoreLayerCollision(layerOne, i, true);
                }
            }
        }
예제 #2
0
        private void SetLayer(HVRLayers one, HVRLayers two, bool ignore = true)
        {
            var layerOne = LayerMask.NameToLayer(one.ToString());
            var layerTwo = LayerMask.NameToLayer(two.ToString());

            if (layerOne < 0)
            {
                Debug.LogWarning($"{one} layer does not exist.");
            }

            if (layerTwo < 0)
            {
                Debug.LogWarning($"{two} layer does not exist.");
            }

            if (layerOne < 0 || layerTwo < 0)
            {
                return;
            }

            Physics.IgnoreLayerCollision(layerOne, layerTwo, ignore);
        }
예제 #3
0
        public static void SetLayerRecursive(this Transform transform, HVRLayers layer, Transform except = null)
        {
            var newLayer = LayerMask.NameToLayer(layer.ToString());

            SetLayerRecursive(transform, newLayer, except);
        }