34 lines
563 B
C#
34 lines
563 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.Events;
|
||
|
|
||
|
public class LeanRepeater : MonoBehaviour
|
||
|
{
|
||
|
public int RepeateCount = -1;
|
||
|
|
||
|
public float Interval = 4f;
|
||
|
|
||
|
public bool StartOnAwake = true;
|
||
|
|
||
|
public UnityEvent Action;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
if (StartOnAwake)
|
||
|
{
|
||
|
StartRepeater();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void StartRepeater()
|
||
|
{
|
||
|
InvokeRepeating("DoAction", 0, Interval);
|
||
|
}
|
||
|
|
||
|
private void DoAction()
|
||
|
{
|
||
|
Action?.Invoke();
|
||
|
}
|
||
|
}
|