mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
add a cache dictionary to ShaderID
This commit is contained in:
1 parent
ca940ee210
commit
3493d0019a
1 file changed
+16
-1
@@ -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");
|
||||
|
||||
Reference in new issue
Block a user