CustomWater.cs 617 B

12345678910111213141516171819202122232425262728293031323334
  1. using UnityEngine;
  2. using System.Collections;
  3. [ExecuteInEditMode]
  4. public class CustomWater : MonoBehaviour
  5. {
  6. private Camera mCam;
  7. public Camera Cam
  8. {
  9. get
  10. {
  11. if (mCam == null)
  12. {
  13. mCam = Camera.main;
  14. }
  15. return mCam;
  16. }
  17. }
  18. private void OnEnable()
  19. {
  20. if (Cam != null)
  21. {
  22. Cam.depthTextureMode |= DepthTextureMode.Depth;
  23. }
  24. }
  25. private void OnDisable()
  26. {
  27. if (Cam != null)
  28. {
  29. Cam.depthTextureMode &= ~DepthTextureMode.Depth;
  30. }
  31. }
  32. }