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); } } }
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); }
public static void SetLayerRecursive(this Transform transform, HVRLayers layer, Transform except = null) { var newLayer = LayerMask.NameToLayer(layer.ToString()); SetLayerRecursive(transform, newLayer, except); }