Asset references not restored correctly on editor hot reload
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Release Type: Github
Describe the bug
If Component A has a reference to an asset and Component B references Component A then the asset will be null when accessed in a processor for Component B after the editor has hot reloaded the assembly.
It seems that Component B references an old copy of Component A after reload, breaking in the debugger shows that the correct instance exists in the EntityManager but not in the component reference.
To Reproduce
- Create a component that references any asset, for example a Model.
- Create a second component that references the first
- Create a processor that loops through the second component types and uses the Model from the referenced component
- Add an entity with the first component type and set a reference to an asset
- Add an entity with the second component type and set a reference to the first component
- Re-save any script so that the editor hot reloads the assembly
- You will now get a null exception.
Additional context
A sample project that reproduces the issue can be found here: https://onedrive.live.com/?authkey=%21AE%2DOVsio9OJ13HE&id=AB3F11B2CDEC1EB4%21278400&cid=AB3F11B2CDEC1EB4
Adding a space to the script in the sample project and saving should cause the editor show a null exception after hot reload.
Hope I make sense, it's a bit difficult to describe :)
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
Start with the linked sample project and reproduce the failure by adding a space to a script and saving it to trigger editor hot reload. Trace how component references are restored during assembly reload, focusing on why Component B retains an old copy of Component A. Done means the asset remains accessible through the referenced component in the processor after reload, without the null exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- game-dev, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100