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.
82 lines
2.1 KiB
82 lines
2.1 KiB
2 months ago
|
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<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));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (child.GetComponent<DecalProjector>())
|
||
|
{
|
||
|
var r = child.GetComponent<DecalProjector>().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");
|
||
|
}
|
||
|
}
|