39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using BITKit;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace BITKit.UX
|
|
{
|
|
public class UXFactory : MonoBehaviour
|
|
{
|
|
[Header(Constant.Header.Components)]
|
|
public UIDocument document;
|
|
[Header(Constant.Header.Settings)]
|
|
public string containerName;
|
|
[Header(Constant.Header.Prefabs)]
|
|
public VisualTreeAsset template;
|
|
[Header(Constant.Header.InternalVariables)]
|
|
VisualElement container;
|
|
void Awake()
|
|
{
|
|
container = document.rootVisualElement.Q(containerName);
|
|
}
|
|
public UXContainer Create()
|
|
{
|
|
return new UXContainer(Create<VisualElement>());
|
|
}
|
|
public T Create<T>() where T : VisualElement
|
|
{
|
|
var x = template.CloneTree().Q<T>();
|
|
container.Add(x);
|
|
return x;
|
|
}
|
|
public void Remove(VisualElement element)
|
|
{
|
|
container.Remove(element);
|
|
}
|
|
|
|
}
|
|
} |