[SerializeField] private Canvas _canvas; // В поле в инспекторе перетаскиваешь сюда нужный канвас
_canvas.enabled = false; // чтобы отключить отображение канваса, true, чтобы включить
я программирую один и делаю игру тоже один
на данный момент мне это не нужно
using UnityEngine;
namespace Interaction
{
[RequireComponent(typeof(Collider2D))]
public abstract class InteractiveItem<TComponent> : MonoBehaviour, IInteractive
where TComponent : class
{
protected TComponent Component { get; private set; }
private void Awake()
{
GetComponent<Collider2D>().isTrigger = true;
}
public void Interact()
{
if (Component != null) InteractInternal();
}
protected abstract void InteractInternal();
private void OnTriggerEnter2D(Collider2D other)
{
if (other.TryGetComponent(out TComponent character))
{
Component = character;
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (other.TryGetComponent(out TComponent character))
{
Component = null;
}
}
}
}