Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.IO;
- [Serializable]
- public class Columns
- {
- public Columns(int _xPos, int _yPos, List<BlockProperties> _properties) {
- xPos = _xPos;
- yPos = _yPos;
- properties = _properties;
- }
- public int xPos;
- public int yPos;
- public List<BlockProperties> properties = new List<BlockProperties> ();
- }
- [Serializable]
- public class BlockProperties
- {
- public BlockProperties(int _num, bool _flag) {
- num = _num;
- flag = _flag;
- }
- // Various ints and bools
- public int num;
- public bool flag;
- }
- public class DictionarySerializer<TKey, TValue> : MonoBehaviour {
- public static byte[] Save(Dictionary<TKey, TValue> dictionary) {
- var binFormatter = new BinaryFormatter ();
- using (var mStream = new MemoryStream())
- {
- binFormatter.Serialize(mStream, dictionary);
- return mStream.ToArray ();
- }
- }
- public static Dictionary<TKey, TValue> Load(byte[] bArray) {
- using (var mStream = new MemoryStream())
- {
- var binFormatter = new BinaryFormatter();
- mStream.Write(bArray, 0, bArray.Length);
- mStream.Position = 0;
- return binFormatter.Deserialize(mStream) as Dictionary<TKey, TValue>;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment