mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-11 04:05:11 +00:00
28 lines
744 B
C#
28 lines
744 B
C#
|
/// 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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|