Open tagcode opened 1 year ago
I just noticed that this dropdown menu does discover all the procedural model classes. So it's only that asset menu that doesn't.
As workaround trick, I can create a model from a built-in procedure, e.g. Plane, and then change it from this dropdown menu.
As far as I saw by studying the code there are some different approaches with the Asset Window and the Property Grid. The property grid looks for the Types in every assembly or DLL while the Asset Window uses YAML templates like this in order to be discovered:
# FILE: Stride.Assets.Presentation\Templates\Assets\Models\ProceduralCube.sdtpl
!TemplateAssetFactory
Id: 8267F08C-3DC8-48F4-81EA-4888A1CEF9CE
AssetTypeName: ProceduralModelAsset
Name: Cube
Scope: Asset
Description: A procedurally-generated cube
Group: Model
Order: 20
Icon: ..\.sdtpl\ProceduralCube.png
DefaultOutputName: Cube
FactoryTypeName: ProceduralModelCubeFactory
I guess that if you add a template file like this one to your proect and implement the factory by implementing AssetFactory<ProceduralModelAsset>
and specifying it in the FactoryTypeName
of your template you can make your procedural model appear in the new Asset Window.
You also need to edit your game .sdpkg file to include your template:
!Package
SerializedVersion: {Assets: 3.1.0.0}
Meta:
Name: StrideGameMenu.Game
Version: 1.0.0
Authors: []
Owners: []
Dependencies: null
AssetFolders:
- Path: !dir ../Assets/Shared
- Path: !dir Effects
ResourceFolders: []
OutputGroupDirectories: {}
ExplicitFolders: []
Bundles: []
TemplateFolders:
- Path: !dir Templates/Assets
Group: Assets
Files:
- !file Templates/MyCube.sdtpl
RootAssets:
- 1b4052b1-fc6a-4d8b-8b3e-2674f6a73895:MainScene
As you can see I can see myCube inside my project:
Thanks, It worked. To an extent.
In order to write AssetFactory<ProceduralModelAsset> implementation, I had to take PackageReference to "Stride.Core.Assets" and "Stride.Assets.Model", and those required that the dependee library has to have TargetFramework of "net6.0-windows7.0". I can't have non-windows target framework.
I guess that since AssetFactory is an editor class it should be Windows only as stride editor is Windows Only at the moment. I suggest to add these in yout .Windows project instead of your game one.
Yeah, AssetFactory to its own library.
Let me know if it works. I have just began to wonder inside the engine internals :)
It works very nicely! I separated into xxx.Asset and xxx.Asset.Editor class libraries.
This issue could be closed if this document page was extended with procedural model template section, that contains @tebjan's instructions and @mattiascibien 's example.
Game Studio cannot discover exported IProceduralModel classes from project, only the built-in ones.
Could the Game Studio be updated so that it scans for the exported IProceduralModel classes from the managed .dll files, and adds them to the Asset menu. The scanning part is should be easy to do with Mono.Cecil which can enumerate anything inside managed .dll without loading into appdomain.