Skip to content

Instantly share code, notes, and snippets.

@aiya000
Created August 22, 2020 10:40
Show Gist options
  • Save aiya000/dbb9e29816a40c99a42b68c1dff2a86f to your computer and use it in GitHub Desktop.
Save aiya000/dbb9e29816a40c99a42b68c1dff2a86f to your computer and use it in GitHub Desktop.
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class Switch4OrNothing : UdonSharpBehaviour {
public GameObject first;
public GameObject second;
public GameObject third;
public GameObject fourth;
public override void Interact() {
if (this.first == null || this.second == null || this.third == null || this.fourth == null) {
Debug.Log("Either the first, the second, the third, or the fourth has not set.");
return;
}
var xs = new GameObject[] { first, second, third, fourth };
for (var i = 0; i < xs.Length - 1; i++) {
if (xs[i].activeSelf) {
this.inactivateAll(xs);
xs[i + 1].SetActive(true);
return;
}
}
xs[0].SetActive(true);
}
private void inactivateAll(GameObject[] xs) {
foreach (var x in xs) {
x.SetActive(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment