123456789101112131415161718192021222324252627282930313233343536 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- namespace KairoEngine.UI
- {
- [CreateAssetMenu(fileName = "Ui Library", menuName = "KairoEngine/UiSystemLibrary"), HideMonoScript]
- public class UiSystemLibrary : ScriptableObject
- {
- public List<UiSystemLibraryItem> elements = new List<UiSystemLibraryItem>();
- public void Load(Transform parent)
- {
- for (int i = 0; i < elements.Count; i++) InstantiateElement(parent, i);
- }
- private void InstantiateElement(Transform parent, int index)
- {
- if(elements[index] == null)
- {
- Debug.LogError("Error loading UI Library item, missing prefab.");
- return;
- }
- var obj = GameObject.Instantiate(elements[index].uiPrefab, parent);
- obj.name = (elements[index].uiPrefab.name).Replace("Prefab", "");
- }
- }
- [System.Serializable]
- public class UiSystemLibraryItem
- {
- [HorizontalGroup("line", 0.015f), HideLabel] public bool visibleOnStart = false;
- [HorizontalGroup("line", 0.985f), HideLabel] public GameObject uiPrefab;
- }
- }
|