UnityMol  0.9.6-875
UnityMol viewer / In developement
ImageEffectBase2.cs
Go to the documentation of this file.
1 using UnityEngine;
2 
3 [RequireComponent (typeof(Camera))]
4 [AddComponentMenu("")]
5 public class ImageEffectBase2 : MonoBehaviour {
8  public Shader shader;
9  private Material m_Material;
10 
11  protected void Start ()
12  {
13  // Disable if we don't support image effects
14  if (!SystemInfo.supportsImageEffects) {
15  enabled = false;
16  return;
17  }
18 
19  // Disable the image effect if the shader can't
20  // run on the users graphics card
21  if (!shader || !shader.isSupported)
22  enabled = false;
23  }
24 
25  protected Material material {
26  get {
27  if (m_Material == null) {
28  m_Material = new Material (shader);
29  m_Material.hideFlags = HideFlags.HideAndDontSave;
30  }
31  return m_Material;
32  }
33  }
34 
35  protected void OnDisable() {
36  if( m_Material ) {
37  DestroyImmediate( m_Material );
38  }
39  }
40 }
Shader shader
Provides a shader property that is set in the inspector and a material instantiated from the shader...