generated from raccoon/vrchat-project-template
Added textures and materials and scene from half-life 2
This commit is contained in:
53
Assets/occlusion-portals/script/Areaportal.cs
Normal file
53
Assets/occlusion-portals/script/Areaportal.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon;
|
||||
|
||||
public class Areaportal : UdonSharpBehaviour
|
||||
{
|
||||
private OcclusionPortal portal;
|
||||
|
||||
private GameObject[] imposters;
|
||||
|
||||
void Start()
|
||||
{
|
||||
this.portal = this.GetComponent<OcclusionPortal>();
|
||||
this.imposters = new GameObject[this.transform.childCount];
|
||||
|
||||
// Ёбаный рот этого UdonSharp
|
||||
int i = 0;
|
||||
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)
|
||||
{
|
||||
this.SetPortalOpenState(true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPlayerTriggerExit(VRCPlayerApi player)
|
||||
{
|
||||
if (player.IsValid() && player.isLocal)
|
||||
{
|
||||
this.SetPortalOpenState(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user