-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Set syncvar variables after calling the hook (#659)
Previously, during deserialize, Mirror either called the hook for a syncvar or it set the variable, but never both. So users had to set the variable inside the hook. ```cs class Player : NetworkBehaviour { [SyncVar(hook=nameof(OnVarChanged))] public int myvar; public void OnVarChanged(int newvalue) { Debug.Log("Got new value " + newvalue); Debug.Log("Old value is " + myvar); // with this pull request the following line is no longer needed // the weaver will do this after the hook finishes // this.myvar = newvalue; } } ``` fix: Hook not working with NetworkIdentity or GameObjects Deserializing NetworkIdentity or GameObjects was broken, it called the hook only if there was no hook, and it saved the variable only if there was a hook.
- Loading branch information
Showing
1 changed file
with
35 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters