stride3d / stride

Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
https://stride3d.net
MIT License
6.65k stars 957 forks source link

Editor bug import asset warning bug within the game project #2354

Open Basewq opened 5 months ago

Basewq commented 5 months ago

Release Type: Official Release

Version: 4.1.0.1948+

Platform(s): Editor

Describe the bug Adding a raw asset within the project solution and importing the asset warns importing assets are not inside resource folder when there is no ResourceFolders declared in the .sdpkg file. Hitting Ok also prompts if you want to copy the asset in the resource folder. Hitting Ok here will crash the editor.

The 'New game' template is one of the rare project templates that explicitly declare the resource folder in the .sdpkg file:

ResourceFolders:
    - !dir Resources

Other templates, eg TopDown RPG do not:

ResourceFolders: []

Futhermore, it places the Resource folder (and Asset folder) one level above the game project folder.

To Reproduce Steps to reproduce the behavior:

  1. Create TopDown RPG template
  2. Go to existing Resources folder, add new raw resource (or just use an existing asset) and drag-drop into the asset sub-window
  3. Observe warning(s)

Expected behavior Handle the special case where package's Resource folder(s) are not explicitly declared.

Additional context Original feature introduced #1781 Copy raw asset into resource folder feature added here #1827

MiniMe453 commented 4 months ago

This also happens with the First Person Template.

I traced the exception to AssetCollectionViewModel.cs - Line 542 ExceptionError: Index out of range for directory.Package.Package.ResourceFolders[0]

It seems like it should be relatively easy to fix, but I wasn't able to understand where the code sets the resource folder directories. Following the code path of the package class ended up being more complicated than I expected....

Kryptos-FR commented 4 months ago

I remember fixing all templates a while back. Wasn't it included in the latest release of Stride?

edit: it was fixed in #2109, and should be present from version 4.2.0.2121 onwards.

With that said, we should add a prompt to ask for a location if it's unset. Let's track that in this issue.

Basewq commented 4 months ago

Unless I've messed around too much will my machine, I tried the RPG template with 4.2.0.2188 and the sdpkg still has ResourceFolders: []

My vague understanding is this would need to be updated since it's still pointing to the older sample 4.2.0.1? https://github.com/stride3d/stride/blob/237e8605e4b36337b8dca92d2338b1086547616a/sources/editor/Stride.Samples.Templates/ThisPackageVersion.PackageBuild.cs#L7

Oddly enough, the .cs code changes to use top level statements does come through (I guess there's some additional upgrading steps the editor understands?)

Kryptos-FR commented 4 months ago

@Basewq good point.