OldBlueWater/BlueWater/Assets/Doozy/Runtime/UIManager/Containers/Internal/UIContainerComponent.cs
2023-08-02 15:08:03 +09:00

39 lines
1.1 KiB
C#

// Copyright (c) 2015 - 2023 Doozy Entertainment. All Rights Reserved.
// This code can only be used under the standard Unity Asset Store End User License Agreement
// A Copy of the EULA APPENDIX 1 is available at http://unity3d.com/company/legal/as_terms
using System.Collections.Generic;
using Doozy.Runtime.Common.Attributes;
// ReSharper disable MemberCanBeProtected.Global
// ReSharper disable MemberCanBePrivate.Global
namespace Doozy.Runtime.UIManager.Containers.Internal
{
public abstract class UIContainerComponent<T> : UIContainer where T : UIContainer
{
[ClearOnReload]
public static HashSet<T> database { get; } = new HashSet<T>();
public T component { get; private set; }
protected override void Awake()
{
database.Add(component = GetComponent<T>());
base.Awake();
}
protected override void OnEnable()
{
database.Remove(null);
base.OnEnable();
}
protected override void OnDestroy()
{
database.Remove(component);
database.Remove(null);
base.OnDestroy();
}
}
}