HeavenStudioPlus/Assets/Plugins/com.unity.uiextensions/Runtime/Scripts/Utilities/ShaderLibrary.cs

28 lines
744 B
C#
Raw Normal View History

2022-01-06 00:11:33 +00:00
/// Credit SimonDarksideJ
using System.Collections.Generic;
namespace UnityEngine.UI.Extensions
{
public static class ShaderLibrary
{
public static Dictionary<string, Shader> shaderInstances = new Dictionary<string, Shader>();
public static Shader[] preLoadedShaders;
public static Shader GetShaderInstance(string shaderName)
{
if (shaderInstances.ContainsKey(shaderName))
{
return shaderInstances[shaderName];
}
var newInstance = Shader.Find(shaderName);
if (newInstance != null)
{
shaderInstances.Add(shaderName, newInstance);
}
return newInstance;
}
}
}