UINested.cs 776 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. using XGame.Framework.ObjectCollection;
  3. namespace XGame.Framework.UI
  4. {
  5. [DisallowMultipleComponent]
  6. [AddComponentMenu("XGame/UI/UINested")]
  7. public class UINested : MonoBehaviour, IUINested, IComponentGetter
  8. {
  9. [SerializeField]
  10. private ObjectCollector _collector = new ObjectCollector();
  11. Transform IUINested.Tr => transform;
  12. bool IUINested.IsActiveSelf => gameObject.activeSelf;
  13. bool IUINested.IsActiveInHierarchy => gameObject.activeInHierarchy;
  14. void IUINested.SetActive(bool isActive)
  15. {
  16. gameObject.SetActive(isActive);
  17. }
  18. T IComponentGetter.GetComponent<T>(string key)
  19. {
  20. return _collector.GetComponent<T>(key);
  21. }
  22. }
  23. }