This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/Legacy/Game/Optimizer.cs
MarcoHampel f8590432ba Assemblies Made and Refactored Code Folders
Created assemblies for the new design code. Relocated legacy scripts into a legacy folder and made a "new_design" folder for new design.
2023-09-11 19:39:27 -04:00

41 lines
923 B
C#

using UnityEngine;
namespace Game {
/// <summary>
/// Attach this behavior to a master room collider. Enables everything in this room OnTriggerEnter of [tag]
/// disables everything in this room OnTriggerExit of [tag]
/// </summary>
public class Optimizer : MonoBehaviour
{
[SerializeField] public string Tag;
[SerializeField] private GameObject[] references;
[SerializeField] private bool beginDisabled = true;
private void Start()
{
if (beginDisabled) Disable();
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag(Tag)) Enable();
}
private void OnTriggerExit(Collider other)
{
if (other.CompareTag(Tag)) Disable();
}
public void Enable()
{
foreach (var go in references) go.SetActive(true);
}
public void Disable()
{
foreach (var go in references) go.SetActive(false);
}
}
}