跳至正文
版本:bleeding-edge 🩸

🍀 资产

从资产包中检索资产数据。

🗿Static ClassClient & Server🧑‍💻API Source

🎒 示例​

(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)

🗿 静态函数​

ReturnsNameDescription
table of tableGetAnimations获取包含资产包中所有动画资产键的列表
table of tableGetAssetPacks获取包含所有已加载资产包信息的列表
stringGetAssetPath获取资产的文件路径
table of tableGetBlueprints获取包含资产包中所有蓝图资产键的列表
table of tableGetMaps获取包含资产包中所有地图资产键的列表
table of tableGetMaterials获取包含资产包中所有材质资产键的列表
table of tableGetOthers获取包含资产包中所有其他资产键的列表
table of tableGetParticles获取包含资产包中所有粒子资产键的列表
table of tableGetSkeletalMeshes获取包含资产包中所有骨骼网格体资产键的列表
table of tableGetSounds获取包含资产包中所有声音资产键的列表
table of tableGetStaticMeshes获取包含资产包中所有静态网格体资产键的列表
booleanIsLoaded返回资产是否已加载并缓存
LoadAsync在后台加载资产,以便之后生成或附加它时不会冻结游戏
Precache手动添加一个资产,使其在玩家的加载屏幕期间进行加载

Slow

GetAnimations​

获取包含资产包中所有动画资产键的列表
local ret = Assets.GetAnimations(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Slow

GetAssetPacks​

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

Returns

TypeDescription
table of table包含所有已加载资产包信息的列表 with this format

Moderate

GetAssetPath​

获取资产的文件路径
local ret = Assets.GetAssetPath(asset, asset_type)

Parameters

TypeParameterDefaultDescription
stringasset Required parameter 格式为 asset-pack::AssetKey 的资产引用
AssetTypeasset_type Required parameter 资产类型

Returns

TypeDescription
stringAssets.toml 中定义的文件路径

Slow

GetBlueprints​

获取包含资产包中所有蓝图资产键的列表
local ret = Assets.GetBlueprints(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Slow

GetMaps​

获取包含资产包中所有地图资产键的列表
local ret = Assets.GetMaps(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Slow

GetMaterials​

获取包含资产包中所有材质资产键的列表
local ret = Assets.GetMaterials(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Slow

GetOthers​

获取包含资产包中所有其他资产键的列表
local ret = Assets.GetOthers(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Slow

GetParticles​

获取包含资产包中所有粒子资产键的列表
local ret = Assets.GetParticles(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Slow

GetSkeletalMeshes​

获取包含资产包中所有骨骼网格体资产键的列表
local ret = Assets.GetSkeletalMeshes(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Slow

GetSounds​

获取包含资产包中所有声音资产键的列表
local ret = Assets.GetSounds(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Slow

GetStaticMeshes​

获取包含资产包中所有静态网格体资产键的列表
local ret = Assets.GetStaticMeshes(asset_pack_path)

Parameters

TypeParameterDefaultDescription
stringasset_pack_path Required parameter 用于获取资产的资产包路径

Returns

TypeDescription
table of table包含所有资产及其元数据的表数组 with this format

Optimal

IsLoaded​

返回资产是否已加载并缓存。

只要本次会话期间实体、附加网格体或 Assets.LoadAsync 以某种类型加载过该资产,该资产就会以该类型计为已加载。
local ret = Assets.IsLoaded(asset_path, asset_type)

Parameters

TypeParameterDefaultDescription
stringasset_path Required parameter 格式为 asset-pack::AssetKey 的资产引用
AssetTypeasset_type Required parameter 资产类型

Returns

TypeDescription
boolean资产是否已加载

Optimal

LoadAsync​

在后台加载资产,以便之后生成或附加它时不会冻结游戏。

实体和附加网格体在创建时会立即加载其资产,当资产较大或同时创建许多实体时(例如使用 AddSkeletalMeshAttached 为多个角色穿戴装备),这可能会让游戏短暂冻结。

之后该资产会保持加载并缓存。在同一个资产仍在加载时再次加载它会等待同一个请求。回调总是在之后的 tick 中运行,绝不会在此调用内部运行,即使该资产已经加载完成也是如此。
Assets.LoadAsync(asset_path, asset_type, callback?)

Parameters

TypeParameterDefaultDescription
stringasset_path Required parameter 格式为 asset-pack::AssetKey 的资产引用
AssetTypeasset_type Required parameter 资产类型
functioncallback?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

TypeParameterDefaultDescription
stringasset_path Required parameter 资产键
AssetTypeasset_type Required parameter 资产类型
Assets.Precache Examples
Precaches a Static Mesh
Assets.Precache("my-asset-pack::SM_MyStaticMesh", AssetType.StaticMesh)