Exemplo n.º 1
0
        // Collects all NetVars in active network components and send those that have been updated.
        IEnumerator UpdateLoop()
        {
            bool[] updatedNetVars = new bool[NumNetVars];
            while (ServiceLocator.NetworkService.IsActive)
            {
                yield return(new WaitForSecondsRealtime(1f / updatesPerSecond));

                // Get updated netvars
                RefreshUpdatedNetVars(ref updatedNetVars);

                // Check if any NetVars were updated.
                if (ServiceLocator.NetworkService.IsActive && updatedNetVars.ArrayContainsValue(true) && ServiceLocator.NetworkService.ActiveSocket.NumActiveConnections > 0)
                {
                    WriteAndSendNetVars(updatedNetVars);
                }
            }
        }