MLAPI - networked variables in Game Manager

Hi,

I’m trying to create a simple multiplayer game in Unity. I decided to use MLAPI but I have some smaller and bigger problems due to lack of informations about this new module.

In order to create a game I need to set some Networked variables that will be synchronized across all players to keep some world related informations (eg. whose turn is currently). To do that I was trying to use NetworkedVariable in my custom NetworkManager but without results. Same when I was trying to do that in my GameManager.

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;
using MLAPI;
using MLAPI.NetworkVariable;

public class MyNetworkManager : NetworkManager
{

    NetworkVariableInt test = new NetworkVariableInt(new NetworkVariableSettings { WritePermission = NetworkVariablePermission.Everyone }, 10);

    public void PrintValue()
    {
        Debug.Log(test.Value);
    }

    public void Increase()
    {
        test.Value = test.Value + 1;
    }
}

Can anyone point me to the correct approach to solve this problem?
I was looking for some examples and tutorials but i found only informations about creating players. That doesn’t solve my problem.

You have to sync variables with RPCs
here is a video on how to do that:

here’s some code I wrote that does it with a string

[SerializeField]
    Text nameText;

    public NetworkVariableString playerName = new NetworkVariableString();

[ServerRpc]
    public void UpateTheNameServerRpc(string newName)
    {
        playerName.Value = newName;
    }

    private void OnEnable()
    {
        playerName.OnValueChanged += OnNameChanged;
    }
    private void OnDisable()
    {
        playerName.OnValueChanged -= OnNameChanged;
    }
    void OnNameChanged(string oldName,string newName)
    {
        if (!IsClient) { return; }
        nameText.text = newName;
    }