CameraDepthMode.cs 460 B

12345678910111213141516171819202122
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace CalmWater
  4. {
  5. [ExecuteInEditMode]
  6. [RequireComponent(typeof(Camera))]
  7. public class CameraDepthMode : MonoBehaviour {
  8. void Start () {
  9. GetComponent<Camera>().depthTextureMode = DepthTextureMode.Depth;
  10. }
  11. void OnEnable(){
  12. GetComponent<Camera>().depthTextureMode = DepthTextureMode.Depth;
  13. }
  14. void OnDisable(){
  15. GetComponent<Camera>().depthTextureMode = DepthTextureMode.None;
  16. }
  17. }
  18. }