using System.Collections; using System.Collections.Generic; using UnityEngine; public class ImageEffectGeneral : PostEffectsBase{ public Shader scannerShader; private Material scannerMaterial; public Material material { get { // 检查是否生成对应材质 scannerMaterial = CheckShaderAndCreateMaterial(scannerShader, scannerMaterial); return scannerMaterial; } } //定义相关数据调整 public string dataTags = ""; public float dataScale = 1.0f; public string dataColorTags = ""; public Color dataColor = Color.white; public new void Start() { //如果需要提前规定Camera获取深度纹理或者法线纹理,需要提前声明 //GetComponent().depthTextureMode = DepthTextureMode.DepthNormals; } void OnRenderImage(RenderTexture src, RenderTexture dest) { //GetComponent().depthTextureMode = DepthTextureMode.DepthNormals; if (material != null) { //需要传入的数据,需要在Shader中定义好对应变量名称,作为传入依据。 material.SetFloat(dataTags, dataScale); material.SetColor(dataColorTags, dataColor); Graphics.Blit(src, dest, material); } else { Graphics.Blit(src, dest); } } }