Some fixes and better code

This commit is contained in:
raccoon
2024-12-17 06:24:54 +05:00
parent 8f819742c8
commit 5d03586c8b
2 changed files with 133 additions and 17 deletions

View File

@@ -21,32 +21,33 @@ public class Areaportal : UdonSharpBehaviour
foreach(Transform child in this.transform)
{
this.imposters[i++] = child.gameObject;
child.gameObject.SetActive(!this.portal.open);
}
}
public void SetPortalOpenState(bool state)
{
this.portal.open = state;
foreach(GameObject imposter in this.imposters)
{
imposter.SetActive(!state);
}
}
public override void OnPlayerTriggerEnter(VRCPlayerApi player)
{
if (!(player.IsValid() && player.isLocal))
return;
this.portal.open = true;
foreach(GameObject imposter in this.imposters)
if (player.IsValid() && player.isLocal)
{
imposter.SetActive(false);
this.SetPortalOpenState(true);
}
}
public override void OnPlayerTriggerExit(VRCPlayerApi player)
{
if (!(player.IsValid() && player.isLocal))
return;
this.portal.open = false;
foreach(GameObject imposter in this.imposters)
if (player.IsValid() && player.isLocal)
{
imposter.SetActive(true);
this.SetPortalOpenState(false);
}
}
}