using UnityEngine; using System.Collections; using UnityEngine.Rendering.Universal; public class LoadShader : MonoBehaviour { private float snakeTime = 0.01f; void Start() { //#if !UNITY_WEBGL || UNITY_EDITOR SetShader(transform); setgameobj(); //#endif } void setgameobj() { foreach (Transform item in transform) { if (item.gameObject.activeSelf) { StartCoroutine(setGameObj(item.gameObject)); } } } IEnumerator setGameObj(GameObject go) { go.SetActive(false); yield return new WaitForSeconds(snakeTime); go.SetActive(true); } public void SetShader(Transform child) { if (child.childCount > 0) { for (int i = 0; i < child.childCount; i++) { SetShader(child.GetChild(i)); } } else { if (child.GetComponent()) { var r = child.GetComponent(); foreach (var material in r.materials) { //Debug.Log(material.shader.name); if (material.shader.name == "Universal Render Pipeline/Lit") { StartCoroutine(setshader(material)); } } } if (child.GetComponent()) { var r = child.GetComponent().material; if (r.shader.name == "Shader Graphs/Decal_Graph2") { StartCoroutine(setshader1(r)); //Debug.Log(r.name); } } } } IEnumerator setshader(Material m) { m.shader = null; yield return new WaitForSeconds(snakeTime); m.shader = Shader.Find("Universal Render Pipeline/Lit"); } IEnumerator setshader1(Material m) { m.shader = null; yield return new WaitForSeconds(snakeTime); m.shader = Shader.Find("Shader Graphs/Decal_Graph2"); } }