IgnoreClipping.cs 599 B

1234567891011121314151617181920
  1. using UnityEngine;
  2. public class IgnoreClipping : MonoBehaviour
  3. {
  4. public int ignoreClippingLayer = 13;
  5. public float preClippingDistance = 1000f;
  6. public int smallObjectsLayer = 14;
  7. public float smallObjectsDistance = 200f;
  8. private void Start()
  9. {
  10. var cam = GetComponent<Camera>();
  11. var distances = new float[32];
  12. for (var i = 0; i < distances.Length; i++) distances[i] = preClippingDistance;
  13. distances[ignoreClippingLayer] = 0f;
  14. distances[smallObjectsLayer] = smallObjectsDistance;
  15. cam.layerCullDistances = distances;
  16. }
  17. }