1
This commit is contained in:
39
Unity/Scripts/UX/Core/UXFactory.cs
Normal file
39
Unity/Scripts/UX/Core/UXFactory.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user