Created
December 4, 2025 18:26
-
-
Save FroggerHH/7063a564c636e1505afb7cdb2cc9787e to your computer and use it in GitHub Desktop.
Find Valheim shaders references
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Text; | |
| using HarmonyLib; | |
| using UnityEngine; | |
| [HarmonyPatch, HarmonyWrapSafe] | |
| file static class FindShaderReferences | |
| { | |
| private const string TARGET_SHADER_NAME = "Standard"; | |
| [HarmonyPrefix] | |
| [HarmonyPatch(typeof(Player), nameof(Player.Start), [])] | |
| private static void LogShadersRefs() | |
| { | |
| if(!ZNetScene.instance) return; | |
| foreach (var meshRenderer in ZNetScene.instance.m_prefabs.SelectMany(x => x.GetComponentsInChildren<MeshRenderer>()).Where(x=>x)) | |
| foreach (var material in meshRenderer.sharedMaterials.Where(x=>x)) | |
| { | |
| if(material.shader?.name != TARGET_SHADER_NAME) continue; | |
| var referencePath = new StringBuilder(); | |
| var parent = meshRenderer.transform.parent; | |
| while (parent) | |
| { | |
| referencePath.Insert(0, $"{parent.name} -> "); | |
| parent = parent.transform.parent; | |
| } | |
| referencePath.Append($"{meshRenderer.name}"); | |
| Debug.Log($"Found {TARGET_SHADER_NAME} shader in {referencePath}"); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment