GQ_Communicate/GQ_URP/GQ/Assets/script/房间检测/RoomInspection.cs

86 lines
2.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class RoomInspection : MonoBehaviour
{
public static RoomInspection Inst;
private void Awake()
{
Inst = this;
}
// Start is called before the first frame update
void Start()
{
ExtendedFlycam.Inst.peiDianShiD.SetActive(false);
ExtendedFlycam.Inst.jiFangD.SetActive(false);
}
// Update is called once per frame
void Update()
{
}
public void OnTriggerEnter(Collider other)
{
displayRoof(other.gameObject);
}
public void OnTriggerExit(Collider other)
{
hideRoof(other.gameObject);
}
/// <summary>
/// 显示屋顶
/// </summary>
public void displayRoof(GameObject other)
{
//Debug.Log(other.gameObject.name);
//if (other.gameObject != Camera.main.gameObject)
if (other != Camera.main.gameObject)
return;
if (ExtendedFlycam.Inst.room == ExtendedFlycam.Room.None)
{
if (ExtendedFlycam.Inst.jiFang[1].activeInHierarchy && ExtendedFlycam.Inst.peiDianShi[1].activeInHierarchy)
{
ExtendedFlycam.Inst.peiDianShiD.SetActive(true);
ExtendedFlycam.Inst.jiFangD.SetActive(true);
}
}
else if (ExtendedFlycam.Inst.room == ExtendedFlycam.Room.)
{
if (ExtendedFlycam.Inst.jiFang[1].activeInHierarchy)
{
ExtendedFlycam.Inst.peiDianShiD.SetActive(false);
ExtendedFlycam.Inst.jiFangD.SetActive(true);
}
}
else if (ExtendedFlycam.Inst.room == ExtendedFlycam.Room.)
{
if (ExtendedFlycam.Inst.peiDianShi[1].activeInHierarchy)
{
ExtendedFlycam.Inst.peiDianShiD.SetActive(true);
ExtendedFlycam.Inst.jiFangD.SetActive(false);
}
}
}
/// <summary>
/// 隐藏屋顶
/// </summary>
public void hideRoof(GameObject other)
{
//Debug.Log(other.gameObject.name);
//if (other.gameObject != Camera.main.gameObject)
if (other != Camera.main.gameObject)
return;
ExtendedFlycam.Inst.peiDianShiD.SetActive(false);
ExtendedFlycam.Inst.jiFangD.SetActive(false);
}
}