mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-19 17:22:37 +08:00
fix: fixed an issue where shader variants were not registered automatically
close #383
This commit is contained in:
@@ -270,7 +270,7 @@ namespace Coffee.UIEffectInternal
|
||||
_sb.Length--; // Remove last space.
|
||||
}
|
||||
|
||||
var hash = new Hash128((uint)shader.GetInstanceID(), (uint)_sb.GetHashCode(), 0, 0);
|
||||
var hash = new Hash128((uint)shader.GetInstanceID(), (uint)GetContentsHash(_sb), 0, 0);
|
||||
if (_cachedVariants.TryGetValue(hash, out var result))
|
||||
{
|
||||
Profiler.EndSample();
|
||||
@@ -288,6 +288,17 @@ namespace Coffee.UIEffectInternal
|
||||
Profiler.EndSample();
|
||||
return (variant, pair);
|
||||
}
|
||||
|
||||
private static int GetContentsHash(StringBuilder sb)
|
||||
{
|
||||
var hash = 17;
|
||||
for (var i = 0; i < sb.Length; i++)
|
||||
{
|
||||
hash = unchecked(hash * 31 + sb[i]);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user