把脚本 MyDepthOfField.cs 挂到main camera,注意前面的钩打上。
using UnityEngine;
using System.Collections;
public class MyDepthOfField : MonoBehaviour {
#region come from ImageEffectBase.cs
/// Provides a shader property that is set in the inspector
/// and a material instantiated from the shader
public Shader shader;
private Material m_Material;
void OnEnable() {
camera.depthTextureMode |= DepthTextureMode.Depth;
}
protected virtual void Start ()
{
// Disable if we don't support image effects
if (!SystemInfo.supportsImageEffects) {
enabled = false;
return;
}
// Disable the image effect if