This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
monsterstalker/Assets/Scripts/Arrows.cs
T
2018-04-13 10:40:35 +10:00

34 lines
610 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Arrows : MonoBehaviour {
SpriteRenderer spriteRenderer;
void Awake() {
spriteRenderer = GetComponent<SpriteRenderer> ();
StartCoroutine (FadeCoroutine (0.01f));
}
IEnumerator FadeCoroutine(float period) {
float absolute = 1.0f;
float degree = -0.01f;
while(true) {
//wait
yield return new WaitForSeconds (period);
//fade routine
absolute += degree;
//fade
spriteRenderer.color = new Color (1, 1, 1, absolute);
if (absolute == 0f) {
Destroy (gameObject);
}
}
}
}