Made children spawn as UI elements

This commit is contained in:
Pasha Bibko
2026-01-13 10:27:24 +00:00
parent 8b648fd690
commit fcbbed1db8
2 changed files with 41 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ namespace InterfaceOff
{
private List<Type> WindowTypes { get; } = new();
[field: SerializeField] private GameObject SampleChild { get; set; }
[field: SerializeField] private Canvas GameCanvas { get; set; }
private void Awake()
@@ -34,9 +35,8 @@ namespace InterfaceOff
{
if (Input.GetKeyDown(KeyCode.Space))
{
GameObject go = Instantiate(SampleChild, GameCanvas.transform);
Type type = WindowTypes.GetRandom();
GameObject go = new();
go.transform.SetParent(GameCanvas.transform);
WindowBase windowBase = go.AddComponent(type) as WindowBase;
if (DebugUtils.IsNull(windowBase))