资产指南
关于资产你需要了解的一切
Assets in nanos world are all objects or content which come from Unreal Engine. For example Maps, StaticMeshes, SkeletalMeshes, Sounds, Particles, Blueprints etc are all types of Assets.
In order to use custom Assets in your servers, for example to spawn a Prop, or a custom Weapon you must have an Asset Pack. 资产包是从虚幻引擎中一起导出的一组资产。
Folder Structure
All Asset Packs go under the server's Assets/ directory. 每个资产包都是该目录下的一个子文件夹。
Asset Packs downloaded when connecting to servers or downloaded from the vault will be stored in server's Assets/ directory as well!
这是一个服务器 Assets 文件夹的示例:
NanosWorldServer.exe
Assets/
├── my-asset-pack-01/
│ ├── MyAssetPack01/
│ │ ├── MyProp.uasset
│ │ ├── MyProp.ubulk
│ │ ├── MyProp.uexp
│ │ ├── MyBigMap.umap
│ │ ...
│ └── Assets.toml
├── awesome-weapons/
│ ├── MyWeapons/
│ │ ├── BigFuckingGun.uasset
│ │ ...
│ └── Assets.toml
Packages/
Config.toml
资产包配置
Asset Packs have a configuration file in the root of the Asset Pack folder, called Assets.toml, in this file we can setup all pertinent settings related to the Asset Pack:
loading...
Settings Detailed
查看每个设置的具体功能描述:
| Setting | Description |
|---|---|
title | 易读的名称 |
author | 贡献者 |
version | Version - in the SemVer format X.Y.Z |
unreal.unreal_folders | 虚幻项目导出的、需要在游戏中挂载的所有文件夹列表。 这很重要,能确保资产正确保留其相对引用关系 |
unreal.unreal_version | 创建此资产包时所使用的版本 |
unreal.is_plugin_content | 此资产包是否使用了插件内容 |
assets.maps | 此资产包中的地图列表 |
assets.static_meshes | 此资产包中的静态网格体列表 |
assets.skeletal_meshes | 此资产包中的骨骼网格体列表 |
assets.sounds | 此资产包中的声音列表 |
assets.animations | 此资产包中的动画列表 |
assets.particles | 此资产包中的粒子列表 |
assets.materials | 此资产包中的材质列表 |
assets.blueprints | 此资产包中的蓝图列表 |
assets.others | 此资产包中的其他资产列表 |
资产元数据
你还可以为每个单独的资产定义自定义元数据!
除了像这样通过字符串来定义资产路径之外:
[assets.static_meshes]
SM_Flower_01 = "MyFolder/SM_Awesome_Flower_01"
SM_Rock_01 = "MyFolder/SM_Rock_01"
SM_MyAsset_01 = "MyFolder/SM_MyAsset_01"
# ...
我们还可以将它们定义为一个表,从而允许使用自定义值——这些值可以通过脚本进行访问:
[assets.static_meshes]
SM_Flower_01 = { path = "MyFolder/SM_Awesome_Flower_01", my_tag = "Wonderful", something = 123, thumbnail = "Thumbnails/SM_Flower_01.jpg" }
SM_Rock_01 = { path = "MyFolder/SM_Rock_01", my_tag = "Wonderful", something = 123, thumbnail = "Thumbnails/SM_Rock_01.jpg" }
SM_MyAsset_01 = { path = "MyFolder/SM_MyAsset_01", my_tag = "Wonderful", something = 123, thumbnail = "Thumbnails/SM_MyAsset_01.jpg" }
# ...
The path key is required, all other values are optional and customizable, use as you wish!
标志图片
你还可以设置一张自定义图片,以便在资源库中显示。 For that, add a file called Assets.jpg besides the Assets.toml with the image you wish. The recommended size is 300x150.
在脚本中引用资产
为了能在代码中使用资产,首先必须确保该资产包已被加载。 资产包在以下情况下会被加载:
- 加载地图时(这会自动加载该地图所属的资产包)。
- A package with it configured in
assets_requirementsis loaded. - It is manually set in Server's
Config.tomlatassetsto load.
资产包加载完成后,你就可以使用以下格式来引用其中的资产:
"[ASSET_PACK_PATH]::[ASSET_KEY]"
示例:
"my-asset-pack-01::SM_Cube"
[ASSET_PACK_PATH] is the folder name and [ASSET_KEY] is the key defined in the Assets.toml.
资产类型
某些脚本方法需要加载特定类型的资产。 尝试加载无效或错误的类型将会引发错误。 E.g.: Character:SetMesh() requires an Asset of type Skeletal Mesh.
以下是所有支持的资产类型列表:
| Type | Description |
|---|---|
| Map | 虚幻引擎的地图/关卡 |
| Static Mesh | 虚幻静态网格体,可用于为道具和静态网格体加载网格体 |
| Skeletal Mesh | 虚幻骨骼网格体,可用于为角色和载具加载网格体 |
| Sound | 虚幻声音,用于加载声音 |
| Particle | 虚幻粒子,可用于在若干实体中进行设置,包括粒子类本身 |
| Animation | 虚幻动画,可用于角色和武器类的设置 |
| Material | 虚幻材质,可用于自定义网格体表面以及用作后处理 |
| Blueprint | 虚幻 Actor 蓝图,可用于生成蓝图实体 |
创建你自己的资产
要创建你自己的资产包,请参阅导入自定义资产指南。
📦 Importing Custom Assetsassets-modding/creating-assets/setting-up-ue默认资产包
nanos world 提供了一个默认的资产包,已经包含在基础游戏中。 请参阅默认资产包页面以获取更多信息。
📦 Default Asset Packassets-modding/default-asset-pack/default-assets-list