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.
33 lines
626 B
33 lines
626 B
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class ObjectBlink : MonoBehaviour |
|
{ |
|
public float duration = 1f; |
|
public float tick = 0.1f; |
|
public void Play() |
|
{ |
|
CancelInvoke(); |
|
|
|
timeSum = 0; |
|
InvokeRepeating("Blink", 0, tick); |
|
} |
|
public void Stop() |
|
{ |
|
CancelInvoke(); |
|
} |
|
float timeSum = 0; |
|
void Blink() |
|
{ |
|
gameObject.SetActive(!gameObject.activeSelf); |
|
|
|
timeSum += tick; |
|
if (duration < timeSum) |
|
{ |
|
CancelInvoke(); |
|
|
|
gameObject.SetActive(true); |
|
} |
|
} |
|
}
|
|
|