36 lines
789 B
C#
36 lines
789 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class Autoportal : MonoBehaviour
|
|
{
|
|
private Transform[] imposters;
|
|
|
|
private OcclusionPortal portal;
|
|
|
|
void Start()
|
|
{
|
|
this.portal = this.GetComponent<OcclusionPortal>();
|
|
this.imposters = Array.FindAll(GetComponentsInChildren<Transform>(), child => child != this.transform);
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
this.portal.open = true;
|
|
|
|
foreach(Transform imposter in this.imposters)
|
|
{
|
|
imposter.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
this.portal.open = false;
|
|
|
|
foreach(Transform imposter in this.imposters)
|
|
{
|
|
imposter.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
}
|