2023-10-30 12:23:06 +03:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class DisableAfterFinish : MonoBehaviour
|
|
|
|
{
|
|
|
|
private DisableAfterFinishController disableController;
|
2023-10-30 18:06:30 +03:00
|
|
|
[SerializeField] private GameObject _target;
|
|
|
|
|
|
|
|
public bool DisableState = false;
|
|
|
|
|
2023-10-30 12:23:06 +03:00
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
disableController = FindObjectOfType<DisableAfterFinishController>();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
2023-10-31 11:52:24 +03:00
|
|
|
if (disableController == null)
|
|
|
|
return;
|
|
|
|
|
2023-10-30 12:23:06 +03:00
|
|
|
disableController.DoDisable += Disable;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
{
|
2023-10-31 11:52:24 +03:00
|
|
|
if (disableController == null)
|
|
|
|
return;
|
|
|
|
|
2023-10-30 12:23:06 +03:00
|
|
|
disableController.DoDisable -= Disable;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Disable()
|
|
|
|
{
|
2023-10-30 18:06:30 +03:00
|
|
|
if (_target == null)
|
|
|
|
gameObject.SetActive(DisableState);
|
|
|
|
else
|
|
|
|
_target.SetActive(DisableState);
|
2023-10-30 12:23:06 +03:00
|
|
|
}
|
|
|
|
}
|