EnableDepthBuffer.cs 654 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using UnityEngine;
  3. namespace Leap.Unity
  4. {
  5. [ExecuteInEditMode]
  6. public class EnableDepthBuffer : MonoBehaviour
  7. {
  8. private void Awake()
  9. {
  10. base.GetComponent<Camera>().depthTextureMode = this._depthTextureMode;
  11. if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth) && this._depthTextureMode != DepthTextureMode.None)
  12. {
  13. Shader.EnableKeyword("USE_DEPTH_TEXTURE");
  14. }
  15. else
  16. {
  17. Shader.DisableKeyword("USE_DEPTH_TEXTURE");
  18. }
  19. }
  20. public const string DEPTH_TEXTURE_VARIANT_NAME = "USE_DEPTH_TEXTURE";
  21. [SerializeField]
  22. private DepthTextureMode _depthTextureMode = DepthTextureMode.Depth;
  23. }
  24. }