uNet sync issue - Beginner's problem

Hi everbody,

I’m new to uNet and I’m having problems with syncing variables to the host. I have updated Unity to the latest patch, followed the UNET tutorial and read the documentation, but I’m sure something slipped by and I haven’t gotten this code to run. I’m trying to get both the host and a client to control a single variable.

The code is very simple, every time I do a right click the value is increased by 1; when I do a left click it should be synced up. Here’s the code

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class NetworkTestScript : NetworkBehaviour {
	
	[SyncVar(hook = "HookTest1")] 
	private int testValue1;

   // I just use this variable to make the sync variables visible in the inspector
	public int showTest1;
	public int myValue;

	// initializing with some number
	void Awake()
	{
		testValue1 = -90000;
	}

	// the controls
	void Update()
	{
		if (isLocalPlayer) {
			if (Input.GetMouseButtonUp (0)) {
				UpdateTheData();
			}
			if(Input.GetMouseButtonUp(1))
			{
				myValue ++;
			}
		}

		showTest1 = testValue1;
	}

	void UpdateTheData()
	{
		TransmitValue ();
	}
	
	[Command]
	void CmdGiveStringToServer(int _myVal)
	{
		Debug.Log (" my name is "+name+ " I am the Server: "+ isServer+" I am local: "+ isLocalPlayer +" the value recieved is "+ _myVal);
		testValue1 = _myVal;

		Debug.Log ("Values are now "+ testValue1);
	}
	
	[ClientCallback]
	void TransmitValue()
	{
		Debug.Log ("Transmitting from "+ name +" the value of "+ myValue);
		CmdGiveStringToServer( myValue);
	}

	//this just lets me know when it was modified.
	void HookTest1(int _var)
	{
		Debug.Log ("the test1 variable has been synced to "+ _var);
	}
}

However, even after the hook is activated, the value in the server does not change
54092-screen-shot-2015-09-11-at-33942-pm.png
while this appeared in the command line, the inspector still showed a value of 2.

when I tried updating the value from the client this happened:
54093-screen-shot-2015-09-11-at-34010-pm.png

Notice how both objects say they are the server. The value updated but only in that object, not syncing with the host. Likewise, when I change the value of the host, it does not change in the client.

I know I must be forgetting something really simple, but I can’t place a finger on it. Do you guys know what I might be doing wrong?

Found the answer; so the code is actually working fine; it is the way that I was reading it was wrong. I was expecting the [syncVar] to change across all instances of the script, not just the one in that particular gameobject. Thanks to everybody who read the question.