FirstGearGames / FishNet

FishNet: Unity Networking Evolved.
Other
1.39k stars 149 forks source link

Syncvars can not be initialized on Awake any more #647

Closed EVITechnologyDevelopment closed 7 months ago

EVITechnologyDevelopment commented 7 months ago

General: Unity version: 2022.3.12f Fish-Networking version: 4.2.0 and 4.1.2 Discord link: https://discordapp.com/channels/424284635074134018/1034477094731784302/1228051377587224586

Description: According to the documentation, Syncvars default value can be set on awake method, but actually this seems to be not working anymore on FN 4.2.0 and 4.1.2

Replication: Copy and paste the following code in a script placed in a network object in a Scene configured to run as server:

``

private readonly SyncVar<bool> varX = new SyncVar<bool>();

private void Awake() {
    varX.Value = true;
}

public override void OnStartServer() {
    base.OnStartServer();

    Debug.Log("varX value: " + varX.Value);

}

` image

As soon as the server starts a new Log should appear in the console showing the current value of varX syncvar image

Expected behavior: The output log should show that the varX value is true, not false since we are setting a default value of true in awake method

FirstGearGames commented 7 months ago

Resolved in 4.2.1