void Awake() { Debug.Assert(Net != null); Debug.Assert(CubeServer != null); Debug.Assert(CubeClient != null); Data = new CubeTransformData(); Net.RegisterNetworkDataClass <CubeTransformData>(CubeTransformData.ID); Net.OnNetworkDataReceived += OnDataReceive; }
void OnDataReceive(object sender, ReceivedNetworkDataEventArgs args) { if (args.Type == CubeTransformData.ID) { CubeTransformData data = (CubeTransformData)args.Data; if (Net.IsServer()) { CubeClient.position = data.Position; CubeClient.rotation = data.Rotation; } else { CubeServer.position = data.Position; CubeServer.rotation = data.Rotation; } } }