using UnityEngine;
using XGame.Framework.ObjectCollection;

namespace XGame.Framework.UI
{
    [DisallowMultipleComponent]
    [AddComponentMenu("XGame/UI/UINested")]
    public class UINested : MonoBehaviour, IUINested, IComponentGetter
    {
        [SerializeField]
        private ObjectCollector _collector = new ObjectCollector();

        Transform IUINested.Tr => transform;
        bool IUINested.IsActiveSelf => gameObject.activeSelf;

        bool IUINested.IsActiveInHierarchy => gameObject.activeInHierarchy;


        void IUINested.SetActive(bool isActive)
        {
            gameObject.SetActive(isActive);
        }
        T IComponentGetter.GetComponent<T>(string key)
        {
            return _collector.GetComponent<T>(key);
        }


    }
}
