Data save/load, RPC, transfer data to/from server

After the May 25 “Unity Game Library” will not be available in AssetStore , because now ULIB client files will be available only in the full version ULIB.
Forum thread about ULIB full version can be found here.

Clients library which allows to serialize data from Unity3D to bytesArray and from a byteArray to objects Unity3D.

Makes easy to save game data to a file or server , loading data runtime, the data transfer . Can be used to transfer any data between the game client through RPC.
Allows the use of byteArray compression (for example, for mesh or large arrays) or encrypt

Enclude:
FileManager - class provides methods for loading, reading, searching, and saving files (include ini-file with section)
LanguageManager - This class for add dynamic multilanguage support to game. Load language any time, change runtime.Provides methods for managing the list of translation, the translation of a key, etc.
Serializer - provides methods for serializing and deserializing objects, compression, encryption.

ULIB use to save data to file
Not all objects can be serialized. But the list of available classes for serialization is very large. Full list of classes that can be serialized is written below. Even if the desired class of Unity is not listed - it does not mean that it can not be serialized, ULIB try to serialize it yourself. I am constantly working to increase this list. If what is your object can not be serialized - you can connect your own rules to handle the serialization and packing / unpacking your property yourself. To deserialize a class should be available in the assembly.
**Saving a file **
You just give away your property in ULIB and get ready to save the byte array. Then you can just store an array of bytes in the file. Or you can pre-compress it. Or you can pre-encrypt a byte array. Or you can encrypt and compress, or compress and encrypt.
Reading from a file
After reading from a file you get an array of bytes. This array of bytes you are sending in ULIB. Get back to your object. You do not need a special decryption or decompression. ULIB will determine the necessary operations and will give you a finished object. If your file is encrypted - you will need to specify keys.
Recovery of references to objects
When deserializing ULIB will try to recover the possible connection of objects that were to be serialized. This means that if your object in a variable was specified the same material - after deserialization of these variables will be listed on the same single instance of the material. This applies not only Unity classes.
Send via RPC
In RPC you can send a small set of types. ULIB can solve this problem. Now you can send the RPC, the types that are supported ULIB. To send data preparation for RPC use EncodeToString. To deserialize, use the feedback Decode (your string).
**Supported Types **
Simple Types boolean, integer, float, string
Enumerators Array , ArrayList, Hashtable, List , Dictionary <K,V>
Unity Classes Vector2/3/4, Quaternion, Rect, Color, Mesh, Texture2D, PhysicMaterial, GameObject, Material, MeshFilter, MeshRenderer, Transform, Collider, Light, Camera, Rigidbody, Projector, ParticleEmitter, and some subclasses of MonoBehaviour
Other Subclasses of System.Object, Enum

AssetStore : only $25

Documentation (*.chm)

Online documentation

FileManager Description (en/ru)

Support is provided by email support@reneos.com

A small announcement features new versions of libraries for Unity3D games - ULIB:

  • Small time to serialize, about 5-10 times;

  • Added support for many Unity3D classes: Camera, Light (all types), Projector, Material, Texture2D, PhysicMaterial, Transform, Rigidbody, Collider (including MeshCollider, CapsuleCollider, SphereCollider, BoxCollider, WheelCollider), ParticleEmitter (base class);

  • Added support for serialization your own components (MonoBehaviour)

  • Added support for serialization Enum

  • A single instance of object: when the deserialization is now present as many copies of objects as they were before the serialization (for example, if two or more MeshRenderer.sharedMaterials contain the same material - after deserialize MeshRenderer.sharedMaterials will contain a one copy of the material ). This allows you to save a large number of copies of objects in a scene with little increase in file size;

  • Recovery of references to objects from scripts : if the script contains field and set to GameObject link or other object - after deserialization, this link will be restored;

  • Added the ability to encrypt stored files;

In the near future a new version will be available on ULIB AssetStore.

Library updated on Asset Store

Added classes for working with files and translations.
Added documentation.
Added examples.

See the new description in first post

Now you can detail read about FileManager functions online: FileManager Description (en/ru)

New version send to AssetStore

Changed examples - add dictionary save/load.
Update LanguageManager and FileManager.
Add support serilize GUITexture.
Add ResourceManager.
Remove small bugs.

The new version LangaugeManager adds the ability to localize not only text but sound and texture. All the resources you can load from local files (png, jpg - graphics formats or ulib-format with compression and encryption). It is also available to download resources from the server. Through the use of a ResourceManager, the download occurs only once.
It’s very simple. You specify the source files (local or remote), a download of the available languages​​, the result as a OnGUI. Other everything for you do ULIB.
Available translation by key, translation with the replacement tag, texture for the current language and other features LanguageManager, such as partial loading of the translation for the current module / scenes, etc.

