stride3d / stride

Stride Game Engine (formerly Xenko)
https://stride3d.net
MIT License
6.45k stars 933 forks source link

Game won't start, build succeeded; Run will instantly close; First Person Shooter Template #468

Closed chaojian-zhang closed 4 years ago

chaojian-zhang commented 5 years ago

Background

Release Type: Official Release

Version: 3.1.0.1-beta02-0615

Platform(s): Windows 10

Describe the bug

Symptom:

If debug the solution inside Visual Studio will receive following error at game.Run() inside Main():

Xenko.Core.Serialization.Contents.ContentManagerException: 'Unexpected exception while loading asset [GameSettings]. Reason: No serializer available for type id f6e78a35184f6fe1d27096e38ec09340 and base type Xenko.Data.Configuration. Check inner-exception for details.'

Inner Exception:
ArgumentException: No serializer available for type id f6e78a35184f6fe1d27096e38ec09340 and base type Xenko.Data.Configuration.

(Potentially) Similar Issue: Xenko.Core.Serialization.Contents.ContentManagerException when trying to run project

Cause and (Failed) Solution:

Search through the whole solution for text appearance f6e78a35184f6fe1d27096e38ec09340 and f6e7 because I realized it's not an actual GUID format, but no result, could it be from some some sort of "Cache"? Clean solution doesn't help. I think it would be helpful if I can see what actually happened inside this function call but I don't know how I can possibly step into engine code to see what happened?

People see online talking about Serialization error mentioned something related to scripts or project settings, but I didn't change those? Wrong name space could have affected but all namespaces I use in scripts are correct. The game settings and project settings are almost exact as default FPS tmeplate. Except I moved folders around a bit.

How to re-create

  1. Create a first person shooter template (does it work with anything else?)
  2. Click Run, this works
  3. Create folder Scenes
  4. Move MainScen into Scenes, Click run, Game Studio outputs (0,0)]: Info:Deployment of XenkoSerializationError.Windows successful. but the game can no longer run
  5. Open the solution using VS2019 and debug we will see the error: Xenko.Core.Serialization.Contents.ContentManagerException: 'Unexpected exception while loading asset [GameSettings]. Reason: No serializer available for type id f6e78a35184f6fe1d27096e38ec09340 and base type Xenko.Data.Configuration. Check inner-exception for details.'. Notice the very specific ID string: f6e78a35184f6fe1d27096e38ec09340 - usually when we create a new template all assets have a new set of ID, but this ID is always the same.

Expected behavior

Everything should just work.

Notice:

  1. At this time if we move MainScene back to Assets folder and delete Scenes folder, the game still have the same Xenko.Core.Serialization.Contents.ContentManagerException: and there seems no way to fix this
  2. Notice in general GameSettings asset also cannot be moved into subfolders of Assets, this is irrelevant of FPS template, but applicable to empty New Game as well
  3. If we create Scenes folder then create a new scene directinside then assign that as startup scene in GameSettings, do a save, then move MainScene into Scenes, then change GameSettings to Scenes/MainScene
  4. Apply the same procedure to an Empty Game, there is no issue at all; So I suspect it has something to do with First Person Shooter template
  5. What's more, it appears you cannot move any of the Crosshair256, Skybox Texture, Skybox, Bullets assets into subfolder, otherwise there can be exceptions like [RouterClient]: Error: Could not connect to connection router using mode Connect. Xenko.Engine.Network.SimpleSocketException: Connection router did not connect back to our listen socket at Xenko.Engine.Network.RouterClient.<InitiateConnectionToRouter>d__5.MoveNext() Xenko.Engine.Network.SimpleSocketException: Connection router did not connect back to our listen socket at Xenko.Engine.Network.RouterClient.<InitiateConnectionToRouter>d__5.MoveNext() and some other issues.

Screenshots

Below are screenshots showing git-version controlled diff between me creating a Scenes folder, putting MainScene into that folder, do a save, then move MainScene back into Assets folder and delete Scenes folder.

Image 2019-06-08 214941 Image 2019-06-08 214957 Image 2019-06-08 214927

Additional context

Remark

This is very bad (not morally, but confusing), because I once setup several scenes with First Personal Template and moved MainScene into Scenes folder, only to discover the whole game cannot no longer run and there is no way to fix it, and I would have to start creating all those scenes again because apprantly there is currently no way to migrate assets between projects and I am not sure whether it's safe to just copy assets around. Please help! Thanks.

Final Remark

Apparently, reverting all changes in Assets\GameSettings.xkgamesettings will resolve the problem, specifically, it's below lines that's causing the issue:

    - !Xenko.Navigation.NavigationSettings,Xenko.Navigation
        EnableDynamicNavigationMesh: false
        IncludedCollisionGroups: AllFilter
        BuildSettings:
            CellHeight: 0.2
            CellSize: 0.3
            TileSize: 32
            MinRegionArea: 2
            RegionMergeArea: 20
            MaxEdgeLen: 12.0
            MaxEdgeError: 1.3
            DetailSamplingDistance: 6.0
            MaxDetailSamplingError: 1.0
        Groups:
            -   Id: 20c6d98c-4c9b-40c0-aa04-138543a9eedd
                Name: New group
                AgentSettings:
                    Height: 1.0
                    MaxClimb: 0.25
                    MaxSlope: {Radians: 0.7853982}
                    Radius: 0.5
xen2 commented 5 years ago

Thanks for the detailed bug report.

What is happening:

As a result, editor adds NavigationSettings to the game, but the game doesnt reference Xenko.Navigation so don't recognize this type when deserializing the settings.

A quick fix would be to change all those occurences of GetOrCreate<NavigationSettings> to just do a Get<NavigationSettings> and handle null case. A longer term fix will be to turn the editor to be aware of plugins as well. This would likely go as far as having editor-side plugins for Physics, Navigation, etc... As a result, all editor code concerning NavigationSettings wouldn't even be loaded in the editor if the game doesn't use Xenko.Navigation. Part of this is tracked in #13.

chaojian-zhang commented 5 years ago

Thank you very much for your reply, that's very helpful.

I will try to follow your instruction adding reference to the Navigation package to see whether it works just to verify the cause when I get a chance and update this comment.

In the meantime I will mark the issue closed.

xen2 commented 5 years ago

I will reopen the issue to track the fact we need to fix those GetOrCreate<NavigationSettings>().

Eideren commented 4 years ago

Closing this one as #580 is more explicit.