com.soviby.unity.ui.ugui-to.../Assets/Editor/Manager/EntityManager.cs

46 lines
1.3 KiB
C#
Raw Normal View History

2024-10-23 17:30:59 +00:00
#if UNITY_EDITOR
using UnityEngine;
namespace UguiToolkit.Editor
{
public class EntityManager : MonoBehaviour, IManager
{
private PanelCache m_panelCache;
private Transform entityRoot;
public void InitAllEntity(PanelCache panelCache)
{
this.m_panelCache = panelCache;
// 创建所有实例
CreateAllEntity();
}
private void CreateAllEntity()
{
if (this.m_panelCache == null) return;
var go = new GameObject();
entityRoot = go.transform;
entityRoot.SetParent(transform);
entityRoot.localPosition = Vector3.zero;
entityRoot.localRotation = Quaternion.identity;
entityRoot.localScale = Vector3.one;
// Image
foreach (var elementInfo in m_panelCache.GetLayoutElementInfos<LayoutInfo.ImageInfo>())
{
go = new GameObject();
var entity = go.AddComponent<ImageEntity>();
entity.transform.SetParent(entityRoot);
entity.transform.SetSiblingIndex(0);
entity.SetData(elementInfo);
entity.InitPreviewImage();
}
// Text
}
}
}
#endif