Files
back_cantanBuilding/Assets/Scripts/SandDig/GameScript/PropSparkItem.cs
2026-05-26 16:15:54 +08:00

39 lines
1.1 KiB
C#

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();
}
}
}