using GadgetCore.API; using System.Collections; using System.Reflection; using UnityEngine; namespace ScrapYard { public class ScrapYardDecoBlinkScript : MonoBehaviour { private void Awake() { StartCoroutine(Run()); } private static Material materialOff = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("shopStand.png") }; private static Material materialOn = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = GadgetCoreAPI.LoadTexture2D("shopStand_blink.png") }; private IEnumerator Run() { while (true) { yield return new WaitForSeconds(5f + Random.Range(0, 100) / 2f); int times = Random.Range(1, 5); for (int i = 0; i < times; i++) { yield return new WaitForSeconds(0.2f + Random.Range(0, 20) / 55f); gameObject.GetComponentInChildren().material = materialOn; yield return new WaitForSeconds(0.1f + Random.Range(0, 20) / 11f); gameObject.GetComponentInChildren().material = materialOff; } } yield break; } } }