Tanoda
EnableDepthBuffer.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using UnityEngine;
10using System.Collections;
11
12namespace Leap.Unity{
13 [ExecuteInEditMode]
14 public class EnableDepthBuffer : MonoBehaviour {
15 public const string DEPTH_TEXTURE_VARIANT_NAME = "USE_DEPTH_TEXTURE";
16
17 [SerializeField]
18 private DepthTextureMode _depthTextureMode = DepthTextureMode.Depth;
19
20 void Awake() {
21 GetComponent<Camera>().depthTextureMode = _depthTextureMode;
22
23 if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth) &&
24 _depthTextureMode != DepthTextureMode.None) {
25 Shader.EnableKeyword(DEPTH_TEXTURE_VARIANT_NAME);
26 } else {
27 Shader.DisableKeyword(DEPTH_TEXTURE_VARIANT_NAME);
28 }
29 }
30 }
31}