public void SerializeWorld(World world, NetworkPlayer player)
    {
        string size = "";

        using (MemoryStream stream = new MemoryStream())
        {
            using (WorldOutputStream writer = new WorldOutputStream(stream, compression))
         			{
                writer.Write(world);
                size = stream.Length.GetSizeReadable();

                networkView.RPC("NetworkUpdateWorld", player, stream.ToArray());
            }
        }

        UnityEngine.Debug.Log("world sent (" + size + " | " + compression + ")");
    }
Ejemplo n.º 2
0
    public void Save(string path, CompressionType compression = CompressionType.NONE)
    {
        World world = GetComponent<World>();

        if (!world.initialized)
            return;

        Stopwatch stopWatch = Stopwatch.StartNew();

        string size = "";

        using (FileStream stream = new FileStream(path, FileMode.Create))
        {
            using (WorldOutputStream writer = new WorldOutputStream(stream, compression))
         			{
                writer.Write(world);
                size = stream.Length.GetSizeReadable();
            }
        }

        stopWatch.Stop();
        UnityEngine.Debug.Log("world saved (" + stopWatch.ElapsedMilliseconds + " ms | " + size + " | " + compression + ")");
    }