vrchat-community / UdonSharp

A compiler for compiling C# to Udon assembly
https://udonsharp.docs.vrchat.com
MIT License
473 stars 51 forks source link

[1.1.8] UdonSharpBehaviour/Prefab checking process happens before C# script complies, causing losing variable data added by version controls #135

Closed leftonbo closed 1 year ago

leftonbo commented 1 year ago

Describe the bug in detail: It seems UdonSharpBehaviour/Prefab checking/auto-saving process happens before C# script complies. It can cause loss of variable data in U# behaviour, especially if they are added by version controls (such as Git).

This makes major issue on Git contribution of World projects: we need checking if added new variables are lost.

Provide steps/code to reproduce the bug:

  1. Create an U# script that has no public variables. (Script A)
  2. Attach Script A to any GameObject on a scene, then save the GameObject to an prefab. (Prefab A)
  3. Save the scene then save project.
  4. Make commit any additives/changes on git. (Commit A)
  5. Add an public variable into Script A (any type is OK, notable if GameObject types).
  6. Open prefab editor on Prefab A: Change the variable added in Prefab A from default value.
  7. Save the prefab.
  8. Make commit any additives/changes on git. (Commit B)
  9. Checkout current working tree to Commit A: this will revert adding the public variable.
  10. Close Unity.
  11. Checkout current working tree to Commit B: this is the reproduction of 'Pulling from a remote', adding the public variable from version control.
  12. Re-open Unity.
  13. After script compile, observe the public variable in Prefab A.

Expected behavior: The value of public variable are still same set by [6.] process.

Actual behavior: The value of public variable are set to default value, losing checkout data.

leftonbo commented 1 year ago

I noticed this seems not be reproduced on new fresh project. i close this until i get more information.