blob: bf9e66e21a728abe52a9ebcf6d98741532ece1ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#if UNITY_EDITOR
using UnityEngine;
[RequireComponent (typeof(Camera))]
[AddComponentMenu("")]
public class ImageEffectBase : MonoBehaviour {
/// Provides a shader property that is set in the inspector
/// and a material instantiated from the shader
public Shader m_shader;
private Material m_Material;
protected string m_shaderName = "Mobile/Diffuse";
protected virtual void Start ()
{
// Disable if we don't support image effects
if (!SystemInfo.supportsImageEffects) {
enabled = false;
return;
}
// Disable the image effect if the shader can't
// run on the users graphics card
if (!shader || !shader.isSupported)
enabled = false;
}
public virtual Shader shader
{
get
{
if (m_shader == null)
{
m_shader = Shader.Find(m_shaderName);
}
return m_shader;
}
set
{
m_shader = value;
}
}
protected Material material {
get {
if (m_Material == null) {
m_Material = new Material (shader);
m_Material.hideFlags = HideFlags.HideAndDontSave;
}
return m_Material;
}
}
protected virtual void OnDisable() {
if( m_Material ) {
DestroyImmediate( m_Material );
}
}
}
#endif
|