mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-30 00:48:00 +01:00
55 lines
1.3 KiB
C#
55 lines
1.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityStandardAssets.ImageEffects
|
|
{
|
|
[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 shader;
|
|
|
|
private Material m_Material;
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|