UnityCommunity / UnityLibrary

:books: Library of all kind of scripts, snippets & shaders for Unity
https://unitycommunity.github.io/UnityLibrary/
MIT License
3.83k stars 446 forks source link

Add Serializable Types #19

Closed hasanbayatme closed 7 years ago

hasanbayatme commented 7 years ago

Hi.

I have found some Unity types such as Vector3, Quaternion, ... does not support serialization, while we need to serialize them.

So, it is good idea to make an serializable version of them. for example Vector3Serializable.

Here is a simple example using SerializableAttribute: (Have a look at examples link at below to get idea)

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public struct Vector3Serializable {

    public float x;
    public float y;
    public float z;

    // Place Constructors

    // Do implicit conversion between Vector3 and Vector3Serializable

}

Or by using ISerializable interface.

Now, the list of types that we can make:

Also, we can add some more serializable custom types such as SerializableDictionary, SerializableCollection or SerializableList.

Or even some custom classes such MyCustomType.

Also there might be some unserializable types in System types.

Thanks.

hasanbayatme commented 7 years ago

Added, Close #19.

If you need more serializable types just let us know.