Created
August 22, 2020 10:40
-
-
Save aiya000/dbb9e29816a40c99a42b68c1dff2a86f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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