zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/Model/FGUI/Core/FUIPackageComponent.cs

75 lines
2.3 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System.Collections.Generic;
using FairyGUI;
using UnityEngine;
namespace ET
{
/// <summary>
/// 管理所有UI Package
/// </summary>
public class FUIPackageComponent: Entity
{
public const string FUI_PACKAGE_DIR = "Assets/Download/FGUI";
private readonly HashSet<UIPackage> packages = new HashSet<UIPackage>();
private bool IsLoadedFUIAB;
public void AddPackageAsync(string uitype)
{
UIPackage uiPackage;
if (Define.IsEditorMode)
{
uiPackage = UIPackage.AddPackage($"{FUI_PACKAGE_DIR}/{uitype}/{uitype}");
}
else
{
//AssetBundle ab = await ResourceHelper.LoadAssetBundleAsync(string.Format(PathHelper.FUIABFormat, uitype), true);
UIPackage.AddPackage($"{FUI_PACKAGE_DIR}/{uitype}/{uitype}",
(string name, string extension, System.Type type, out DestroyMethod destroyMetho) =>
{
destroyMetho = DestroyMethod.Unload;
switch (extension)
{
case ".bytes":
{
2021-04-11 19:50:39 +08:00
TextAsset req = ResourceHelper.LoadAsset<TextAsset>($"{name}{extension}");
2021-04-08 20:09:59 +08:00
return req;
}
case ".png":
{
2021-04-11 19:50:39 +08:00
Texture req = ResourceHelper.LoadAsset<Texture>($"{name}{extension}");
2021-04-08 20:09:59 +08:00
return req;
}
}
//return ResourceHelper.LoadAsset(name + extension, type);
return null;
});
}
}
public void RemovePackage(string type)
{
UIPackage package;
//if (packages.TryGetValue(type, out package))
//{
// var p = UIPackage.GetByName(package.name);
// if (p != null)
// {
// UIPackage.RemovePackage(package.name);
// }
// packages.Remove(package.name);
//}
if (!Define.IsEditorMode)
{
}
}
}
}