Skip to content

Commit

Permalink
revert dynamic shader name stuff
Browse files Browse the repository at this point in the history
- unity can't be trusted
bump version
  • Loading branch information
SFGrenade committed Oct 20, 2024
1 parent 94ddf22 commit f55b591
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SFCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyTitle>SFCore</AssemblyTitle>
<Description>A Hollow Knight Mod Library</Description>
<Copyright>Copyright © SFGrenade 2024</Copyright>
<AssemblyVersion>1.5.12.3</AssemblyVersion>
<AssemblyVersion>1.5.12.4</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<ImplicitUsings>false</ImplicitUsings>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
Expand Down
9 changes: 8 additions & 1 deletion src/MonoBehaviours/SpritePatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace SFCore.MonoBehaviours;
/// </summary>
class SpritePatcher : MonoBehaviour
{
private static Dictionary<string, Material> _materials = new Dictionary<string, Material>();

/// <summary>
/// Shader to apply to all SpriteRenderers on this GameObject and children
/// </summary>
Expand All @@ -22,10 +24,15 @@ class SpritePatcher : MonoBehaviour
/// </summary>
public void Start()
{
if (!_materials.ContainsKey(shader))
{
var mat = new Material(Shader.Find(shader));
_materials.Add(shader, mat);
}
foreach (SpriteRenderer sr in gameObject.GetComponentsInChildren<SpriteRenderer>(true))
{
sr.gameObject.transform.localScale *= Scale;
sr.material.shader = Shader.Find(sr.material.shader.name);
sr.material = _materials[shader];
}
}
}

0 comments on commit f55b591

Please sign in to comment.