stride3d / stride3d/stride

EntityComponent not getting values when being deserialized

Open
#1,635 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Serialization bug
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

  1. Attach both components to an entity and set the "Asset" property to a prefab.
  2. Save
    Two things you'll notice:
  3. The prefab doesn't get linked into the build when using MyStoryGameMode1, but does with MyStoryGameMode2.
  4. The prefab asset ID is properly saved into the asset file (which means the issue is only for deserialization).
  //
  // MyStoryGameMode1 always has null values, even though the values are set inside the stride asset files.
  //  - You can also test this by noticing the Prefab asset inside the GameStudio editor doesn't get linked into the build,
  //    where as it does when using MyStoryGameMode2.
  //
  [DataContract]
  public struct ClassReference
  {
      public Prefab Asset { get; set; }
  }
  [DataContract("MyGameMode", Inherited = true)]
  public abstract class MyGameMode : EntityComponent
  {
      [DataMember]
      public ClassReference PlayerClass { get; set; }
  }
  public abstract class MyGameMode<T> : MyGameMode
  {
  }
  public abstract class MyNetGameMode<T> : MyGameMode<T>
  { 
  }
  // Doesn't de-serialize
  public class MyStoryGameMode1 : MyNetGameMode<object>
  {
  }
  // Does de-serialize because we changed the base.
  public class MyStoryGameMode2 : MyGameMode<object>
  {
  }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the MyStoryGameMode1 and MyStoryGameMode2 class hierarchies, attaching both components and assigning a prefab to ClassReference.Asset before saving. Compare the deserialization paths for the inherited generic EntityComponent types and verify that MyStoryGameMode1 restores the prefab asset ID and links the prefab into the build, matching MyStoryGameMode2.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.