UEFN のアセットを Verse に公開し、Verse コードで使えるようにできます。これは アセット リフレクション と呼ばれています。これにより、カスタム UI に画像を挿入したり、カスタムの小道具にメッシュを使用したりできます。
アセットを Verse に公開すると、アセットの名前が 識別子、つまりコンパイラ シンボルになります。これにより、Verse コードでの使用と、Verse パス からアセットへのアクセスが可能となります。アセットの命名は、識別子の 命名規則とルール に従う必要があります。Verse に公開されているすべてのアセットは、プロジェクトの「Assets.digest.verse」ファイルで確認できます。
「Assets.digest.verse」ファイルを生成するには、Verse コードをビルドする前にプロジェクトに少なくとも 1 つの Verse ファイルが必要です。
たとえば、テクスチャの名前が「MyTexture」の場合、「Assets.digest.verse」ファイルに MyTexture<scoped {MyProject}>:texture_2d = external {}
として表示されます。
プロジェクトの「Content」フォルダ内のサブフォルダにアセットを配置すると、サブフォルダ名が Verse モジュールの名前になります。たとえば、「MySphere」という名前のカスタム メッシュを作成し、それがプロジェクトの「Content」フォルダのサブフォルダ「Meshes」内にある場合、コード内でメッシュの名前をモジュール (サブフォルダ) 名で修飾する必要があります (例:Meshes.MySphere
)。
現在、次のタイプのアセットを Verse に公開できます。
- メッシュ
- テクスチャ
- Materials (マテリアル)
- Niagara VFX Particle Systems
次のセクションでは、Verse コードで使用できるように各種アセットを設定する方法について説明します。
メッシュ
Verse コードでメッシュを参照できるようにするには、次のことを行う必要があります。
-
UEFN でメッシュを モデル化 するか、メッシュをプロジェクトにインポートします。
Fab からインポート したアセットを「Assets.digest.verse」ファイルに表示するには、変更可能な Unreal Engine アセットとして追加する必要があります。現在、Fab からの参照アセットを Verse コードで使用することはできません。
- [File (ファイル)] > [Save All (すべて保存)] を選択してメッシュを保存します。
- メッシュの名前がプロジェクトの「Assets.digest.verse」ファイルに表示されていることを確認します。
すると、クリエイティブの小道具にメッシュを設定するといったように、Verse API でメッシュを使用できるようになります。
次の例は、ゲームの開始時に小道具をスポーンする Verse で作成した仕掛け です。この例では、プロジェクトの「Content」フォルダのサブフォルダ「Meshes」にある「MySphere」という名前のメッシュを使用します。
using { /Fortnite.com/Devices}
using { /Verse.org/Simulation}
using { /UnrealEngine.com/Temporary/Diagnostics}
using { /Fortnite.com/UI}
using { /UnrealEngine.com/Temporary/UI}
using { /UnrealEngine.com/Temporary/SpatialMath}
# A Verse-authored creative device that spawns a prop and sets its mesh.
my_device := class(creative_device):
# 実行中のゲームで仕掛けが開始されたときに実行します
OnBegin<override>()<suspends> : void =
SpawnLocation := transform:
Translation := vector3{X := 0.0, Y := 0.0, Z := 0.0}
Rotation := IdentityRotation()
Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0}
SpawnPropResult := SpawnProp(DefaultCreativePropAsset, SpawnLocation)
# SpawnProp() の結果はタプル型です。この最初の要素はオプションのクリエイティブ小道具となります
if (SpawnedProp := SpawnPropResult(0)?):
SpawnedProp.SetMesh(Meshes.MySphere)
テクスチャ
Verse コードでテクスチャを参照できるようにするには、次のことを行う必要があります。
- テクスチャを UEFN にインポートします。
Fab からインポート したアセットを「Assets.digest.verse」ファイルに表示するには、変更可能な Unreal Engine アセットとして追加する必要があります。現在、Fab からの参照アセットを Verse コードで使用することはできません。
- [File (ファイル)] > [Save All (すべて保存)] を選択してテクスチャを保存します。
- テクスチャの名前がプロジェクトの「Assets.digest.verse」ファイルに表示されていることを確認します。
すると、Verse UI などの Verse API でテクスチャを使用できるようになります。
マテリアル
Verse コードでマテリアルを参照できるようにするには、次のことを行う必要があります。
- UEFN でマテリアルを作成します。
- マテリアルの名前がプロジェクトの「Assets.digest.verse」ファイルに表示されていることを確認します。
You can then use your material with Verse APIs, such as Verse UI and setting the material on creative props.

