You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.3 KiB
58 lines
1.3 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
|
||
|
[ExecuteInEditMode]
|
||
|
[RequireComponent (typeof(Camera))]
|
||
|
public class PostEffectsBase : MonoBehaviour {
|
||
|
|
||
|
// Called when start
|
||
|
protected void CheckResources() {
|
||
|
bool isSupported = CheckSupport();
|
||
|
|
||
|
if (isSupported == false) {
|
||
|
NotSupported();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Called in CheckResources to check support on this platform
|
||
|
protected bool CheckSupport() {
|
||
|
if (SystemInfo.supportsImageEffects == false || SystemInfo.supportsRenderTextures == false) {
|
||
|
Debug.LogWarning("This platform does not support image effects or render textures.");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
// Called when the platform doesn't support this effect
|
||
|
protected void NotSupported() {
|
||
|
enabled = false;
|
||
|
}
|
||
|
|
||
|
protected void Start() {
|
||
|
CheckResources();
|
||
|
}
|
||
|
|
||
|
// Called when need to create the material used by this effect
|
||
|
protected Material CheckShaderAndCreateMaterial(Shader shader, Material material) {
|
||
|
if (shader == null) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
if (shader.isSupported && material && material.shader == shader)
|
||
|
return material;
|
||
|
|
||
|
if (!shader.isSupported) {
|
||
|
return null;
|
||
|
}
|
||
|
else {
|
||
|
material = new Material(shader);
|
||
|
material.hideFlags = HideFlags.DontSave;
|
||
|
if (material)
|
||
|
return material;
|
||
|
else
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
}
|