mirror of
https://github.com/ApfelTeeSaft/Slender.git
synced 2026-09-02 12:03:36 +00:00
44 lines
686 B
C#
44 lines
686 B
C#
using UnityEngine;
|
|
|
|
[AddComponentMenu("")]
|
|
[RequireComponent(typeof(Camera))]
|
|
public class ImageEffectBase : MonoBehaviour
|
|
{
|
|
public Shader shader;
|
|
|
|
private Material m_Material;
|
|
|
|
protected Material material
|
|
{
|
|
get
|
|
{
|
|
if (m_Material == null)
|
|
{
|
|
m_Material = new Material(shader);
|
|
m_Material.hideFlags = HideFlags.HideAndDontSave;
|
|
}
|
|
return m_Material;
|
|
}
|
|
}
|
|
|
|
protected virtual void Start()
|
|
{
|
|
if (!SystemInfo.supportsImageEffects)
|
|
{
|
|
base.enabled = false;
|
|
}
|
|
else if (!shader || !shader.isSupported)
|
|
{
|
|
base.enabled = false;
|
|
}
|
|
}
|
|
|
|
protected virtual void OnDisable()
|
|
{
|
|
if ((bool)m_Material)
|
|
{
|
|
Object.DestroyImmediate(m_Material);
|
|
}
|
|
}
|
|
}
|