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
| Parameter | Type | Description |
|---|---|---|
bundle | AssetBundle | A 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
| Parameter | Type | Description |
|---|---|---|
desc | AssetBundle | A assetbunble contains description file. |
res | AssetBundle | A 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
| Parameter | Type | Description |
|---|---|---|
desc | AssetBundle | A assetbunble contains description file. |
res | AssetBundle | A assetbundle contains resources. |
mainAssetName | string | Main 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.
| Parameter | Type | Description |
|---|---|---|
descData | byte[] | Description file data |
assetNamePrefix | string | Prefix of the resource file name. The file name would be in format of 'assetNamePrefix_resFileName'. It can be empty. |
loadFunc | LoadResource | Load 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.
| Parameter | Type | Description |
|---|---|---|
descData | byte[] | Description file data |
assetNamePrefix | string | refix of the resource file name. The file name would be in format of 'assetNamePrefix_resFileName'. It can be empty. |
loadFunc | LoadResourceAsync | Load method |
Source:UI/UIPackage.cs (line 363)
AddPackage(string, LoadResource)
public static UIPackage AddPackage(string assetPath, LoadResource loadFunc);
使用自定义的加载方式载入一个包。
| Parameter | Type | Description |
|---|---|---|
assetPath | string | 包资源路径。 |
loadFunc | LoadResource | 载入函数 |
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
| Parameter | Type | Description |
|---|---|---|
descFilePath | string | Path relative to Unity Resources path. |
Source:UI/UIPackage.cs (line 281)
CreateObject(string)
public GObject CreateObject(string resName);
| Parameter | Type | Description |
|---|---|---|
resName | string |
Source:UI/UIPackage.cs (line 1074)
CreateObject(string, Type)
public GObject CreateObject(string resName, System.Type userClass);
| Parameter | Type | Description |
|---|---|---|
resName | string | |
userClass | Type |
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.
| Parameter | Type | Description |
|---|---|---|
pkgName | string | Package name. |
resName | string | Resource 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.
| Parameter | Type | Description |
|---|---|---|
pkgName | string | Package name. |
resName | string | Resource name. |
userClass | Type | Custom implementation of this object. |
Source:UI/UIPackage.cs (line 451)
CreateObjectAsync(string, string, CreateObjectCallback)
public static void CreateObjectAsync(string pkgName, string resName, CreateObjectCallback callback);
| Parameter | Type | Description |
|---|---|---|
pkgName | string | |
resName | string | |
callback | CreateObjectCallback |
Source:UI/UIPackage.cs (line 489)
CreateObjectAsync(string, CreateObjectCallback)
public void CreateObjectAsync(string resName, CreateObjectCallback callback);
| Parameter | Type | Description |
|---|---|---|
resName | string | |
callback | CreateObjectCallback |
Source:UI/UIPackage.cs (line 1104)
CreateObjectFromURL(string)
public static GObject CreateObjectFromURL(string url);
Create a UI object.
returns
A UI object.
| Parameter | Type | Description |
|---|---|---|
url | string | Resource 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.
| Parameter | Type | Description |
|---|---|---|
url | string | Resource url. |
userClass | Type | Custom implementation of this object. |
Source:UI/UIPackage.cs (line 480)
CreateObjectFromURL(string, CreateObjectCallback)
public static void CreateObjectFromURL(string url, CreateObjectCallback callback);
| Parameter | Type | Description |
|---|---|---|
url | string | |
callback | CreateObjectCallback |
Source:UI/UIPackage.cs (line 498)
GetById(string)
public static UIPackage GetById(string id);
Return a UIPackage with a certain id.
returns
UIPackage
| Parameter | Type | Description |
|---|---|---|
id | string | ID 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
| Parameter | Type | Description |
|---|---|---|
name | string | Name of the package. |
Source:UI/UIPackage.cs (line 187)
GetItem(string)
public PackageItem GetItem(string itemId);
| Parameter | Type | Description |
|---|---|---|
itemId | string |
Source:UI/UIPackage.cs (line 1157)
GetItemAsset(PackageItem)
public object GetItemAsset(PackageItem item);
| Parameter | Type | Description |
|---|---|---|
item | PackageItem |
Source:UI/UIPackage.cs (line 1175)
GetItemAsset(string)
public object GetItemAsset(string resName);
| Parameter | Type | Description |
|---|---|---|
resName | string |
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.
| Parameter | Type | Description |
|---|---|---|
pkgName | string | Package name. |
resName | string | Resource 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.
| Parameter | Type | Description |
|---|---|---|
url | string | Resource url. |
Source:UI/UIPackage.cs (line 527)
GetItemByName(string)
public PackageItem GetItemByName(string itemName);
| Parameter | Type | Description |
|---|---|---|
itemName | string |
Source:UI/UIPackage.cs (line 1166)
GetItemByURL(string)
public static PackageItem GetItemByURL(string url);
| Parameter | Type | Description |
|---|---|---|
url | string |
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.
| Parameter | Type | Description |
|---|---|---|
pkgName | string | Package name. |
resName | string | Resource 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);
| Parameter | Type | Description |
|---|---|---|
key | string |
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。
| Parameter | Type | Description |
|---|---|---|
url | string |
Source:UI/UIPackage.cs (line 598)
ReloadAssets()
public void ReloadAssets();
Source:UI/UIPackage.cs (line 1003)
ReloadAssets(AssetBundle)
public void ReloadAssets(AssetBundle resBundle);
| Parameter | Type | Description |
|---|---|---|
resBundle | AssetBundle |
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.
| Parameter | Type | Description |
|---|---|---|
packageIdOrName | string |
Source:UI/UIPackage.cs (line 383)
SetItemAsset(PackageItem, object, DestroyMethod)
public void SetItemAsset(PackageItem item, object asset, DestroyMethod destroyMethod);
| Parameter | Type | Description |
|---|---|---|
item | PackageItem | |
asset | object | |
destroyMethod | DestroyMethod |
Source:UI/UIPackage.cs (line 1233)
SetStringsSource(XML)
public static void SetStringsSource(XML source);
Set strings source.
| Parameter | Type | Description |
|---|---|---|
source | XML |
Source:UI/UIPackage.cs (line 622)
SetVar(string, string)
public static void SetVar(string key, string value);
| Parameter | Type | Description |
|---|---|---|
key | string | |
value | string |
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)