EnableCameraDepthInForward.cs 480 B

12345678910111213141516171819202122
  1. //
  2. // Attach this script to your camera in order to use depth nodes in forward rendering
  3. //
  4. using UnityEngine;
  5. using System.Collections;
  6. [RequireComponent(typeof(Camera))]
  7. public class EnableCameraDepthInForward : MonoBehaviour {
  8. #if UNITY_EDITOR
  9. void OnDrawGizmos(){
  10. Set();
  11. }
  12. #endif
  13. void Start () {
  14. Set();
  15. }
  16. void Set(){
  17. if(GetComponent<Camera>().depthTextureMode == DepthTextureMode.None)
  18. GetComponent<Camera>().depthTextureMode = DepthTextureMode.Depth;
  19. }
  20. }