You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							51 lines
						
					
					
						
							1.3 KiB
						
					
					
				
			
		
		
	
	
							51 lines
						
					
					
						
							1.3 KiB
						
					
					
				| using UnityEngine; | |
| using System.Collections; | |
|  | |
| public class LoadShader : MonoBehaviour | |
| { | |
|     // Start is called once before the first execution of Update after the MonoBehaviour is created | |
|     void Start() | |
|     { | |
| #if !UNITY_WEBGL || UNITY_EDITOR | |
|         SetShader(transform); | |
| #endif | |
|     } | |
|  | |
|     // Update is called once per frame | |
|     void Update() | |
|     { | |
|  | |
|     } | |
|     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<Renderer>()) | |
|             { | |
|                 var r = child.GetComponent<Renderer>(); | |
|                 foreach (var material in r.materials) | |
|                 { | |
|                     //Debug.Log(material.shader.name); | |
|                     if (material.shader.name == "Universal Render Pipeline/Lit") | |
|                     { | |
|                         StartCoroutine(setshader(material)); | |
|                     } | |
|                 } | |
|             } | |
|         } | |
|     } | |
|  | |
|     IEnumerator setshader(Material m) | |
|     { | |
|         m.shader = null; | |
|         yield return new WaitForSeconds(0.1f); | |
|         m.shader = Shader.Find("Universal Render Pipeline/Lit"); | |
|     } | |
| }
 | |
| 
 |