EntityComponent not getting values when being deserialized
Open
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
- Attach both components to an entity and set the "Asset" property to a prefab.
- Save
Two things you'll notice: - The prefab doesn't get linked into the build when using MyStoryGameMode1, but does with MyStoryGameMode2.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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