Skip to main content

UIPackage

Namespace:FairyGUI
Source:Assets/Scripts/UI/UIPackage.cs (line 15)

public class UIPackage

A UI Package contains a description file and some texture, sound assets.

Constructors​

UIPackage()​

public UIPackage();

Source:UI/UIPackage.cs (line 112)

Events​

onReleaseResource​

public static event Action<PackageItem> onReleaseResource;

The event is triggered when all reference to this package item dropped.

Source:UI/UIPackage.cs (line 27)

Fields​

URL_PREFIX​

public const string URL_PREFIX = "ui://";

Source:UI/UIPackage.cs (line 96)

unloadBundleByFGUI​

public static bool unloadBundleByFGUI;

Unload UIAssetBundle by FairyGUI system. if use AssetBundlesManager set value to false then unload UIAssetBundle by AssetBundlesManager

Source:UI/UIPackage.cs (line 22)

Methods​

AddPackage(AssetBundle)​

public static UIPackage AddPackage(AssetBundle bundle);

Add a UI package from assetbundle.

returns

UIPackage

ParameterTypeDescription
bundleAssetBundleA assetbundle.

Source:UI/UIPackage.cs (line 201)

AddPackage(AssetBundle, AssetBundle)​

public static UIPackage AddPackage(AssetBundle desc, AssetBundle res);

Add a UI package from two assetbundles. desc and res can be same.

returns

UIPackage

ParameterTypeDescription
descAssetBundleA assetbunble contains description file.
resAssetBundleA assetbundle contains resources.

Source:UI/UIPackage.cs (line 212)

AddPackage(AssetBundle, AssetBundle, string)​

public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string mainAssetName);

Add a UI package from two assetbundles with a optional main asset name.

returns

UIPackage

ParameterTypeDescription
descAssetBundleA assetbunble contains description file.
resAssetBundleA assetbundle contains resources.
mainAssetNamestringMain asset name. e.g. Basics_fui

Source:UI/UIPackage.cs (line 224)

AddPackage(byte[], string, LoadResource)​

public static UIPackage AddPackage(byte[] descData, string assetNamePrefix, LoadResource loadFunc);

Load Package by custom load method.

ParameterTypeDescription
descDatabyte[]Description file data
assetNamePrefixstringPrefix of the resource file name. The file name would be in format of 'assetNamePrefix_resFileName'. It can be empty.
loadFuncLoadResourceLoad method

Source:UI/UIPackage.cs (line 340)

AddPackage(byte[], string, LoadResourceAsync)​

public static UIPackage AddPackage(byte[] descData, string assetNamePrefix, LoadResourceAsync loadFunc);

Load Package async by custom load method.

ParameterTypeDescription
descDatabyte[]Description file data
assetNamePrefixstringrefix of the resource file name. The file name would be in format of 'assetNamePrefix_resFileName'. It can be empty.
loadFuncLoadResourceAsyncLoad method

Source:UI/UIPackage.cs (line 363)

AddPackage(string, LoadResource)​

public static UIPackage AddPackage(string assetPath, LoadResource loadFunc);

使用自定义的加载方式载入一个包。

ParameterTypeDescription
assetPathstring包资源路径。
loadFuncLoadResource载入函数

Source:UI/UIPackage.cs (line 303)

AddPackage(string)​

public static UIPackage AddPackage(string descFilePath);

Add a UI package from a path relative to Unity Resources path.

returns

UIPackage

ParameterTypeDescription
descFilePathstringPath relative to Unity Resources path.

Source:UI/UIPackage.cs (line 281)

CreateObject(string)​

public GObject CreateObject(string resName);
ParameterTypeDescription
resNamestring

Source:UI/UIPackage.cs (line 1074)

CreateObject(string, Type)​

public GObject CreateObject(string resName, System.Type userClass);
ParameterTypeDescription
resNamestring
userClassType

Source:UI/UIPackage.cs (line 1092)

CreateObject(string, string)​

public static GObject CreateObject(string pkgName, string resName);

Create a UI object.

returns

A UI object.

ParameterTypeDescription
pkgNamestringPackage name.
resNamestringResource name.

Source:UI/UIPackage.cs (line 435)

CreateObject(string, string, Type)​

public static GObject CreateObject(string pkgName, string resName, System.Type userClass);

Create a UI object.

returns

A UI object.

ParameterTypeDescription
pkgNamestringPackage name.
resNamestringResource name.
userClassTypeCustom implementation of this object.

Source:UI/UIPackage.cs (line 451)

CreateObjectAsync(string, string, CreateObjectCallback)​

public static void CreateObjectAsync(string pkgName, string resName, CreateObjectCallback callback);
ParameterTypeDescription
pkgNamestring
resNamestring
callbackCreateObjectCallback

Source:UI/UIPackage.cs (line 489)

CreateObjectAsync(string, CreateObjectCallback)​

public void CreateObjectAsync(string resName, CreateObjectCallback callback);
ParameterTypeDescription
resNamestring
callbackCreateObjectCallback

Source:UI/UIPackage.cs (line 1104)

CreateObjectFromURL(string)​

public static GObject CreateObjectFromURL(string url);

Create a UI object.

returns

A UI object.

ParameterTypeDescription
urlstringResource url.

Source:UI/UIPackage.cs (line 465)

CreateObjectFromURL(string, Type)​

public static GObject CreateObjectFromURL(string url, System.Type userClass);

Create a UI object.

returns

A UI object.

ParameterTypeDescription
urlstringResource url.
userClassTypeCustom implementation of this object.

