Super Knight : Enter the Dungeon
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.

52 lines
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
public class HoldingTime : MonoBehaviour
{
[Header("오브젝트 유지 시간")]
[Range(0, 10f)]
public float duration = 1f;
private void OnEnable()
{
CancelInvoke();
Invoke("TimeOver", duration);
}
private void OnDisable()
{
CancelInvoke();
}
public void TimerStart()
{
//if (gameObject.activeSelf)
// CancelInvoke();
gameObject.SetActive(true);
}
public void TimerReStart()
{
CancelInvoke();
Invoke("TimeOver", duration);
gameObject.SetActive(true);
}
[System.Serializable]
public class TimeOverEvent : UnityEvent<object> { }
[FormerlySerializedAs("onTimeOver")]
[SerializeField]
private TimeOverEvent OnTimeOver = new TimeOverEvent();
public bool FORCE = false;
public bool HIDE = true;
void TimeOver()
{
if (gameObject.activeInHierarchy || FORCE)
OnTimeOver.Invoke(null);
if (HIDE)
gameObject.SetActive(false);
}
}