IgnoreClipping.cs 689 B

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