56 lines
1.2 KiB
C#
56 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class OpenPanelOnCollision : MonoBehaviour
|
|
{
|
|
|
|
public GameObject Panel;
|
|
public GameObject OtherPanel;
|
|
public GameObject SecondPanel;
|
|
public GameObject PanelAbove;
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if(collision.tag == "Player")
|
|
{
|
|
if(SecondPanel.active == false)
|
|
{
|
|
Panel.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
PanelAbove.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if(OtherPanel.active == true)
|
|
{
|
|
Panel.SetActive(false);
|
|
}
|
|
if(SecondPanel.active == false)
|
|
{
|
|
if(PanelAbove.active == true)
|
|
{
|
|
PanelAbove.SetActive(false);
|
|
Panel.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit2D(Collider2D collision)
|
|
{
|
|
if(Panel.active == true)
|
|
{
|
|
Panel.SetActive(false);
|
|
}
|
|
else if(PanelAbove.active == true)
|
|
{
|
|
PanelAbove.SetActive(false);
|
|
}
|
|
}
|
|
}
|