-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSkyboxSwapper.cs
39 lines (31 loc) · 1.14 KB
/
SkyboxSwapper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Components;
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
public class SkyboxSwapper : UdonSharpBehaviour {
public UdonSharpBehaviour self;
public GameObject[] skyboxes;
private int _skyboxIndex = 0;
private void Update() {
var skybox = skyboxes[_skyboxIndex];
if (!skybox.activeSelf) {
self.InteractionText = $"[{_skyboxIndex}/{skyboxes.Length}] [{skybox.name}] Click to Swap Skybox";
}
}
public override void Interact() {
var skybox = skyboxes[_skyboxIndex];
if (skybox.activeSelf && self.InteractionText.EndsWith("Downloading...")) {
self.InteractionText = "Click again to Skip";
return;
}
// Disable the old skybox
skybox.SetActive(false);
// Increment or loop back skybox index
_skyboxIndex = (_skyboxIndex + 1) % skyboxes.Length;
// Enable the new skybox
skyboxes[_skyboxIndex].SetActive(true);
// Set the interaction text
self.InteractionText = $"[{_skyboxIndex}/{skyboxes.Length}] [{skybox.name}] Downloading...";
}
}