[SOLVED] What is wrong with this SyncVar

I am trying to use SyncVar but I do not fully understand what I am doing wrong, if I do it wrong that is. Here is the situation:

  1. I have two public SyncVar’s: redFunds and blueFunds and two local “old”-version to compare with
  2. I initiate the SyncVar in Start by using Cmd_UpdateXxx, that works
  3. I have two buttons, one for each SyncVar
  4. In Update i compare the SyncVar vs. the oldXxxFunds. If a hit i display on scene

When i run the code it does display the correct numbers on the scen on both players (Red & Blue) but that is not fully reflected in the editor when looking at the “public” SyncVar’s. When pressing the red button it only reflect, in the editor, on the red player not the Blue.

Can someone explain to me what i am doing wrong here? …if I am doing something wrong that is. Shouldn’t i see the changes in the editor as well?

[SyncVar] public int redFunds;
[SyncVar] public int blueFunds;
public int oldRedFunds;
public int oldBlueFunds;



void Start () {

    if (!isLocalPlayer)
            return;
    Cmd_UpdateRed (10);
    Cmd_UpdateBlue (20);

}


// Button
void btn_Red () {
    if (!hasAuthority)
            return;
    Cmd_UpdateRed (10000);
}

void btn_Blue () {
     if (!hasAuthority)
            return;
    Cmd_UpdateBlue (20000);
}

[Command]
void Cmd_UpdateRed (int _value) {
    redFunds = _value;
}

[Command]
void Cmd_UpdateBlue (int _value) {
    blueFunds = _value;
}

void Update () {
   
    if (redFunds != oldRedFunds) {

        txt_RedTotalFunds = GameObject.Find ("txt_RedTotalFunds").GetComponent<Text> ();
        txt_RedTotalFunds.text = "$" + redFunds;
        oldRedFunds = redFunds;
    }

    if (blueFunds != oldBlueFunds) {

        txt_BlueTotalFunds = GameObject.Find ("txt_BlueTotalFunds").GetComponent<Text> ();
        txt_BlueTotalFunds.text = "$" + blueFunds;
        oldBlueFunds = blueFunds;
    }
   
}

I solved the problem. The red and blue funds variables are unique in each player, so if you update the red funds in the red player, it will not be updated in the blue player. The solution is to have a, non player, script that is shared in a ScriptContainer with the actual SyncVar’s, which is access from the players.