36 lines
674 B
C#
36 lines
674 B
C#
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
|
|
public class SetCustomDepthNormalShader : MonoBehaviour
|
|
{
|
|
public Shader depthNormalShader;
|
|
|
|
private void Start()
|
|
{
|
|
SetCustomShader();
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
SetCustomShader();
|
|
}
|
|
|
|
private void OnValidate()
|
|
{
|
|
SetCustomShader();
|
|
}
|
|
|
|
private void SetCustomShader()
|
|
{
|
|
if (depthNormalShader != null)
|
|
{
|
|
GraphicsSettings.SetShaderMode(BuiltinShaderType.DepthNormals, BuiltinShaderMode.UseCustom);
|
|
GraphicsSettings.SetCustomShader(BuiltinShaderType.DepthNormals, depthNormalShader);
|
|
}
|
|
else
|
|
{
|
|
GraphicsSettings.SetShaderMode(BuiltinShaderType.DepthNormals, BuiltinShaderMode.UseBuiltin);
|
|
}
|
|
}
|
|
}
|