using System.Collections; using UnityEngine; namespace Script.RuntimeScript.GameLogic { public class PropSparkItem : MonoBehaviour { Transform fx_diggingitem_spark; private void Awake() { fx_diggingitem_spark = transform.Find("PositionRoot/AnimationRoot/fx_diggingitem_spark"); } public void Init(float ItemFxScale) { if (fx_diggingitem_spark) { fx_diggingitem_spark.localScale = Vector3.one * ItemFxScale; StartCoroutine(PlaySpark()); } } IEnumerator PlaySpark() { while (true) { int seconds = Random.Range(2, 4); yield return new WaitForSeconds(seconds); fx_diggingitem_spark.gameObject.SetActive(true); seconds = Random.Range(2, 4); yield return new WaitForSeconds(seconds); fx_diggingitem_spark.gameObject.SetActive(false); } } private void OnDisable() { StopAllCoroutines(); } } }