|
@@ -1,16 +1,47 @@
|
|
|
-namespace ET.Client
|
|
|
+using FairyGUI;
|
|
|
+using System.Runtime.Remoting.Lifetime;
|
|
|
+using UnityEngine;
|
|
|
+
|
|
|
+namespace ET.Client
|
|
|
{
|
|
|
public static class UIHelper
|
|
|
{
|
|
|
- public static async ETTask<UI> Create(Scene scene, string uiType, UILayer uiLayer)
|
|
|
+ public static async ETTask<GObject> Create(string uiName)
|
|
|
{
|
|
|
- return await scene.GetComponent<UIComponent>().Create(uiType, uiLayer);
|
|
|
+ var ass = await YooAssetProxy.LoadAssetAsync<TextAsset>($"FGUI_{uiName}_fui");
|
|
|
+ UIPackage.AddPackage(ass.GetAssetObject<TextAsset>().bytes, uiName, LoadPackageInternalAsync);
|
|
|
+ var view = UIPackage.CreateObject(uiName, uiName).asCom;
|
|
|
+ view.name = uiName;
|
|
|
+ GRoot.inst.AddChild(view);
|
|
|
+ return view;
|
|
|
}
|
|
|
-
|
|
|
- public static async ETTask Remove(Scene scene, string uiType)
|
|
|
+
|
|
|
+ private static async void LoadPackageInternalAsync(string name,string extension, System.Type type, PackageItem item)
|
|
|
{
|
|
|
- scene.GetComponent<UIComponent>().Remove(uiType);
|
|
|
- await ETTask.CompletedTask;
|
|
|
+ var tex = await YooAssetProxy.LoadAssetAsync<Texture>($"FGUI_{name}");
|
|
|
+ item.owner.SetItemAsset(item, tex.GetAsset<Texture>(), DestroyMethod.Unload);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool Remove(string uiName, bool release = true)
|
|
|
+ {
|
|
|
+ var view = GRoot.inst.GetChild(uiName);
|
|
|
+ if (view != null)
|
|
|
+ {
|
|
|
+ GRoot.inst.RemoveChild(view, release);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static bool SetVisible(string uiName, bool flag)
|
|
|
+ {
|
|
|
+ var view = GRoot.inst.GetChild(uiName);
|
|
|
+ if (view != null)
|
|
|
+ {
|
|
|
+ view.visible = flag;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
}
|