Example #1
0
    public static void ServerSendStatsUpdate(StatsUpdateList updateList)
    {
        // Before we can Invoke our NetworkMessage, we need to make sure our centralized network object is spawned.
        // For doing that, we Instantiate the CentralNetworkObject, we obviously check if we don't already have one that is already instantiated and activated in the current scene.
        // Note : Make sure you instantiate the gameobject, and not spawn it directly, it would get deleted otherwise on scene change, even with DontDestroyOnLoad.

        if (!_centralNetworkObjectSpawned)
        {
            LogHelper.Log(LogTarget.Init, "Creating centralized network object");
            _centralNetworkObjectSpawned = GameObject.Instantiate(CentralNetworkObject);
            NetworkServer.Spawn(_centralNetworkObjectSpawned);
        }

        foreach (NetworkUser user in NetworkUser.readOnlyInstancesList)
        {
            StatsUpdateNetworkComponent.Invoke(user, updateList);
        }
    }
Example #2
0
 private void Awake()
 {
     LogHelper.Log(LogTarget.Init, "StatsUpdateNetworkComponent Awake");
     _instance = this;
 }