using FairyGUI;
using System;
using XGame.Framework.Asset;
using XGame.Framework.UI;
namespace XGame.Framework.FGUI
{
public static class FguiUtils
{
///
/// 包名转ui的描述文件名(Description file data)
/// fgui的ui数据保存在pkgName_fui.bytes文件里
///
///
///
public static string ToDescFileName(string pkgName)
{
return $"{pkgName}_fui";
}
///
/// 包名+资源名转ui路径
///
///
///
///
public static string ToUrl(string pkgName, string resName)
{
return $"ui://{pkgName}/{resName}";
}
///
/// 加载Nested并设置父节点
///
///
///
///
///
public static IAssetLoadAsync LoadFguiNested(this IUIAssetModule assetModule, UIKey nestedKey, GComponent parent)
{
if (assetModule is FguiAssetModule fguiImpl)
{
return fguiImpl.LoadNested(nestedKey, parent);
}
Log.Error($"IUIAssetModule 为空. NestedKey:{nestedKey}");
return null;
}
public static IGListItemHandle CreateListItem(this IUIViewAdapter viewAdapter, Type viewType, GObject gObj)
{
if (viewAdapter == null)
return null;
var view = viewAdapter.CreateNested(viewType, new FguiNested(gObj.asCom), false);
return view as IGListItemHandle;
}
}
}