context: using UnityEngine;
  using System.Collections;
  using System.Collections.Generic;
  using System.Reflection;
  
  public static class ES2 
  {
  	public static bool initialised = false;
  	
  	/*
  	 * 	Initializes the type list by instantiating the ES2Init object from Resources
  	 */
  	public static void Init()
  	{
  		GameObject.Instantiate(Resources.Load("ES2/ES2Init"));
  	}
  		
  	#region Save Methods
  
  	public static void Save<T>(T param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(T param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  
  	public static void Save<T>(T[] param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  
  	public static void Save<T>(T[] param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(T[,] param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  
  	// Explicit method to work around stripping issue.
  	public static void Save<T>(T[,] param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  
  	// Explicit method to work around stripping issue.
  	public static void Save2DArray<T>(T[,] param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save2DArray<T>(T[,] param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(T[,,] param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	// Explicit method to work around stripping issue.
  	public static void Save<T>(T[,,] param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	// Explicit method to work around stripping issue.
  	public static void Save3DArray<T>(T[,,] param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save3DArray<T>(T[,,] param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<TKey, TValue>(Dictionary<TKey,TValue> param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<TKey,TValue>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<TKey,TValue>(Dictionary<TKey,TValue> param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<TKey,TValue>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(List<T> param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(HashSet<T> param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(Queue<T> param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(Stack<T> param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(List<T> param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(HashSet<T> param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(Queue<T> param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  	
  	public static void Save<T>(Stack<T> param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{	
  			mWriter.Write<T>(param, newSettings.filenameData.tag);
  			mWriter.Save();
  		}
  	}
  
  	public static void SaveRaw(string param, string identifier)
  	{
  		SaveRaw(System.Text.Encoding.UTF8.GetBytes(param), identifier);
  	}
  	
  	public static void SaveRaw(string param, string identifier, ES2Settings settings)
  	{
  		SaveRaw(System.Text.Encoding.UTF8.GetBytes(param), identifier, settings);
  	}
  
  	public static void SaveRaw(byte[] param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(param);
  			mWriter.Save(false);
  		}
  	}
  	
  	public static void SaveRaw(byte[] param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(param);
  			mWriter.Save(false);
  		}
  	}
  	
  	public static void SaveRaw(TextAsset param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(param.bytes);
  			mWriter.Save(false);
  		}
  	}
  	
  	public static void SaveRaw(TextAsset param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(param.bytes);
  			mWriter.Save(false);
  		}
  	}
  
  	public static void AppendRaw(string param, string identifier)
  	{
  		AppendRaw(System.Text.Encoding.UTF8.GetBytes(param), identifier);
  	}
  	
  	public static void AppendRaw(string param, string identifier, ES2Settings settings)
  	{
  		AppendRaw(System.Text.Encoding.UTF8.GetBytes(param), identifier, settings);
  	}
  	
  	public static void AppendRaw(byte[] param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		newSettings.fileMode = ES2Settings.ES2FileMode.Append;
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(param);
  			mWriter.Save(false);
  		}
  	}
  	
  	public static void AppendRaw(byte[] param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		newSettings.fileMode = ES2Settings.ES2FileMode.Append;
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(param);
  			mWriter.Save(false);
  		}
  	}
  	
  	public static void AppendRaw(TextAsset param, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		newSettings.fileMode = ES2Settings.ES2FileMode.Append;
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(param.bytes);
  			mWriter.Save(false);
  		}
  	}
  	
  	public static void AppendRaw(TextAsset param, string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		newSettings.fileMode = ES2Settings.ES2FileMode.Append;
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(param.bytes);
  			mWriter.Save(false);
  		}
  	}
  
  	public static void SaveImage(Texture2D tex, string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		if(newSettings.filenameData.extension.ToLower() != ".png")
  			Debug.LogError("Easy Save 2 Error: ES2.SaveImage can only be used to save PNG files. Please change your path extension to PNG.");
  
  		using (ES2Writer mWriter = ES2Writer.Create(newSettings))
  		{
  			mWriter.WriteRaw(tex.EncodeToPNG());
  			mWriter.Save(false);
  		}
  	}
  
  	#endregion
  
  	#region Load Methods
  
  	public static byte[] LoadRaw(string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.ReadRaw();
  	}
  	
  	public static byte[] LoadRaw(string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.ReadRaw();
  	}
  	
  	public static System.Object LoadObject(string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.ReadObject(newSettings.filenameData.tag);
  	}
  	
  	public static System.Object LoadObject(string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.ReadObject(newSettings.filenameData.tag);
  	}
  	
  	public static T Load<T>(string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.Read<T>(newSettings.filenameData.tag);
  	}
  	
  	public static T Load<T>(string identifier)
  	{
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.Read<T>(newSettings.filenameData.tag);
  	}
  	
  	public static void Load<T>(string identifier, T c) where T : class
  	{	
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			reader.Read<T>(newSettings.filenameData.tag, c);
  	}
  	
  	public static void Load<T>(string identifier, T c, ES2Settings settings) where T : class
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			reader.Read<T>(newSettings.filenameData.tag, c);
  	}
  	
  	public static T[] LoadArray<T>(string identifier)
  	{	
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.ReadArray<T>(newSettings.filenameData.tag);
  	}
  	
  	public static T[] LoadArray<T>(string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.ReadArray<T>(newSettings.filenameData.tag);
  	}
  	
  	public static void LoadArray<T>(string identifier, T[] c) where T : class
  	{	
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			reader.ReadArray<T>(newSettings.filenameData.tag, c);
  	}
  	
  	public static void LoadArray<T>(string identifier, T[] c, ES2Settings settings) where T : class
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			reader.ReadArray<T>(newSettings.filenameData.tag, c);
  	}
  	
  	public static T[,] Load2DArray<T>(string identifier)
  	{	
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.Read2DArray<T>(newSettings.filenameData.tag);
  	}
  	
  	public static T[,] Load2DArray<T>(string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.Read2DArray<T>(newSettings.filenameData.tag);
  	}
  	
  	public static T[,,] Load3DArray<T>(string identifier)
  	{	
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.Read3DArray<T>(newSettings.filenameData.tag);
  	}
  	
  	public static T[,,] Load3DArray<T>(string identifier, ES2Settings settings)
  	{
  		ES2Settings newSettings = settings.Clone(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.Read3DArray<T>(newSettings.filenameData.tag);
  	}
  	
  	public static Dictionary<TKey, TValue> LoadDictionary<TKey, TValue>(string identifier)
  	{	
  		ES2Settings newSettings = new ES2Settings(identifier);
  		using (ES2Reader reader = ES2Reader.Create(newSettings))
  			return reader.ReadDictionary<TKey,TValue>(newSettings.filenameData.tag);
  	}
  	
  	public static Dictionary<TKey, TValue> LoadDictionary<TKey, TValue>(string identifier, ES2Settings settings)
  	{
  
gt: 		ES2Settings newSettings = settings.Clone(identifier);