Files
kaiju/Assets/Loader.cs
T
2022-02-03 12:30:45 +11:00

49 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;
public class Loader : MonoBehaviour {
public KeyCode NextButton = KeyCode.Space;
public KeyCode PrevButton = KeyCode.Return;
public GameObject[] vis;
private int _current = 0;
private int _count;
void Awake() {
vis = GameObject.FindGameObjectsWithTag("VFX");
foreach (GameObject v in vis) {
v.SetActive(false);
v.GetComponent<VisualEffect>().enabled = true;
}
_count = vis.Length;
}
void Start() {
foreach (GameObject v in vis) {
Debug.Log(v.ToString());
}
Debug.Log($"{_current}, {_count}");
vis[_current].SetActive(true);
}
void Update() {
if (Input.GetKeyDown(NextButton)) {
LoadNextVis();
}
}
void LoadNextVis() {
vis[_current].SetActive(false);
int next = (_current + 1) % _count;
_current = next;
vis[next].SetActive(true);
}
}