BS 0.2.0 Visual

This commit is contained in:
2025-07-21 15:58:52 +08:00
parent f6750189d0
commit d0e5420f95
142 changed files with 11176 additions and 11 deletions

View File

@@ -0,0 +1,49 @@
using System.Collections.Generic;
using Convention.WindowsUI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Convention
{
public class CustomMenu : WindowsComponent
{
[Setting, SerializeField] private bool IsDestroy = true;
[Resources, SerializeField, OnlyNotNullMode] private Button ButtonPrefab;
[Resources, SerializeField, OnlyNotNullMode] private RectTransform Plane;
[Content] public List<GameObject> childs = new();
[Content, OnlyPlayMode]
[return: IsInstantiated(true)]
public virtual Button CreateItem()
{
var item = GameObject.Instantiate(ButtonPrefab, Plane).GetComponent<Button>();
item.gameObject.SetActive(true);
childs.Add(item.gameObject);
return item;
}
[return: IsInstantiated(true)]
public virtual Button CreateItem(UnityAction callback, string title)
{
var item = CreateItem();
item.onClick.AddListener(callback);
item.GetComponents<IText>()[0].text = title;
return item;
}
public virtual void ClearAllItem()
{
foreach (var child in childs)
{
GameObject.Destroy(child);
}
childs.Clear();
}
public virtual void ReleaseMenu()
{
if (IsDestroy)
Destroy(this.gameObject);
else
gameObject.SetActive(false);
}
}
}