using { /Fortnite.com/Devices}
using { /Verse.org/Simulation}
using { /UnrealEngine.com/Temporary/Diagnostics}
using { /UnrealEngine.com/Temporary/SpatialMath}
my_device := class(creative_device):
# 実行中のゲームで仕掛けが開始されたときに実行します
OnBegin<override>()<suspends>:void=
SpawnLocation := transform:
Translation := vector3{X := 0.0, Y := 0.0, Z := 0.0}
Rotation := IdentityRotation()
Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0}
SpawnPropResult := SpawnProp(DefaultCreativePropAsset, SpawnLocation)
# SpawnProp() の結果はタプル型です。この最初の要素はオプションのクリエイティブ小道具となります
if (SpawnedProp := SpawnPropResult(0)?):
SpawnedProp.SetMaterial(Materials.MyMaterial)

Material Parameters
マテリアルを作成し、パラメータを作成すると、そのパラメータが Assets.digest.verse ファイルのマテリアルクラスのフィールド。マテリアルをメッシュに設定すると、ランタイム時に Verse でマテリアルのパラメータを変更できます。
The following parameter types from your material can be exposed in Verse:
Material Parameters | Verse Type | Description |
---|---|---|
scalar | float |
A single floating point value. |
texture | texture |
A parameter for accessing and setting the texture on a material. |
vector4 | color |
The color struct in Verse only contains three elements, RGB. If you need a fourth element, or to represent the alpha for a color, you'll need to use an additional scalar parameter. |
The following example uses a material named ConcreteMaterial with a vector4 parameter named MyRandomColor.
This is what appears in the Assets.digest.verse file for this material:
ConcreteMaterial_material<scoped {ParameterizedMaterialsTest}> := class<final><public>(material):
var Specular:float = external {}
var WorldPositionOffset:color = external {}
var BaseTexture:texture = external {}
ConcreteMaterial<scoped {ParameterizedMaterialsTest}>:material = external {}
To be able to access and update the parameters on this material, you must instantiate your material in your Verse code first. In the following example, the material is instantiated and then set on a mesh before the parameters are modified.
using { /Fortnite.com/Devices}
using { /Verse.org/Colors}
using { /Verse.org/Random}
using { /Verse.org/Simulation}
using { /UnrealEngine.com/Temporary/Diagnostics}
using { /UnrealEngine.com/Temporary/SpatialMath}
# A Verse-authored creative device that spawns three props and randomly changes their color
material_color_test_device := class(creative_device):
# Reference to the parameterized material in the Assets.digest.verse file.
MyParameterizedMaterial:ConcreteMaterial_material = ConcreteMaterial_material{}
OnBegin<override>()<suspends>:void=
Offset:vector3 = vector3:
X := 200.0
Y := 0.0
Z := 0.0
# Spawn several props to apply the material to.
SpawnResult1 := SpawnProp(DefaultCreativePropAsset,GetTransform().Translation, GetTransform().Rotation)
SpawnResult2 := SpawnProp(DefaultCreativePropAsset,GetTransform().Translation + Offset, GetTransform().Rotation)
SpawnResult3 := SpawnProp(DefaultCreativePropAsset,GetTransform().Translation - Offset, GetTransform().Rotation)
# Set the material on each of the props.
if:
Prop1 := SpawnResult1(0)?
Prop2 := SpawnResult2(0)?
Prop3 := SpawnResult3(0)?
then:
Prop1.SetMaterial(MyParameterizedMaterial)
Prop2.SetMaterial(MyParameterizedMaterial)
Prop3.SetMaterial(MyParameterizedMaterial)
# Randomize the color on the parameterized material.
loop:
set MyParameterizedMaterial.MyRandomColor = color:
R := GetRandomFloat(0.0, 1.0)
G := GetRandomFloat(0.0, 1.0)
B := GetRandomFloat(0.0, 1.0)
Sleep(0.20)