The library ULIB (client) updated on AssetStore to version 4.4.0.1

The new version adds new manager for fast development of games, fixed bugs , changes in the serialization algorithm, adds the ability to use external serializers.

Price change to $30.

Detailed documentation is being prepared and will be available within a few days.
Thank you.

when I open de file en try to fill my List i get this error (221)DecodeObject can’t create Instance of CraftItem

CraftItem inherits form Item

using UnityEngine;
using System.Collections;

public class CraftItem : Item {

	public CraftItem(int id,string name,string[] descriptions ,Texture2D texture,GameObject prefab){
		base.id = id;
		base.name =  name;
		base.descriptions = descriptions;
		base.texture = texture;
		base.prefab = prefab;
	}
	
	
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Item  {

  	public int id ;
	public string name = "";
	public string[] descriptions = new string[3]{"","",""};
	public Texture2D texture;
	public GameObject prefab;
	
	public Item(){
	}
	public Item(int id,string name,string[] descriptions ,Texture2D texture,GameObject prefab){
		this.id = id;
		this.name =  name;
		this.descriptions = descriptions;
		this.texture = texture;
		this.prefab = prefab;
	}
}

Any idea how to fix this ??

ps.
its a great scripting tool

Hi!
I think that the problem lies in the class constructor. In this version of ULIB you can use only constructor with no parameters.
Thank you.

thank that solves my problem

Hi.
For those who want to save (or send) other data (as opposed to ULIB) or who want to extended ULIB in your project - I hope this method should work.
As well as processing components, processing of objects can also be expanded or modified.
You can replace the function Mesh what used in ULIB on your own function.

  1. Create a function for encode Mesh by example:
byte[] MyOwnMeshEncoder(object val)
    {
        var ms = (Mesh) val;
       //you can used list of property what you want
        var table = new Hashtable
                                               {
                                                   {"vertices",ms.vertices},
                                                   {"uv",ms.uv},
                                                   {"triangles",ms.triangles},
                                                   {"tangents",ms.tangents},
                                                   {"normals",ms.normals}
                                               };
        var dataBytes = _serializer.EncodeHashtable(table);
        var dataBytesLength = dataBytes.Length;
        var result = new byte[1 + dataBytesLength];
        result[0] = 22;//this is code for Mesh!!
        Buffer.BlockCopy(dataBytes, 0, result, 1, dataBytesLength);
        return result;
    }
  1. Create a function for decode Mesh by example.
object MyOwnMeshDecoder(byte[] inBytes, ref int startPos)
    {
        var mesh = new Mesh();
        var table = _serializer.DecodeHashtable(inBytes, ref startPos);
        mesh.vertices = (Vector3[]) table["vertices"];
        mesh.uv = (Vector2[]) table["uv"];
        mesh.triangles = (int[])table["triangles"];
        mesh.tangents = (Vector4[]) table["tangents"];
        mesh.normals = (Vector3[]) table["normals"];
        return mesh;
    }
  1. Add these to the code before (ULIB first seeking external functions ).
Serializer.TypeEncoders.Add(typeof(Mesh), MyOwnMeshEncoder);
Serializer.TypeDecoders.Add(22, MyOwnMeshDecoder);

Or you can override this example for used your own list of properties for extend ULIB.

Code for used:

22 - Mesh
23 - Texture2D
24 - Physics
25 - GameObject
26 - Material

You can use your code for your class - please used from 150 to 199. (this opportunity only for test now, sorry)

Please - not used this way if you send data to / from ULIB-PHP ! Now this only for local.

If there are difficulties or questions - please let me know.

Thank you.

P.S. No need to update ULIB - this method should work in the current latest version.

Does this work for mobile platforms?

Yes, it works on mobile platforms. I tested the work on Android, and buyers have written to me that it works on iOS.

Awesome thanks! I’ll be getting this!

Just purchased and really enjoyed playing with it. Nice work and I’m glad I bought it.

Doesn’t seem to serialize the velocity of a game object. Is that possible?

Yes, it can be.
ULIB does not support all components Unity3d.
But you can always expand (or change) the rules of serialization - please see the examples from “example_used_external.unity”.
Also, you can read help from my blog: http://game.reneos.com/blog/archives/1207
In any case - if you can not solve it by yourself - please send me an email with a description of the problem: support@reneos.com
Thank you.

Thanks for the reply. I’ll have a go at it.

I do see that ULib supports rigidbodies but that probably only supports the public properties of a rigidbody.

So the correct TypeDecorder would be 24 Phyics? Makes me wish I bought the source code version.

ULIB read fields and property from object only if ULIB can set them later (not readOnly)
Please send me a part of code that causes problem, I need to understand how I can help you.
Thank you.