add a cache dictionary to ShaderID

This commit is contained in:
XtraCube committed 2024-08-18 12:56:22 -04:00
1 parent ca940ee210
commit 3493d0019a
1 file changed
+16 -1
+16 -1
View File
@@ -1,9 +1,24 @@
using UnityEngine;
using System.Collections.Generic;
using UnityEngine;
namespace MiraAPI.Utilities;
public static class ShaderID
{
private static readonly Dictionary<string, int> _cache = new();
public static int Get(string name)
{
if (_cache.TryGetValue(name, out var id))
{
return id;
}
id = Shader.PropertyToID(name);
_cache[name] = id;
return id;
}
// For player shader
public static readonly int _BodyColor = Shader.PropertyToID("_BodyColor");
public static readonly int _BackColor = Shader.PropertyToID("_BackColor");