VFX Assets and Particle Systems
To be able to reference your Niagara VFX particle system in your Verse code, you must:
- Create your particle system in UEFN.
- Verify that the name of your particle system appears in your project’s Assets.digest.verse file.
You can then spawn the particle system using the SpawnParticleSystem()
function. The following example uses a particle system named MyParticleSystem that was in the subfolder VFX of the project's Content folder.
using { /Fortnite.com/Devices}
using { /Verse.org/Simulation}
using { /UnrealEngine.com/Assets }
using { /UnrealEngine.com/Temporary/Diagnostics}
# A Verse-authored creative device that spawns a VFX particle system
vfx_test_device := class(creative_device):
# 実行中のゲームで仕掛けが開始されたときに実行します
OnBegin<override>()<suspends>:void=
loop:
# Spawns a VFX particle system at the given Translation
MyVFX:cancelable = SpawnParticleSystem(MyParticleSystem, GetTransform().Translation)
# Let the VFX play for 3 seconds
Sleep(3.0)
# Stop the VFX
MyVFX.Cancel()
既知の制限事項
以下に、アセット リフレクションに関する現在の制限事項を示します。
-
小道具で
SetMesh
を使用する場合、クリエイティブ ツールセットの一部の小道具にはオーバーライド マテリアルが定義されていることから、新しいメッシュのマテリアルが小道具に表示されない場合があります。小道具にオーバーライド マテリアルがない場合、メッシュを変更すると、新しいメッシュのマテリアルが使用されます。 -
アセットにプロジェクト内の別の識別子と同じ名前を付けるとコンパイル エラーが発生します。たとえば、以下に示す構造のプロジェクトは、「
MyMesh
」というアセットと「MyMesh
」というフォルダが存在するため、コンパイルできません。コードをコンパイルするには、フォルダまたはアセットの名前を変更する必要があります。-
MyFolder /
-
MyMesh.uasset
-
MyMesh /
- MyOtherMesh.uasset
-
-
トラブルシューティング
「Assets.digest.verse」ファイルの更新またはアセット リフレクション コードのコンパイルで問題が発生した場合は、以下の修正を試してください。
-
set
やblock
などの Verse キーワード をアセットまたはフォルダの名前として使用しないでください。「Assets.digest.verse」ファイルは、これらの名前から Verse 識別子を作成します。Verse 識別子としてキーワードを使用すると、コンパイル エラーが発生します。Verse キーワードのリストについては、「Verse 言語のクイック リファレンス」を参照してください。 -
Verse API または API メンバーの名前をアセットまたはフォルダの名前として使用しないでください。「Verse API リファレンス」を参照してください。
-
アセットやフォルダに名前を付けるときは、Verse の 命名規則 に従ってください。そうしないと、ダイジェスト ファイルの生成でスキップされる可能性があります。
-
モジュール外のアセットを参照しようとすると、アクセス エラーが発生する可能性があります。これは、モジュールにデフォルトで
<internal>
アクセス指定子 があるためです。 このエラーを修正するには、モジュール宣言に<public>
アクセス指定子を追加する必要があります。 プロジェクト内にフォルダを作成してモジュールを指定した場合は、コード内のモジュールのアクセシビリティを変更する必要があります。 たとえば、次のプロジェクト構造では、Materials
、Meshes
、Textures
がWatermelon
モジュールのサブモジュールとなっています。-
MyProject /
-
MiniGame /
-
MiniGameAssets /
-
Watermelon /
-
Materials /
-
Meshes /
- Watermelon.uasset
-
Textures /
-
-
-
-
hello_world_device.verse
-
-
The following code in hello_world_device.verse
changes the Meshes
module's accessibility to public.
MiniGame := module:
MiniGameAssets<public> := module:
Watermelon<public> := module:
メッシュ<public> := module {}
Now the project's hello_world_device.verse
file can reference the Watermelon.uasset
in code using the path MiniGame.MiniGameAssets.Watermelon.Meshes.Watermelon
.
識別子によって Verse コード内でエラーが発生した場合、アセットまたはフォルダの名前としてもエラーが発生する可能性があります。 最初に使用したい名前をコードに識別子として入力して、それらがアセット名やフォルダ名として使用できるかどうかを確認してください。
アセット リフレクションを有効にする
26.00 のリリースでは、UEFN から Verse にアセットを公開する機能が、すべての新規作成された UEFN プロジェクトに対してデフォルトで有効になりました。 26.00 より前に作成されたプロジェクトでは、次の手順に従って、この機能を有効にする必要があります。
- UEFN でプロジェクトを閉じます。
- プロジェクト ディレクトリで .uplugin ファイルを見つけます。
- .uplugin ファイルをテキスト エディタで開きます。
- プロパティ EnableVerseAssetReflection を見つけて、これを true に設定します。
- そのようなプロパティがない場合、次の行を VersePath パスの下に追加します。
"EnableVerseAssetReflection" : true,
- .uplugin ファイルを保存します。
- UEFN でプロジェクトを再度開きます。