43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using Unity.Loader;
|
|
using UnityEngine;
|
|
|
|
namespace ZC
|
|
{
|
|
public static class GameObjectFactory
|
|
{
|
|
private static Transform parent;
|
|
|
|
public static T CreateGameObject<T>(string path) where T : GameObjectBase<T>
|
|
{
|
|
var go = ResourcesLocalComponent.Instance.LoadGameObjectSync(path);
|
|
if (parent == null)
|
|
parent = Global.ObjectPool;
|
|
go.transform.SetParent(parent);
|
|
var objectBase = go.AddComponent<T>();
|
|
objectBase.SetID(IDGenerator.Generate());
|
|
Global.ObjectManager.Add(objectBase);
|
|
return objectBase;
|
|
}
|
|
|
|
public static void DeleteGameObject(long id)
|
|
{
|
|
Global.ObjectManager.Remove(id);
|
|
}
|
|
}
|
|
|
|
public static class UIGameObjectFactory
|
|
{
|
|
private static Transform parent;
|
|
|
|
public static T CreateUI<T>(UIType uiType, string path, UILayer uiLayer) where T : UIBase
|
|
{
|
|
return Global.UIManager.CreateUI<T>(uiType, path, uiLayer);
|
|
}
|
|
|
|
public static void DeleteUI(UIType uiType)
|
|
{
|
|
Global.UIManager.DeleteUI(uiType);
|
|
}
|
|
}
|
|
} |