Source:UI/UIPackage.cs (line 480)

CreateObjectFromURL(string, CreateObjectCallback)​

public static void CreateObjectFromURL(string url, CreateObjectCallback callback);
ParameterTypeDescription
urlstring
callbackCreateObjectCallback

Source:UI/UIPackage.cs (line 498)

GetById(string)​

public static UIPackage GetById(string id);

Return a UIPackage with a certain id.

returns

UIPackage

ParameterTypeDescription
idstringID of the package.

Source:UI/UIPackage.cs (line 173)

GetByName(string)​

public static UIPackage GetByName(string name);

Return a UIPackage with a certain name.

returns

UIPackage

ParameterTypeDescription
namestringName of the package.

Source:UI/UIPackage.cs (line 187)

GetItem(string)​

public PackageItem GetItem(string itemId);
ParameterTypeDescription
itemIdstring

Source:UI/UIPackage.cs (line 1157)

GetItemAsset(PackageItem)​

public object GetItemAsset(PackageItem item);
ParameterTypeDescription
itemPackageItem

Source:UI/UIPackage.cs (line 1175)

GetItemAsset(string)​

public object GetItemAsset(string resName);
ParameterTypeDescription
resNamestring

Source:UI/UIPackage.cs (line 1140)

GetItemAsset(string, string)​

public static object GetItemAsset(string pkgName, string resName);

Get a asset with a certain name.

returns

If resource is atlas, returns NTexture; If resource is sound, returns AudioClip.

ParameterTypeDescription
pkgNamestringPackage name.
resNamestringResource name.

Source:UI/UIPackage.cs (line 513)

GetItemAssetByURL(string)​

public static object GetItemAssetByURL(string url);

Get a asset with a certain name.

returns

If resource is atlas, returns NTexture; If resource is sound, returns AudioClip.

ParameterTypeDescription
urlstringResource url.

Source:UI/UIPackage.cs (line 527)

GetItemByName(string)​

public PackageItem GetItemByName(string itemName);
ParameterTypeDescription
itemNamestring

Source:UI/UIPackage.cs (line 1166)

GetItemByURL(string)​

public static PackageItem GetItemByURL(string url);
ParameterTypeDescription
urlstring

Source:UI/UIPackage.cs (line 555)

GetItemURL(string, string)​

public static string GetItemURL(string pkgName, string resName);

Get url of an item in package.

returns

Url.

ParameterTypeDescription
pkgNamestringPackage name.
resNamestringResource name.

Source:UI/UIPackage.cs (line 542)

GetItems()​

public List<PackageItem> GetItems();

Source:UI/UIPackage.cs (line 1152)

GetPackages()​

public static List<UIPackage> GetPackages();

Source:UI/UIPackage.cs (line 424)

GetVar(string)​

public static string GetVar(string key);
ParameterTypeDescription
keystring

Source:UI/UIPackage.cs (line 148)

LoadAllAssets()​

public void LoadAllAssets();

Source:UI/UIPackage.cs (line 964)

NormalizeURL(string)​

public static string NormalizeURL(string url);

将'ui://包名/组件名'转换为以内部id表达的url格式。如果传入的url本身就是内部id格式,则直接返回。 同时这个方法还带格式检测,如果传入不正确的url,会返回null。

ParameterTypeDescription
urlstring

Source:UI/UIPackage.cs (line 598)

ReloadAssets()​

public void ReloadAssets();

Source:UI/UIPackage.cs (line 1003)

ReloadAssets(AssetBundle)​

public void ReloadAssets(AssetBundle resBundle);
ParameterTypeDescription
resBundleAssetBundle

Source:UI/UIPackage.cs (line 1014)

RemoveAllPackages()​

public static void RemoveAllPackages();

Source:UI/UIPackage.cs (line 404)

RemovePackage(string)​

public static void RemovePackage(string packageIdOrName);

Remove a package. All resources in this package will be disposed.

ParameterTypeDescription
packageIdOrNamestring

Source:UI/UIPackage.cs (line 383)

SetItemAsset(PackageItem, object, DestroyMethod)​

public void SetItemAsset(PackageItem item, object asset, DestroyMethod destroyMethod);
ParameterTypeDescription
itemPackageItem
assetobject
destroyMethodDestroyMethod

Source:UI/UIPackage.cs (line 1233)

SetStringsSource(XML)​

public static void SetStringsSource(XML source);

Set strings source.

ParameterTypeDescription
sourceXML

Source:UI/UIPackage.cs (line 622)

SetVar(string, string)​

public static void SetVar(string key, string value);
ParameterTypeDescription
keystring
valuestring

Source:UI/UIPackage.cs (line 160)

UnloadAssets()​

public void UnloadAssets();

Source:UI/UIPackage.cs (line 974)

Properties​

assetPath​

public string assetPath { get; }

Source:UI/UIPackage.cs (line 630)

branch​

public static string branch { get; set; }

Source:UI/UIPackage.cs (line 125)

customId​

public string customId { get; set; }

Set a custom id for package, then you can use it in GetById.

Source:UI/UIPackage.cs (line 638)

dependencies​

public Dictionary<string, string>[] dependencies { get; }

获得本包依赖的包的id列表

Source:UI/UIPackage.cs (line 662)

id​

public string id { get; private set; }

Package id. It is generated by the Editor.

Source:UI/UIPackage.cs (line 32)

name​

public string name { get; private set; }

Package name.

Source:UI/UIPackage.cs (line 37)

resBundle​

public AssetBundle resBundle { get; }

Source:UI/UIPackage.cs (line 654)