🍀 资产
从资产包中检索资产数据。
🎒 示例
(Assets.LoadAsync) Loads a Skeletal Mesh before attaching it
Assets.LoadAsync("my-asset-pack::SK_MyHair", AssetType.SkeletalMesh, function(success)
if (success and character:IsValid()) then
character:AddSkeletalMeshAttached("hair", "my-asset-pack::SK_MyHair")
end
end)
(Assets.Precache) Precaches a Static Mesh
Assets.Precache("my-asset-pack::SM_MyStaticMesh", AssetType.StaticMesh)
🗿 静态函数
| Returns | Name | Description | |
|---|---|---|---|
| table of table | GetAnimations | 获取包含资产包中所有动画资产键的列表 | |
| table of table | GetAssetPacks | 获取包含所有已加载资产包信息的列表 | |
| string | GetAssetPath | 获取资产的文件路径 | |
| table of table | GetBlueprints | 获取包含资产包中所有蓝图资产键的列表 | |
| table of table | GetMaps | 获取包含资产包中所有地图资产键的列表 | |
| table of table | GetMaterials | 获取包含资产包中所有材质资产键的列表 | |
| table of table | GetOthers | 获取包含资产包中所有其他资产键的列表 | |
| table of table | GetParticles | 获取包含资产包中所有粒子资产键的列表 | |
| table of table | GetSkeletalMeshes | 获取包含资产包中所有骨骼网格体资产键的列表 | |
| table of table | GetSounds | 获取包含资产包中所有声音资产键的列表 | |
| table of table | GetStaticMeshes | 获取包含资产包中所有静态网格体资产键的列表 | |
| boolean | IsLoaded | 返回资产是否已加载并缓存 | |
LoadAsync | 在后台加载资产,以便之后生成或附加它时不会冻结游戏 | ||
Precache | 手动添加一个资产,使其在玩家的加载屏幕期间进行加载 |
Slow

GetAnimations
获取包含资产包中所有动画资产键的列表
local ret = Assets.GetAnimations(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Slow

GetAssetPacks
获取包含所有已加载资产包信息的列表
local ret = Assets.GetAssetPacks()
Moderate

GetAssetPath
获取资产的文件路径
local ret = Assets.GetAssetPath(asset, asset_type)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset | Required parameter | 格式为 asset-pack::AssetKey 的资产引用 |
| AssetType | asset_type | Required parameter | 资产类型 |
Returns
| Type | Description |
|---|---|
| string | Assets.toml 中定义的文件路径 |
Slow

GetBlueprints
获取包含资产包中所有蓝图资产键的列表
local ret = Assets.GetBlueprints(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Slow

GetMaps
获取包含资产包中所有地图资产键的列表
local ret = Assets.GetMaps(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Slow

GetMaterials
获取包含资产包中所有材质资产键的列表
local ret = Assets.GetMaterials(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Slow

GetOthers
获取包含资产包中所有其他资产键的列表
local ret = Assets.GetOthers(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Slow

GetParticles
获取包含资产包中所有粒子资产键的列表
local ret = Assets.GetParticles(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Slow

GetSkeletalMeshes
获取包含资产包中所有骨骼网格体资产键的列表
local ret = Assets.GetSkeletalMeshes(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Slow

GetSounds
获取包含资产包中所有声音资产键的列表
local ret = Assets.GetSounds(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Slow

GetStaticMeshes
获取包含资产包中所有静态网格体资产键的列表
local ret = Assets.GetStaticMeshes(asset_pack_path)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_pack_path | Required parameter | 用于获取资产的资产包路径 |
Optimal

IsLoaded
返回资产是否已加载并缓存。
只要本次会话期间实体、附加网格体或Assets.LoadAsync以某种类型加载过该资产,该资产就会以该类型计为已加载。
local ret = Assets.IsLoaded(asset_path, asset_type)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_path | Required parameter | 格式为 asset-pack::AssetKey 的资产引用 |
| AssetType | asset_type | Required parameter | 资产类型 |
Returns
| Type | Description |
|---|---|
| boolean | 资产是否已加载 |
Optimal

LoadAsync
在后台加载资产,以便之后生成或附加它时不会冻结游戏。
实体和附加网格体在创建时会立即加载其资产,当资产较大或同时创建许多实体时(例如使用 AddSkeletalMeshAttached 为多个角色穿戴装备),这可能会让游戏短暂冻结。
之后该资产会保持加载并缓存。在同一个资产仍在加载时再次加载它会等待同一个请求。回调总是在之后的 tick 中运行,绝不会在此调用内部运行,即使该资产已经加载完成也是如此。
Assets.LoadAsync(asset_path, asset_type, callback?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_path | Required parameter | 格式为 asset-pack::AssetKey 的资产引用 |
| AssetType | asset_type | Required parameter | 资产类型 |
| function | callback? | nil | 资产加载完成时调用 with this format |
Assets.LoadAsync Examples
Loads a Skeletal Mesh before attaching it
Assets.LoadAsync("my-asset-pack::SK_MyHair", AssetType.SkeletalMesh, function(success)
if (success and character:IsValid()) then
character:AddSkeletalMeshAttached("hair", "my-asset-pack::SK_MyHair")
end
end)
Optimal

Precache
手动添加一个资产,使其在玩家的加载屏幕期间进行加载
Assets.Precache(asset_path, asset_type)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | asset_path | Required parameter | 资产键 |
| AssetType | asset_type | Required parameter | 资产类型 |
Assets.Precache Examples
Precaches a Static Mesh
Assets.Precache("my-asset-pack::SM_MyStaticMesh", AssetType.StaticMesh)


