diff --git a/Assets/ResWork/Table/SheGotWet.xlsm b/Assets/ResWork/Table/NightWard.xlsm similarity index 100% rename from Assets/ResWork/Table/SheGotWet.xlsm rename to Assets/ResWork/Table/NightWard.xlsm diff --git a/Assets/ResWork/Table/SheGotWet.xlsm.meta b/Assets/ResWork/Table/NightWard.xlsm.meta similarity index 100% rename from Assets/ResWork/Table/SheGotWet.xlsm.meta rename to Assets/ResWork/Table/NightWard.xlsm.meta diff --git a/Assets/Scripts/AttachToGameObject/SaveMgr.cs b/Assets/Scripts/AttachToGameObject/SaveMgr.cs index 45d9ad2..be7ba32 100644 --- a/Assets/Scripts/AttachToGameObject/SaveMgr.cs +++ b/Assets/Scripts/AttachToGameObject/SaveMgr.cs @@ -1,27 +1,12 @@ -using GUPS.AntiCheat.Protected; -using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; -using TigerForge; +using GUPS.AntiCheat.Protected; +using Newtonsoft.Json; using UnityEngine; public class SaveMgr : MonoBehaviourSingletonTemplate { - EasyFileSave _EasyFile; - EasyFileSave m_EasyFile - { - get - { - if (_EasyFile == null) - { - _EasyFile = new EasyFileSave(); - m_EasyFile.Load("shegotwet"); - } - return _EasyFile; - } - } - public SaveData m_SaveData; IEnumerator Start() @@ -45,7 +30,7 @@ public class SaveMgr : MonoBehaviourSingletonTemplate public void Load() { - m_SaveData = (SaveData)m_EasyFile.GetDeserialized("SaveData", typeof(SaveData)); + m_SaveData = CryptoUtil.Load("SaveData"); if (m_SaveData == null) { m_SaveData = new SaveData @@ -61,9 +46,10 @@ public class SaveMgr : MonoBehaviourSingletonTemplate SelectGirlID = 1, LastDoY = 0, AttendanceDoY = 0, - GirlUnLockIndex = 1, MiniGameHP = table_GlobalValue.Ins.Get_Int("MiniGame_TotalEnterMoney") }; + + Open_Album(table_album.Ins.Get_DataList()[0]); } } @@ -71,10 +57,7 @@ public class SaveMgr : MonoBehaviourSingletonTemplate public void Save() { if (m_SaveData != null) - { - m_EasyFile.AddSerialized("SaveData", m_SaveData); - m_EasyFile.Save("shegotwet"); - } + CryptoUtil.Save(m_SaveData, "SaveData"); } public void Set_Option(eOption option) @@ -247,8 +230,13 @@ public class SaveMgr : MonoBehaviourSingletonTemplate Save(); } - public void Open_Image() { ++m_SaveData.GirlUnLockIndex; } - public int Get_UnLockIndex() { return m_SaveData.GirlUnLockIndex; } + public void Open_Album(albumtabledata data) + { + if (!m_SaveData.dic_ablumopen.ContainsKey(data.n_GirlID)) + m_SaveData.dic_ablumopen.Add(data.n_GirlID, new List()); + if (!m_SaveData.dic_ablumopen[data.n_GirlID].Contains(data.n_Index)) + m_SaveData.dic_ablumopen[data.n_GirlID].Add(data.n_Index); + } public int Get_SelectGirlID() { return m_SaveData.SelectGirlID; } public void Set_SelectGirlID(int id) { @@ -268,16 +256,14 @@ public class SaveMgr : MonoBehaviourSingletonTemplate } return true; } + public bool IsOpenAlbum(albumtabledata data) + { + return m_SaveData.dic_ablumopen.ContainsKey(data.n_GirlID) && + m_SaveData.dic_ablumopen[data.n_GirlID].Contains(data.n_Index); + } public int Get_ImageCount(int girlid) { - var lst = table_album.Ins.Get_DataList(girlid); - var count = 0; - for (int i = 0; i < lst.Count; i++) - { - if (lst[i].n_Index <= Get_UnLockIndex()) - ++count; - } - return count; + return m_SaveData.dic_ablumopen.ContainsKey(girlid) ? m_SaveData.dic_ablumopen[girlid].Count : 0; } public void Set_ShopReward(shoptabledata data) @@ -425,7 +411,6 @@ public class SaveMgr : MonoBehaviourSingletonTemplate ProtectedInt32 _LastDoY; public int LastDoY { get { return _LastDoY; } set { _LastDoY = value; _LastDoY.Obfuscate(); } } ProtectedInt32 _WeekOfYear; public int WeekOfYear { get { return _WeekOfYear; } set { _WeekOfYear = value; _WeekOfYear.Obfuscate(); } } ProtectedInt32 _GirlSelectIndex; public int SelectGirlID { get { return _GirlSelectIndex; } set { _GirlSelectIndex = value; _GirlSelectIndex.Obfuscate(); } } - ProtectedInt32 _GirlUnLockIndex; public int GirlUnLockIndex { get { return _GirlUnLockIndex; } set { _GirlUnLockIndex = value; _GirlUnLockIndex.Obfuscate(); } } ProtectedInt32 _AttendanceDoY; public int AttendanceDoY { get { return _AttendanceDoY; } set { _AttendanceDoY = value; _AttendanceDoY.Obfuscate(); } } ProtectedInt32 _Attendance; public int Attendance { get { return _Attendance; } set { _Attendance = value; _Attendance.Obfuscate(); } } @@ -453,6 +438,7 @@ public class SaveMgr : MonoBehaviourSingletonTemplate ProtectedBool _BuyShopDisableOne1; public bool BuyShopDisableOne1 { get { return _BuyShopDisableOne1; } set { _BuyShopDisableOne1 = value; _BuyShopDisableOne1.Obfuscate(); } } ProtectedBool _BuyShopDisableOne2; public bool BuyShopDisableOne2 { get { return _BuyShopDisableOne2; } set { _BuyShopDisableOne2 = value; _BuyShopDisableOne2.Obfuscate(); } } + public Dictionary> dic_ablumopen = new Dictionary>(); public List list_ShopLimit = new List(); public List list_ChatSaveData = new List(); } diff --git a/Assets/Scripts/UI/AlbumCard.cs b/Assets/Scripts/UI/AlbumCard.cs index 838d743..a85dc2b 100644 --- a/Assets/Scripts/UI/AlbumCard.cs +++ b/Assets/Scripts/UI/AlbumCard.cs @@ -31,20 +31,20 @@ public class AlbumCard : CardBase public override void Set_UI() { - gos[0].SetActive(m_Data.n_Index == SaveMgr.Ins.Get_UnLockIndex() + 1 && m_Data.n_Price > 0); + gos[0].SetActive(!SaveMgr.Ins.IsOpenAlbum(m_Data)); t_price.text = m_Data.n_Price.ToString(); //if (i_girl.enabled) i_girl.material = IsObtain() ? null : mat_blur; gos[1].SetActive(!IsObtain()); } - public bool IsObtain() { return m_Data.n_Index <= SaveMgr.Ins.Get_UnLockIndex(); } + public bool IsObtain() { return SaveMgr.Ins.IsOpenAlbum(m_Data); } public void OnClick_Buy() { if (SaveMgr.Ins.Check_Money(eMoney.AlbumOpen, m_Data.n_Price)) { SaveMgr.Ins.Add_Money(eMoney.AlbumOpen, -m_Data.n_Price); - SaveMgr.Ins.Open_Image(); + SaveMgr.Ins.Open_Album(m_Data); SaveMgr.Ins.Save(); LobbyUI.Ins.m_LobbyCenterProfileUI.Set(false); diff --git a/Assets/Scripts/UI/ProfileCard.cs b/Assets/Scripts/UI/ProfileCard.cs index a860a5f..cec835b 100644 --- a/Assets/Scripts/UI/ProfileCard.cs +++ b/Assets/Scripts/UI/ProfileCard.cs @@ -101,7 +101,7 @@ public class ProfileCard : MonoBehaviour { if (CanOpen()) { // 열 수 있음 - SaveMgr.Ins.Open_Image(); // 최초 한 장 공짜 지급 + SaveMgr.Ins.Open_Album(table_album.Ins.Get_DataList()[0]); // 최초 한 장 공짜 지급 SaveMgr.Ins.Save(); Set_UI(); diff --git a/Assets/Scripts/Util/CryptoUtil.cs b/Assets/Scripts/Util/CryptoUtil.cs new file mode 100644 index 0000000..3b42817 --- /dev/null +++ b/Assets/Scripts/Util/CryptoUtil.cs @@ -0,0 +1,76 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; +using Newtonsoft.Json; +using UnityEngine; + +public static class CryptoUtil +{ + private static readonly string Key = "7gT9KfL2xQ1bN4pV6sH8jD3zW0cR5mYq"; // 32Ʈ + private static readonly string IV = "aB3dE6gH9jK2mP5Q"; // 16Ʈ + + public static string Encrypt(string plainText) + { + using (Aes aes = Aes.Create()) + { + aes.Key = Encoding.UTF8.GetBytes(Key); + aes.IV = Encoding.UTF8.GetBytes(IV); + + using (var ms = new MemoryStream()) + using (var cs = new CryptoStream(ms, aes.CreateEncryptor(), CryptoStreamMode.Write)) + using (var sw = new StreamWriter(cs)) + { + sw.Write(plainText); + sw.Close(); + return Convert.ToBase64String(ms.ToArray()); + } + } + } + + public static string Decrypt(string cipherText) + { + byte[] buffer = Convert.FromBase64String(cipherText); + + using (Aes aes = Aes.Create()) + { + aes.Key = Encoding.UTF8.GetBytes(Key); + aes.IV = Encoding.UTF8.GetBytes(IV); + + using (var ms = new MemoryStream(buffer)) + using (var cs = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Read)) + using (var sr = new StreamReader(cs)) + { + return sr.ReadToEnd(); + } + } + } + + public static void Save(object data, string filename) + { + string json = JsonConvert.SerializeObject(data); + + // ȣȭ + string encrypted = Encrypt(json); + + string path = Path.Combine(Application.persistentDataPath, filename); + File.WriteAllText(path, encrypted); + + //Debug.Log("Saved to: " + path); + } + + public static T Load(string filename) + { + string path = Path.Combine(Application.persistentDataPath, filename); + + if (File.Exists(path) == false) + return default; + + string encrypted = File.ReadAllText(path); + + // ȣȭ + string json = Decrypt(encrypted); + + return JsonConvert.DeserializeObject(json); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Util/CryptoUtil.cs.meta b/Assets/Scripts/Util/CryptoUtil.cs.meta new file mode 100644 index 0000000..f775c58 --- /dev/null +++ b/Assets/Scripts/Util/CryptoUtil.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ef855febcbbf51c45bdd8ee568c300d9 \ No newline at end of file diff --git a/Assets/ThirdParty/TigerForge.meta b/Assets/ThirdParty/TigerForge.meta deleted file mode 100644 index dffc5cd..0000000 --- a/Assets/ThirdParty/TigerForge.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 01ffeed7f274cbf4f841fd7e061ef6bc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave.meta b/Assets/ThirdParty/TigerForge/EasyFileSave.meta deleted file mode 100644 index 83da48d..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 56ac68a733c3d1b45ad8ebbf2c8df088 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo.meta b/Assets/ThirdParty/TigerForge/EasyFileSave/Demo.meta deleted file mode 100644 index 32da21e..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: da326e740f7dac54683976f28bba2bed -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.cs b/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.cs deleted file mode 100644 index a098aec..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.cs +++ /dev/null @@ -1,283 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; -using TigerForge; - -namespace TigerForge -{ - public class Demo : MonoBehaviour - { - - // Instance of Easy File Save - - EasyFileSave myFile; - - // Item class - - [System.Serializable] - public class Item - { - public string name = ""; - public int quantity = 0; - } - - // Variables for this Demo. - - string character; - string nickname; - int age; - float strenght; - bool has_sword; - bool has_bow; - int[] skills; - List equipment; - Vector3 initialLocation; - Dictionary coins; - List items; - - void Start() - { - // Start a new instance of Easy File Save. The file name is not specified, so a default name will be used. - - myFile = new EasyFileSave(); - myFile.suppressWarning = false; - - // If this file already exists for some reason, I delete it. - - myFile.Delete(); - - Debug.Log(">> HELLO! I'M READY!" + "\n"); - - } - - void Update() - { - - // When [S] key is pressed: SAVE. - if (Input.GetKeyUp(KeyCode.S)) - { - Debug.Log(">> I'M GOING TO SAVE SOME DATA!" + "\n"); - - // Some values. - - equipment = new List(); - equipment.Add("Hammer"); - equipment.Add("Knife"); - equipment.Add("Rope"); - - initialLocation = new Vector3(101.5f, -30.4f, 22f); - - coins = new Dictionary(); - coins.Add("Copper", 1200); - coins.Add("Silver", 450); - coins.Add("Gold", 300); - - // Simple data. - - character = "Conan"; - age = 30; - strenght = 300.5f; - has_sword = true; - has_bow = false; - skills = new int[] { 6, 10, 22, 46, 69 }; - - myFile.Add("name", character); - myFile.Add("age", age); - myFile.Add("strenght", strenght); - myFile.Add("has_sword", has_sword); - myFile.Add("has_bow", has_bow); - myFile.Add("skills_id", skills); - - // GameObject data. - - myFile.Add("equipment", equipment); - myFile.Add("coins", coins); - myFile.Add("initialLocation", initialLocation); - myFile.Add("player", gameObject.transform); - - // Class data (serialization). - - items = new List(); - items.Add(new Item { name = "Gold", quantity = 15000 }); - items.Add(new Item { name = "Darts", quantity = 24 }); - items.Add(new Item { name = "Potions", quantity = 10 }); - - myFile.AddSerialized("items", items); - - // Custom Extension for managing BoxCollider - - myFile.AddCustom("collider", gameObject.GetComponent(), "BoxCollider"); - - // Save all the collected data. - // At the end of the process, stored data is cleared to free memory. - - myFile.Save(); - - Debug.Log(">> Data saved in: " + myFile.GetFileName() + "\n"); - ShowData(); - } - - // When [L] key is pressed: LOAD. - if (Input.GetKeyUp(KeyCode.L)) - { - // Load data from file. - if (myFile.Load()) - { - - Debug.Log(">> I'M GOING TO USE LOADED DATA!" + "\n"); - - // Simple data. - - character = myFile.GetString("name"); - age = myFile.GetInt("age"); - strenght = myFile.GetFloat("strenght"); - has_sword = myFile.GetBool("has_sword"); - has_bow = myFile.GetBool("has_bow"); - skills = myFile.GetArray("skills_id"); - - // In this case, if 'nickname' key doesn't exist, 'user_1234' string is used. - - nickname = myFile.GetString("nickname", "user_1234"); - - // GameObject data. - - equipment = myFile.GetList("equipment"); - coins = myFile.GetDictionary("coins"); - initialLocation = myFile.GetUnityVector3("initialLocation"); - - var tr = myFile.GetUnityTransform("player"); - gameObject.transform.position = tr.position; - gameObject.transform.rotation = tr.rotation; - gameObject.transform.localScale = tr.localScale; - - // Class data (serialization). - - items = (List)myFile.GetDeserialized("items", typeof(List)); - - // Custom Extension for managing BoxCollider. - - var bc = myFile.GetCustom("collider", "BoxCollider"); - var thisBoxColllider = gameObject.GetComponent(); - thisBoxColllider.center = new Vector3 { x = bc["centerX"].ToFloat(), y = bc["centerY"].ToFloat(), z = bc["centerZ"].ToFloat() }; - thisBoxColllider.isTrigger = bc["isTrigger"].ToBool(); - - // Loaded data has been used as needed. - // Stored data is manually cleared to free memory. - - myFile.Dispose(); - - Debug.Log(">> Data loaded from: " + myFile.GetFileName() + "\n"); - ShowData(); - } - } - - // When [A] key is pressed: APPEND. - if (Input.GetKeyUp(KeyCode.A)) - { - - // Simple data. - - myFile.Add("nickname", "The Warrior"); - myFile.Add("age", 32); - - // Append this data to the current file content. - // 'nickname' key is new, so its value is added to the file. - // 'age' key already exists, so its current value is updated with this new one. - - myFile.Append(); - - Debug.Log(">> New data added to: " + myFile.GetFileName() + "\n"); - Debug.Log(">> Age value updated to 32." + "\n"); - Debug.Log(">> Added nickname." + "\n"); - } - - // When [Del] key is pressed: FILE DELETE. - if (Input.GetKeyUp(KeyCode.Delete)) - { - - // Delete this file. - // This method clears stored data as well. - - myFile.Delete(); - - Debug.Log(">> The file has been deleted." + "\n"); - } - - // When [T] key is pressed: SAVING AND LOADING DATA TEST. - if (Input.GetKeyUp(KeyCode.T)) - { - - // Perform a test of writing and loading data. - // ------------------------------------------- - - myFile.Delete(); - - // Add some values to the internal storage for saving and loading test. - - equipment = new List(); - equipment.Add("Hammer"); - equipment.Add("Knife"); - equipment.Add("Rope"); - - initialLocation = new Vector3(101.5f, -30.4f, 22f); - - character = "Conan"; - age = 30; - strenght = 300.5f; - has_sword = true; - has_bow = false; - - items = new List(); - items.Add(new Item { name = "Gold", quantity = 15000 }); - items.Add(new Item { name = "Darts", quantity = 24 }); - items.Add(new Item { name = "Potions", quantity = 10 }); - - myFile.Add("name", character); - myFile.Add("age", age); - myFile.Add("strenght", strenght); - myFile.Add("has_sword", has_sword); - myFile.Add("has_bow", has_bow); - - myFile.Add("equipment", equipment); - myFile.Add("initialLocation", initialLocation); - myFile.Add("player", gameObject.transform); - - myFile.AddSerialized("items", items); - - myFile.AddCustom("collider", gameObject.GetComponent(), "BoxCollider"); - - // Test - - if (myFile.TestDataSaveLoad()) - { - Debug.Log("GOOD!\n"); - } - else - { - Debug.Log("OPS! SOMETHING WENT WRONG!\n"); - } - - } - - } - - private void ShowData() - { - Debug.Log("Name: " + character + "\n"); - Debug.Log("Nickname: " + nickname + "\n"); - Debug.Log("Age: " + age + "\n"); - Debug.Log("Stregth: " + strenght + "\n"); - Debug.Log("Has a sword: " + has_sword + "\n"); - Debug.Log("Has a Bow: " + has_bow + "\n"); - Debug.Log("Spawn location: x = " + initialLocation.x + ", y = " + initialLocation.y + ", z = " + initialLocation.z + "\n"); - Debug.Log("GameObject position: x = " + gameObject.transform.position.x + ", y = " + gameObject.transform.position.y + ", z = " + gameObject.transform.position.z + "\n"); - Debug.Log("GameObject rotation: x = " + gameObject.transform.rotation.x + ", y = " + gameObject.transform.rotation.y + ", z = " + gameObject.transform.rotation.z + "\n"); - Debug.Log("GameObject scale: x = " + gameObject.transform.localScale.x + ", y = " + gameObject.transform.localScale.y + ", z = " + gameObject.transform.localScale.z + "\n"); - - foreach (var n in skills) Debug.Log("Skill ID: " + n + "\n"); - foreach (var item in equipment) Debug.Log("Equipment: " + item + "\n"); - foreach (KeyValuePair item in coins) Debug.Log("Coin - Type: " + item.Key + " Quantity: " + item.Value + "\n"); - foreach (var item in items) Debug.Log("Item - Name: " + item.name + " Quantity: " + item.quantity + "\n"); - } - - } -} \ No newline at end of file diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.cs.meta b/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.cs.meta deleted file mode 100644 index df78325..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5296b1f6b230a0748a634b61dc8016f3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.unity b/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.unity deleted file mode 100644 index 4fbc208..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.unity +++ /dev/null @@ -1,693 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 9 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 0 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 11 - m_GIWorkflowMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 1 - m_EnableRealtimeLightmaps: 1 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 1 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 512 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 256 - m_PVREnvironmentReferencePointCount: 2048 - m_PVRFilteringMode: 1 - m_PVRDenoiserTypeDirect: 1 - m_PVRDenoiserTypeIndirect: 1 - m_PVRDenoiserTypeAO: 1 - m_PVRFilterTypeDirect: 0 - m_PVRFilterTypeIndirect: 0 - m_PVRFilterTypeAO: 0 - m_PVREnvironmentMIS: 1 - m_PVRCulling: 1 - m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousPositionSigmaDirect: 0.5 - m_PVRFilteringAtrousPositionSigmaIndirect: 2 - m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ExportTrainingData: 0 - m_TrainingDataDestination: TrainingData - m_LightingDataAsset: {fileID: 0} - m_UseShadowmask: 1 ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 2 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - accuratePlacement: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &515071295 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 515071297} - - component: {fileID: 515071296} - - component: {fileID: 515071298} - m_Layer: 0 - m_Name: DEMO - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &515071296 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 515071295} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5296b1f6b230a0748a634b61dc8016f3, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!4 &515071297 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 515071295} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!65 &515071298 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 515071295} - m_Material: {fileID: 0} - m_IsTrigger: 1 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 1, y: 2, z: 3} ---- !u!1 &517188200 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 517188203} - - component: {fileID: 517188202} - - component: {fileID: 517188201} - m_Layer: 0 - m_Name: EventSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &517188201 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 517188200} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 ---- !u!114 &517188202 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 517188200} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 10 ---- !u!4 &517188203 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 517188200} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &566797187 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 566797188} - - component: {fileID: 566797190} - - component: {fileID: 566797189} - m_Layer: 5 - m_Name: Image - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &566797188 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 566797187} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 1993110673} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &566797189 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 566797187} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.28627452, g: 0.28627452, b: 0.28627452, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!222 &566797190 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 566797187} - m_CullTransparentMesh: 0 ---- !u!1 &975714498 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 975714500} - - component: {fileID: 975714499} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &975714499 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 975714498} - m_Enabled: 1 - serializedVersion: 9 - m_Type: 1 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &975714500 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 975714498} - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &1691826865 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1691826866} - - component: {fileID: 1691826868} - - component: {fileID: 1691826867} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1691826866 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1691826865} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 1993110673} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 15, y: -15} - m_SizeDelta: {x: -30, y: -30} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1691826867 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1691826865} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 20 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 2 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 1 - m_LineSpacing: 1 - m_Text: 'INSTRUCTIONS - - Press the keys in the given order. Look at the Console for messages. - - - 1. Press [S] : save some data. - - - 2. Press [L] : load data. - - - 3. Press [A] : append data. - - - 4. Press [L] : load data for checking appended data. - - - 5. Press [DEL] : file delete. - - - 6. Press [T] : file reading / writing test.' ---- !u!222 &1691826868 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1691826865} - m_CullTransparentMesh: 0 ---- !u!1 &1993110669 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1993110673} - - component: {fileID: 1993110672} - - component: {fileID: 1993110671} - - component: {fileID: 1993110670} - m_Layer: 5 - m_Name: Canvas - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1993110670 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1993110669} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &1993110671 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1993110669} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} - m_Name: - m_EditorClassIdentifier: - m_UiScaleMode: 1 - m_ReferencePixelsPerUnit: 100 - m_ScaleFactor: 1 - m_ReferenceResolution: {x: 800, y: 600} - m_ScreenMatchMode: 0 - m_MatchWidthOrHeight: 0 - m_PhysicalUnit: 3 - m_FallbackScreenDPI: 96 - m_DefaultSpriteDPI: 96 - m_DynamicPixelsPerUnit: 1 ---- !u!223 &1993110672 -Canvas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1993110669} - m_Enabled: 1 - serializedVersion: 3 - m_RenderMode: 0 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 0 - m_OverridePixelPerfect: 0 - m_SortingBucketNormalizedSize: 0 - m_AdditionalShaderChannelsFlag: 0 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!224 &1993110673 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1993110669} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0, y: 0, z: 0} - m_Children: - - {fileID: 566797188} - - {fileID: 1691826866} - m_Father: {fileID: 0} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 0} ---- !u!1 &2028864016 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2028864019} - - component: {fileID: 2028864018} - - component: {fileID: 2028864017} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &2028864017 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2028864016} - m_Enabled: 1 ---- !u!20 &2028864018 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2028864016} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &2028864019 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2028864016} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.unity.meta b/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.unity.meta deleted file mode 100644 index 44c9492..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/Demo/Demo.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: c724f19b6c2c7cd429daa2c2258fdfe0 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSave.cs b/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSave.cs deleted file mode 100644 index ca94d1d..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSave.cs +++ /dev/null @@ -1,1573 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization.Formatters.Binary; -using System.IO; -using UnityEngine; -using System.Xml.Serialization; -using UnityEngine.Events; -using System; -using System.Security.Cryptography; -using System.Text; -using System.IO.Compression; - -namespace TigerForge -{ - /// - /// Easy File Save v.1.2 - /// - public class EasyFileSave - { - - #region " VARIABLES & PROPERTIES " - - // The file internal storage. - private Dictionary storage = new Dictionary(); - - /// - /// The error information. - /// - public string Error = ""; - - /// - /// Disable the warning messages shown in the Console. - /// - public bool suppressWarning = true; - - // The instance file name. - private readonly string fileName = ""; - - // A custom Structure for containing all the Transform component data. - public struct UnityTransform - { - public Vector3 position; - public Quaternion rotation; - public Vector3 localScale; - public Vector3 localPosition; - public Quaternion localRotation; - public Vector3 lossyScale; - public Vector3 eulerAngles; - public Vector3 localEulerAngles; - } - - // Easy File Save Extensions management. - private EasyFileSaveExtension customs = new EasyFileSaveExtension(); - - // The Structure used by Custom data method. - public struct CustomData - { - /// - /// The raw object data. - /// - public object data; - - /// - /// Cast the object into integer value. - /// - /// - public int ToInt() - { - try - { - return (int)data; - } - catch (System.Exception) - { - return 0; - } - } - - /// - /// Cast the object into float value. - /// - /// - public float ToFloat() - { - try - { - return (float)data; - } - catch (System.Exception) - { - return 0f; - } - } - - /// - /// Cast the object into byrte value. - /// - /// - public byte ToByte() - { - try - { - return (byte)data; - } - catch (System.Exception) - { - return 0; - } - } - - /// - /// Cast the object into a string. - /// - /// - public override string ToString() - { - try - { - return (string)data; - } - catch (System.Exception) - { - return ""; - } - } - - /// - /// Cast the object into a boolean value. - /// - /// - public bool ToBool() - { - try - { - return (bool)data; - } - catch (System.Exception) - { - return false; - } - } - - } - - #endregion - - - #region " CONSTRUCTOR " - - /// - /// Initialize a new instance with the given fileName or with a default file name if it's not specified. - /// - /// - public EasyFileSave(string fileName = "") - { - // If no name is provided, 'gamedata' file name will be used. - if (fileName == "") fileName = "gamedata"; - - // Initialize the storage. - storage = new Dictionary(); - - // Initialize the file name with the right path, name and extension. - this.fileName = Application.persistentDataPath + "/" + fileName + ".dat"; - - Error = ""; - - // Keep track of all the created files so as you can delete them all. - Register(fileName); - - // Activate all the Extensions defined in 'EasyFileSaveExtension.cs'. - customs.Start(); - } - - #endregion - - - #region " SAVE, APPEND, LOAD, ADD " - - /// - /// Save the 'system internal storage' data into the file. Return TRUE when done without errors. - /// If a password is specified, the method will save an encrypted and compressed file. - /// - public bool Save(string password = "") - { - try - { - if (password == "") - { - BinaryFormatter bf = new BinaryFormatter(); - FileStream saveFile = File.Create(fileName); - bf.Serialize(saveFile, storage); - saveFile.Close(); - Dispose(); - return true; - } else - { - return SaveSecure(password); - } - } - catch (System.Exception e) - { - Error = "[Easy File Save] This system exeption has been thrown during saving: " + e.Message; - return false; - } - - } - - /// - /// Append the 'system internal storage' data at the end of the current file content. - /// By default, existing keys will be overwritten with new values. If 'overwrite' parameter is set to FALSE, existing keys will be ignored. - /// If a password is specified, the method will save an encrypted and compressed file. - /// - public bool Append(bool overwrite = true, string password = "") - { - try - { - Dictionary fileStorage = new Dictionary(); - - if (FileExists()) - { - // If the file exists, it's read and its content is mixed with the storage. - // How the current storage is joined to the existing file content depends on 'overwrite' option. - - if (password == "") - { - BinaryFormatter bf2 = new BinaryFormatter(); - FileStream openFile = File.Open(fileName, FileMode.Open); - fileStorage = (Dictionary)bf2.Deserialize(openFile); - openFile.Close(); - } else - { - var loadPassword = (password + "easyfilesavesecure1234").Substring(0, 16); - byte[] key = Encoding.UTF8.GetBytes(loadPassword); - byte[] iv = Encoding.UTF8.GetBytes(loadPassword); - using (Stream s = File.OpenRead(fileName)) - { - RijndaelManaged rm = new RijndaelManaged(); - rm.Key = key; - rm.IV = iv; - using (CryptoStream cs = new CryptoStream(s, rm.CreateDecryptor(), CryptoStreamMode.Read)) - { - using (GZipStream gs = new GZipStream(cs, CompressionMode.Decompress)) - { - BinaryFormatter bf = new BinaryFormatter(); - fileStorage = (Dictionary)bf.Deserialize(gs); - } - } - } - } - - foreach (KeyValuePair item in storage) - { - if (fileStorage.ContainsKey(item.Key)) - { - if (overwrite) fileStorage[item.Key] = item.Value; - } - else - { - fileStorage.Add(item.Key, item.Value); - } - } - - } - else - { - fileStorage = storage; - } - - if (password == "") - { - BinaryFormatter bf = new BinaryFormatter(); - FileStream saveFile = File.Create(fileName); - bf.Serialize(saveFile, fileStorage); - saveFile.Close(); - Dispose(); - } else - { - var savePassword = (password + "easyfilesavesecure1234").Substring(0, 16); - byte[] key = Encoding.UTF8.GetBytes(savePassword); - byte[] iv = Encoding.UTF8.GetBytes(savePassword); - using (Stream s = File.Create(fileName)) - { - RijndaelManaged rm = new RijndaelManaged(); - rm.Key = key; - rm.IV = iv; - using (CryptoStream cs = new CryptoStream(s, rm.CreateEncryptor(), CryptoStreamMode.Write)) - { - using (GZipStream gs = new GZipStream(cs, CompressionMode.Compress)) - { - BinaryFormatter bf = new BinaryFormatter(); - bf.Serialize(gs, fileStorage); - } - } - } - } - - - return true; - } - catch (System.Exception e) - { - Error = "[Easy File Save] This system exeption has been thrown during append data: " + e.Message; - return false; - } - - - } - - /// - /// Load the file data into the 'system internal storage' and return TRUE if the loading has been completed. Return FALSE if something has gone wrong. - /// If a password is specified, the method will load an encrypted and compressed file. - /// - /// - public bool Load(string password = "") - { - // If the file doesn't exist, the method just returns false. A warning message is written into the Error property. - if (!FileExists()) - { - Error = "[Easy File Save] The file " + fileName + " doesn't exist."; - return false; - } - - try - { - if (password == "") - { - BinaryFormatter bf = new BinaryFormatter(); - FileStream loadFile = File.Open(fileName, FileMode.Open); - storage = (Dictionary)bf.Deserialize(loadFile); - loadFile.Close(); - return true; - } else - { - return LoadSecure(password); - } - - } - catch (System.Exception e) - { - Error = "[Easy File Save] This system exeption has been thrown during loading: " + e.Message; - return false; - } - - } - - /// - /// Add a value, with the given unique key, into the 'system internal storage'. - ///
By default, if the given key already exists into the 'internal storage', the existing key value is overwritten by the new value. - ///
Set the optional 'ignoreExistingKey' parameter to true so as to prevent the reuse of an existing key. In this case, the original value won't be overwritten and a non-blocking warning will be thrown. - ///
- public void Add(string key, object value, bool ignoreExistingKey = false) - { - if (KeyExists(key)) - { - if (ignoreExistingKey) - { - Warning("[Easy File Save] Trying to reuse the key '" + key + "' to put a value into the storage!"); - } - else - { - value = ConvertUnityTypes(value); - storage[key] = value; - } - } - else - { - value = ConvertUnityTypes(value); - storage.Add(key, value); - } - } - - #endregion - - - #region " SAVE, APPEND, LOAD WITH AES " - - /// - /// Save the 'system internal storage' data into a password protected and compressed file. Return TRUE when done without errors. - /// - /// - /// - private bool SaveSecure(string password) - { - password = (password + "easyfilesavesecure1234").Substring(0, 16); - - try - { - - byte[] key = Encoding.UTF8.GetBytes(password); - byte[] iv = Encoding.UTF8.GetBytes(password); - - using (Stream s = File.Create(fileName)) - { - RijndaelManaged rm = new RijndaelManaged(); - rm.Key = key; - rm.IV = iv; - using (CryptoStream cs = new CryptoStream(s, rm.CreateEncryptor(), CryptoStreamMode.Write)) - { - using (GZipStream gs = new GZipStream(cs, CompressionMode.Compress)) - { - BinaryFormatter bf = new BinaryFormatter(); - bf.Serialize(gs, storage); - } - } - } - - Dispose(); - return true; - } - catch (System.Exception e) - { - Error = "[Easy File Save] This system exeption has been thrown during SaveSecure: " + e.Message;Debug.Log(e.Message); - return false; - } - } - - /// - /// Load a password protected and compressed file data into the 'system internal storage' and return TRUE if the loading has been completed. Return FALSE if something has gone wrong. - /// - /// - /// - private bool LoadSecure(string password) - { - password = (password + "easyfilesavesecure1234").Substring(0, 16); - - try - { - byte[] key = Encoding.UTF8.GetBytes(password); - byte[] iv = Encoding.UTF8.GetBytes(password); - - using (Stream s = File.OpenRead(fileName)) - { - RijndaelManaged rm = new RijndaelManaged(); - rm.Key = key; - rm.IV = iv; - using (CryptoStream cs = new CryptoStream(s, rm.CreateDecryptor(), CryptoStreamMode.Read)) - { - using (GZipStream gs = new GZipStream(cs, CompressionMode.Decompress)) - { - BinaryFormatter bf = new BinaryFormatter(); - storage = (Dictionary)bf.Deserialize(gs); - } - } - } - - return true; - } - catch (System.Exception e) - { - Error = "[Easy File Save] This system exeption has been thrown during LoadSecure: " + e.Message; Debug.Log(e.Message); - return false; - } - } - - #endregion - - - #region " UTILITY METHODS " - - /// - /// Return TRUE if the file exists. - /// - /// - public bool FileExists() - { - return File.Exists(fileName); - } - - /// - /// Save a backup copy of this file. - /// - public void BackupSave() - { - if (File.Exists(fileName)) - { - var backupFile = fileName + ".backup"; - File.Copy(fileName, backupFile); - } - } - - /// - /// Restore a previously saved backup copy. Restoring process makes the backup copy the current file. - /// - public void BackupRestore() - { - Delete(); - var backupFile = fileName + ".backup"; - File.Copy(backupFile, fileName); - } - - /// - /// Delete the backup file if it exists. - /// - public void BackupDelete() - { - var backupFile = fileName + ".backup"; - if (File.Exists(backupFile)) File.Delete(backupFile); - } - - /// - /// Delete this file (if it exists). - /// - public void Delete() - { - if (FileExists()) - { - File.Delete(fileName); - Dispose(); - } - } - - /// - /// Return TRUE if the 'system internal storage' contains the given key. - /// - /// - /// - public bool KeyExists(string key) - { - return storage.ContainsKey(key); - } - - /// - /// Remove the given key (and the associated value) from the 'system internal storage'. - /// - /// - public void KeyRemove(string key) - { - if (storage.ContainsKey(key)) storage.Remove(key); - } - - /// - /// Return the system internal storage. - /// - /// - public Dictionary GetStorage() - { - return storage; - } - - /// - /// Return the current file name with path. - /// - /// - public string GetFileName() - { - return fileName; - } - - /// - /// Delete the 'system internal storage' so to free this part of memory. This method is automatically called after saving. It should be manually called after loading data. - /// - public void Dispose() - { - storage = new Dictionary(); - Error = ""; - } - - /// - /// Perform a test of data saving and loading, so as to verifiy if the provided data is correctly managed. Return true if the test is passed. The test results are shown on Console panel. - /// - /// - public bool TestDataSaveLoad() - { - Debug.Log("==== [Easy File Save] ==== TESTING SAVE AND LOAD DATA ==============================================\n"); - - if (Save()) - { - Debug.Log("[Easy File Save] >> TEST #1 PASSED: data has been saved!\n"); - - if (Load()) - { - Debug.Log("[Easy File Save] >> TEST #2 PASSED: data has been loaded!\n"); - Debug.Log("====================================================================================\n"); - return true; - } - else - { - Debug.Log("[Easy File Save] >> TEST #2 NOT PASSED: there is a problem loading data!\n"); - Debug.Log(Error); - } - - } - else - { - Debug.Log("[Easy File Save] >> TEST #1 NOT PASSED: there is a problem saving data!\n"); - Debug.Log(Error); - } - - Debug.Log("====================================================================================\n"); - - return false; - - } - - #endregion - - - #region " GETTERS (DEFAULT DATA-TYPES) " - - /// - /// Return the object data for the given key (or the defined defaultValue if nothing found). - ///
Note that this method returns an 'object' that should be manually converted in the proper data-type. - ///
- /// - /// - public object GetData(string key, object defaultValue = null) - { - try - { - if (storage.ContainsKey(key)) return storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetData error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the integer data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public int GetInt(string key, int defaultValue = 0) - { - try - { - if (storage.ContainsKey(key)) return (int)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetInt error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the boolean data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public bool GetBool(string key, bool defaultValue = false) - { - try - { - if (storage.ContainsKey(key)) return (bool)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetBool error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the float data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public float GetFloat(string key, float defaultValue = 0f) - { - try - { - if (storage.ContainsKey(key)) return (float)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetFloat error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the string data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public string GetString(string key, string defaultValue = "") - { - try - { - if (storage.ContainsKey(key)) return (string)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetString error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the byte data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public byte GetByte(string key, byte defaultValue = 0) - { - try - { - if (storage.ContainsKey(key)) return (byte)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetByte error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the char data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public char GetChar(string key, char defaultValue = ' ') - { - try - { - if (storage.ContainsKey(key)) return (char)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetChar error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the long data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public long GetLong(string key, long defaultValue = 0) - { - try - { - if (storage.ContainsKey(key)) return (long)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetLong error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the short data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public short GetShort(string key, short defaultValue = 0) - { - try - { - if (storage.ContainsKey(key)) return (short)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetShort error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the uint data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public uint GetUint(string key, uint defaultValue = 0) - { - try - { - if (storage.ContainsKey(key)) return (uint)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUint error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the ulong data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public ulong GetUlong(string key, ulong defaultValue = 0) - { - try - { - if (storage.ContainsKey(key)) return (ulong)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUlong error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the ushort data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public ushort GetUshort(string key, ushort defaultValue = 0) - { - try - { - if (storage.ContainsKey(key)) return (ushort)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUshort error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the IntPtr data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public IntPtr GetIntPtr(string key, IntPtr defaultValue = new IntPtr()) - { - try - { - if (storage.ContainsKey(key)) return (IntPtr)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetIntPtr error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the UIntPtr data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public UIntPtr GetUintPtr(string key, UIntPtr defaultValue = new UIntPtr()) - { - try - { - if (storage.ContainsKey(key)) return (UIntPtr)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUintPtr error using key: " + key); - return defaultValue; - } - } - - /// - /// Return the DateTime data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public DateTime GetDateTime(string key, DateTime defaultValue = new DateTime()) - { - try - { - if (storage.ContainsKey(key)) return (DateTime)storage[key]; else return defaultValue; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetDateTime error using key: " + key); - return defaultValue; - } - } - - /// - /// Return an array of the specified data-type for the given key (or an empty array if nothing found). - /// - /// - /// - /// - public T[] GetArray(string key) - { - try - { - if (storage.ContainsKey(key)) return (T[]) storage[key]; else return Array.Empty(); - } - catch (System.Exception) - { - Warning("[Easy File Save] GetArray error using key: " + key); - return Array.Empty(); - } - } - - /// - /// Return a list of the specified data-type for the given key (or an empty list if nothing found). - /// - /// - /// - /// - public List GetList(string key) - { - try - { - if (storage.ContainsKey(key)) return (List)storage[key]; else return new List(); - } - catch (System.Exception) - { - Warning("[Easy File Save] GetList error using key: " + key); - return new List(); - } - } - - /// - /// Return a dictionary of the specified data-types for the given key (or an empty dictionary if nothing found). - /// - /// - /// - /// - /// - public Dictionary GetDictionary(string key) - { - try - { - if (storage.ContainsKey(key)) return (Dictionary)storage[key]; else return new Dictionary(); - } - catch (System.Exception) - { - Warning("[Easy File Save] GetDictionary error using key: " + key); - return new Dictionary(); - } - } - - #endregion - - - #region " SPECIAL TYPES (SETTERS & GETTERS) " - - /// - /// Serialize an object and add it, with the given unique key, into the 'system internal storage'. - /// - /// - /// - public void AddSerialized(string key, object data, bool ignoreExistingKey = false) - { - var xml = Serialize(data); - Add(key, xml, ignoreExistingKey); - } - - /// - /// Return the object data, for the given key, deserialized with the given type (or null if nothing found). - /// - /// - /// - /// - public object GetDeserialized(string key, System.Type type) - { - try - { - var obj = GetData(key); - if (obj != null) return Deserialize(obj, type); else return null; - } - catch (System.Exception) - { - Warning("[Easy File Save] GetDeserializedObject error using key: " + key); - return null; - } - } - - /// - /// Add a new custom value, with the given unique key, into the 'system internal storage'. - /// - public void AddCustom(string key, object data, string extensionName, bool ignoreExistingKey = false) - { - if (!customs.extensions.ContainsKey(extensionName)) - { - Debug.LogWarning("[Easy File Save] AddCustom: an extension with name '" + extensionName + "doesn't exist."); - return; - } - - UnityAction myExtension = customs.extensions[extensionName]; - customs.data[extensionName] = data; - myExtension.Invoke(); - - List dataToSave = customs.pars[extensionName]; - Add(key, dataToSave, ignoreExistingKey); - } - - /// - /// Return a dictionary of custom values. - /// - public Dictionary GetCustom(string key, string extensionName) - { - try - { - - if (storage.ContainsKey(key)) { - - if (!customs.mapping.ContainsKey(extensionName)) - { - Debug.LogWarning("[Easy File Save] GetCustom: an extension with name '" + extensionName + "' doesn't exist."); - return null; - } - - if (!storage.ContainsKey(key)) - { - Debug.LogWarning("[Easy File Save] GetCustom: the key '" + key + "' doesn't exist in the Storage."); - return null; - } - - List dataToLoad = (List)storage[key]; - List mapping = customs.mapping[extensionName]; - - if (mapping == null) - { - Debug.LogWarning("[Easy File Save] GetCustom: the extension '" + extensionName + "' has no mapping."); - return null; - } - - if (dataToLoad.Count != mapping.Count) - { - Debug.LogWarning("[Easy File Save] GetCustom: check your extension! Something gone wrong."); - return null; - } - - Dictionary customData = new Dictionary(); - for (var i = 0; i < mapping.Count; i++) - { - customData.Add(mapping[i], new CustomData { data = dataToLoad[i] }); - } - - return customData; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetCustom error using key: " + key); - } - return null; - } - - /// - /// Convert an object in bytes and add it, with the given unique key, into the 'system internal storage'. - /// - /// - /// - public void AddBinary(string key, object data, bool ignoreExistingKey = false) - { - MemoryStream stream = new MemoryStream(); - BinaryFormatter formatter = new BinaryFormatter(); - formatter.Serialize(stream, data); - var arrayData = stream.ToArray(); - - Add(key, arrayData, ignoreExistingKey); - } - - /// - /// Return the object data for the given key. The object must be properly converted (cast) to the original data structure. - /// - /// - /// - public object GetBinary(string key) - { - try - { - if (storage.ContainsKey(key)) - { - BinaryFormatter formatter = new BinaryFormatter(); - MemoryStream stream = new MemoryStream((byte[])storage[key]); - var obj = formatter.Deserialize(stream); - return obj; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetBinary error using key: " + key); - } - return null; - } - - #endregion - - - #region " UNITY TYPES (SETTERS & GETTERS) " - - /// - /// Return the Vector2 data for the given key (or the defined defaultValue if nothing found). - /// - /// - /// - public Vector2 GetUnityVector2(string key, Vector2 defaultValue = new Vector2()) - { - try - { - if (storage.ContainsKey(key)) - { - List dataList = (List)storage[key]; - Vector2 newData = new Vector2(dataList[0], dataList[1]); - return newData; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUnityVector2 error using key: " + key); - } - return defaultValue; - } - - /// - /// Return the Vector3 data for the given key (or the defined defaultValue if nothing found). - /// - public Vector3 GetUnityVector3(string key, Vector3 defaultValue = new Vector3()) - { - try - { - if (storage.ContainsKey(key)) - { - List dataList = (List)storage[key]; - Vector3 newData = new Vector3(dataList[0], dataList[1], dataList[2]); - return newData; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUnityVector3 error using key: " + key); - } - return defaultValue; - } - - /// - /// Return the Vector4 data for the given key (or the defined defaultValue if nothing found). - /// - public Vector4 GetUnityVector4(string key, Vector4 defaultValue = new Vector4()) - { - try - { - if (storage.ContainsKey(key)) - { - List dataList = (List)storage[key]; - Vector4 newData = new Vector4(dataList[0], dataList[1], dataList[2], dataList[3]); - return newData; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUnityVector4 error using key: " + key); - } - return defaultValue; - } - - /// - /// Return the Quaternion data for the given key (or the defined defaultValue if nothing found). - /// - public Quaternion GetUnityQuaternion(string key, Quaternion defaultValue = new Quaternion()) - { - try - { - if (storage.ContainsKey(key)) - { - List dataList = (List)storage[key]; - Quaternion newData = new Quaternion(dataList[0], dataList[1], dataList[2], dataList[3]); - return newData; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUnityQuaternion error using key: " + key); - } - return defaultValue; - } - - /// - /// Return the Quaternion data for the given key (or the defined defaultValue if nothing found). - /// - public UnityTransform GetUnityTransform(string key, UnityTransform defaultValue = new UnityTransform()) - { - var tr = new UnityTransform(); - - try - { - if (storage.ContainsKey(key)) - { - List dataList = (List)storage[key]; - tr.position.x = dataList[0]; - tr.position.y = dataList[1]; - tr.position.z = dataList[2]; - tr.localPosition.x = dataList[3]; - tr.localPosition.y = dataList[4]; - tr.localPosition.z = dataList[5]; - tr.localScale.x = dataList[6]; - tr.localScale.y = dataList[7]; - tr.localScale.z = dataList[8]; - tr.lossyScale.x = dataList[9]; - tr.lossyScale.y = dataList[10]; - tr.lossyScale.z = dataList[11]; - tr.rotation.x = dataList[12]; - tr.rotation.y = dataList[13]; - tr.rotation.z = dataList[14]; - tr.rotation.w = dataList[15]; - tr.localRotation.x = dataList[16]; - tr.localRotation.y = dataList[17]; - tr.localRotation.z = dataList[18]; - tr.localRotation.w = dataList[19]; - tr.eulerAngles.x = dataList[20]; - tr.eulerAngles.y = dataList[21]; - tr.eulerAngles.z = dataList[22]; - tr.localEulerAngles.x = dataList[23]; - tr.localEulerAngles.y = dataList[24]; - tr.localEulerAngles.z = dataList[25]; - return tr; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUnityTransform error using key: " + key); - } - return defaultValue; - } - - /// - /// Return the Color data for the given key (or the defined defaultValue if nothing found). - /// - public Color GetUnityColor(string key, Color defaultValue = new Color()) - { - try - { - if (storage.ContainsKey(key)) - { - List dataList = (List)storage[key]; - Color newData = new Color(dataList[0], dataList[1], dataList[2], dataList[3]); - return newData; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUnityColor error using key: " + key); - } - return defaultValue; - } - - /// - /// Return the Color32 data for the given key (or the defined defaultValue if nothing found). - /// - public Color32 GetUnityColor32(string key, Color32 defaultValue = new Color32()) - { - try - { - if (storage.ContainsKey(key)) - { - List dataList = (List)storage[key]; - Color32 newData = new Color32((byte)dataList[0], (byte)dataList[1], (byte)dataList[2], (byte)dataList[3]); - return newData; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUnityColor32 error using key: " + key); - } - return defaultValue; - } - - /// - /// Return the Rect data for the given key (or the defined defaultValue if nothing found). - /// - public Rect GetUnityRect(string key, Rect defaultValue = new Rect()) - { - try - { - if (storage.ContainsKey(key)) - { - List dataList = (List)storage[key]; - Rect newData = new Rect(dataList[0], dataList[1], dataList[2], dataList[3]); - - if (dataList.Count == 18) - { - newData.center = new Vector2(dataList[4], dataList[5]); - newData.max = new Vector2(dataList[6], dataList[7]); - newData.min = new Vector2(dataList[8], dataList[9]); - newData.position = new Vector2(dataList[10], dataList[11]); - newData.size = new Vector2(dataList[12], dataList[13]); - newData.xMax = dataList[14]; - newData.xMin = dataList[15]; - newData.yMax = dataList[16]; - newData.yMin = dataList[17]; - - } - return newData; - } - } - catch (System.Exception) - { - Warning("[Easy File Save] GetUnityRect error using key: " + key); - } - return defaultValue; - } - - #endregion - - - #region " STATIC FUNCTIONS " - - private static List filesArchive = new List(); - - public static void Register(string fileName) - { - if (!filesArchive.Contains(fileName)) filesArchive.Add(fileName); - } - - /// - /// Delete all the files created by Easy File Save. - /// - public static void DeleteAll() - { - foreach (string fileName in filesArchive) - { - if (File.Exists(fileName)) File.Delete(fileName); - } - filesArchive = new List(); - } - - /// - /// Serialize the object data in the proper way and return its XML structure. - /// - /// - /// - public static string Serialize(object data) - { - System.Type st = data.GetType(); - - var sw = new StringWriter(); - XmlSerializer ser = new XmlSerializer(st); - ser.Serialize(sw, data); - string xml = sw.ToString(); - - return xml; - } - - /// - /// Deserialize the given data with the given type. - /// - /// - /// - /// - public static object Deserialize(object data, System.Type type) - { - string xml = (string)data; - - XmlSerializer ser = new XmlSerializer(type); - - object result = null; - using (TextReader reader = new StringReader(xml)) - { - result = ser.Deserialize(reader); - } - - return result; - } - - #endregion - - - #region " CONVERTERS " - - public class Converter - { - - /// - /// Cast the object into integer value. - /// - /// - public static int ToInt(object value) - { - try - { - return (int)value; - } - catch (System.Exception) - { - return 0; - } - } - - /// - /// Cast the object into float value. - /// - /// - public static float ToFloat(object value) - { - try - { - return (float)value; - } - catch (System.Exception) - { - return 0f; - } - } - - /// - /// Cast the object into a string. - /// - /// - public static string ToString(object value) - { - try - { - return (string)value; - } - catch (System.Exception) - { - return ""; - } - } - - /// - /// Cast the object into a boolean value. - /// - /// - public static bool ToBool(object value) - { - try - { - return (bool)value; - } - catch (System.Exception) - { - return false; - } - } - - } - - #endregion - - - #region " HELPERS " - - /// - /// If the give value is a Unity data-type, it's converted in a list of float values suitable to be saved in a file. - ///
If it's another kind of data-type, it's just returned as is. - ///
- /// - /// - private object ConvertUnityTypes(object value) - { - string type = value.GetType().ToString(); - if (!type.StartsWith("UnityEngine")) return value; - - List converted = new List(); - - switch (type) - { - case "UnityEngine.Vector2": - Vector2 v2Data = (Vector2)value; - converted.Add(v2Data.x); - converted.Add(v2Data.y); - - break; - - case "UnityEngine.Vector3": - Vector3 v3Data = (Vector3)value; - converted.Add(v3Data.x); - converted.Add(v3Data.y); - converted.Add(v3Data.z); - - break; - - case "UnityEngine.Vector4": - Vector4 v4Data = (Vector4)value; - converted.Add(v4Data.x); - converted.Add(v4Data.y); - converted.Add(v4Data.z); - converted.Add(v4Data.w); - - break; - - case "UnityEngine.Quaternion": - Quaternion qData = (Quaternion)value; - converted.Add(qData.x); - converted.Add(qData.y); - converted.Add(qData.z); - converted.Add(qData.w); - - break; - - case "UnityEngine.Transform": - Transform trData = (Transform)value; - converted.Add(trData.position.x); - converted.Add(trData.position.y); - converted.Add(trData.position.z); - converted.Add(trData.localPosition.x); - converted.Add(trData.localPosition.y); - converted.Add(trData.localPosition.z); - converted.Add(trData.localScale.x); - converted.Add(trData.localScale.y); - converted.Add(trData.localScale.z); - converted.Add(trData.lossyScale.x); - converted.Add(trData.lossyScale.y); - converted.Add(trData.lossyScale.z); - converted.Add(trData.rotation.x); - converted.Add(trData.rotation.y); - converted.Add(trData.rotation.z); - converted.Add(trData.rotation.w); - converted.Add(trData.localRotation.x); - converted.Add(trData.localRotation.y); - converted.Add(trData.localRotation.z); - converted.Add(trData.localRotation.w); - converted.Add(trData.eulerAngles.x); - converted.Add(trData.eulerAngles.y); - converted.Add(trData.eulerAngles.z); - converted.Add(trData.localEulerAngles.x); - converted.Add(trData.localEulerAngles.y); - converted.Add(trData.localEulerAngles.z); - - break; - - case "UnityEngine.Color": - Color clData = (Color)value; - converted.Add(clData.r); - converted.Add(clData.g); - converted.Add(clData.b); - converted.Add(clData.a); - - break; - - case "UnityEngine.Color32": - Color32 cl32Data = (Color32)value; - converted.Add(cl32Data.r); - converted.Add(cl32Data.g); - converted.Add(cl32Data.b); - converted.Add(cl32Data.a); - - break; - - case "UnityEngine.Rect": - Rect reData = (Rect)value; - converted.Add(reData.x); - converted.Add(reData.y); - converted.Add(reData.width); - converted.Add(reData.height); - - converted.Add(reData.center.x); - converted.Add(reData.center.y); - converted.Add(reData.max.x); - converted.Add(reData.max.y); - converted.Add(reData.min.x); - converted.Add(reData.min.y); - converted.Add(reData.position.x); - converted.Add(reData.position.y); - converted.Add(reData.size.x); - converted.Add(reData.size.y); - converted.Add(reData.xMax); - converted.Add(reData.xMin); - converted.Add(reData.yMax); - converted.Add(reData.yMin); - break; - - default: - break; - } - - return converted; - } - - /// - /// Show a Log Warning message in the Unity Console. User can use 'suppressWarning' property to disable this warnings. - /// - /// - private void Warning(string message) - { - if (!suppressWarning) Debug.LogWarning(message); - } - - #endregion - - } -} - - diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSave.cs.meta b/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSave.cs.meta deleted file mode 100644 index f70bda0..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSave.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: eabf4ebc67ab92740b9739e522fd27fc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSaveExtension.cs b/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSaveExtension.cs deleted file mode 100644 index c9b6852..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSaveExtension.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.Events; - -public class EasyFileSaveExtension -{ - - // ---------------------------------------- - // Add new extension inside this function. - // ---------------------------------------- - - public void Start() - { - - // AddExtension method required parameters: - // - Name of this extension - // - CallBack function to execute when this extension save data - // - An array of unique keys, where each key corresponds to each saved value - AddExtension( - "BoxCollider", - BoxColliderExtension, - new string[] { "centerX", "centerY", "centerZ", "sizeX", "sizeY", "sizeZ", "enabled", "isTrigger", "contactOffset" } - ); - - } - - // ---------------------------------------- - // Add callBack functions here. - // ---------------------------------------- - - // This extension allow Easy File Save to easily save BoxCollider data. - void BoxColliderExtension() - { - // The boxCollider object data received by the AddCustom() method. - var data = GetData("BoxCollider"); - - // Casting of the object data to BoxCollider. - BoxCollider bc = (BoxCollider)data; - - SetParameters( - "BoxCollider", - bc.center.x, - bc.center.y, - bc.center.z, - bc.size.x, - bc.size.y, - bc.size.z, - bc.enabled, - bc.isTrigger, - bc.contactOffset - ); - - } - - - - - - - - - - - - - - - // ****************************************************** - // DON'T MODIFY ANYTHING UNDER THIS COMMENT: - // ****************************************************** - - #region " EXTENSIONS ENGINE " - - public Dictionary extensions = new Dictionary(); - public Dictionary data = new Dictionary(); - public Dictionary> pars = new Dictionary>(); - public Dictionary> mapping = new Dictionary>(); - - /// - /// Add a new extension to the Easy File Save system - /// - private void AddExtension(string name, UnityAction callBack, string[] map) - { - if (!extensions.ContainsKey(name)) - { - extensions.Add(name, callBack); - data.Add(name, null); - pars.Add(name, null); - mapping.Add(name, new List(map)); - } - else - { - Debug.LogWarning("An extension with name '" + name + "' already exists."); - } - } - - /// - /// Get the object data sent to this callback. - /// - private object GetData(string extensionName) - { - if (data.ContainsKey(extensionName)) return data[extensionName]; else return null; - } - - /// - /// Collect the object data to save. - /// - private void SetParameters(string extensionName, params object[] parameters) - { - pars[extensionName] = new List(parameters); - } - - #endregion - -} diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSaveExtension.cs.meta b/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSaveExtension.cs.meta deleted file mode 100644 index 6f52b76..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/EasyFileSaveExtension.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3ef45ac7f06d2e74ca134ddb3d99bfbb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/Manual.html b/Assets/ThirdParty/TigerForge/EasyFileSave/Manual.html deleted file mode 100644 index 3dba13c..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/Manual.html +++ /dev/null @@ -1,1631 +0,0 @@ - - - - - - - - - - - -
-
TIGERFORGE
-
Easy File Save
-
1.1
-
- -
- -
- [[[Introduction]]] - Easy File Save is a lightweight, easy and practical way to save and load your data in a file. It has - been designed to be very easy and fast to use, but complete and powerful as well. - - {{{HOW IT WORKS}}} - Basically, everything starts with the declaration of an instance of EasyFileSave class. This instance - represents a file that can be written and read. The instance contains all the methods and functionalities - for working with data and that file. With the instantiation, you can specify a file name. The file name is - optional: if your project just needs one file only, you can omit the file name and Easy File Save will use a - default predefined name. Instead, if you plan to use more files, you must specify a file name. - - {{{SYSTEM INTERNAL STORAGE}}} - When you create an EasyFileSave instance, the internal storage is initialized. Practically, this storage - represents the file content. This means that if you want to write a file, you have to fill that storage with - data. Then, through the Save() method, the storage is transferred into a file. Similarly, when you read a - file, the whole file content is transferred into the storage, in a well-organized structure easily - accessible. - - {{{WRITING}}} - The writing process consists of transferring the internal storage into a file. This means that firstly you - have to fill the storage with the data you want to save. Filling the storage is very easy: you have just to - use the Add() method specifying the data to save and a unique id to find it later after you loaded the - file. After that, simply calling the Save() method, the file is filled with the storage content. - - - void Save() - { - -// Instance declaration. - -EasyFileSave myFile = new EasyFileSave(); - - -// Internal storage filling with some data. - -myFile.Add("name", "Conan"); - -myFile.Add("age", 30); - -myFile.Add("has_sword", true); - - -// Saving. - -myFile.Save(); - } - - - {{{READING}}} - The reading process consists of calling the Load() method, which will fill the storage with the file - content. The storage is a simple dictionary where every single value is located by the unique id used during - the writing process. Because the values are saved as object data-type, you must convert (cast) them in a - proper way to have them in their original data-type. The instance comes with various Get methods - that read and convert the values. - - - void Load() - { - -EasyFileSave myFile = new EasyFileSave(); - - -// Load() method returns true if everything is ok. - -if (myFile.Load()) - -{ - - --// Read the "name" value and return it as String. - --string character = myFile.GetString("name"); - - --// Read the "age" value and return it as Integer. - --int age = myFile.GetInt("age"); - - --// Read the "has_sword" value and return it as Boolean. - --bool has_sword = myFile.GetBool("has_sword"); - - --// Dispose() method clears the storage in order to free the memory occupied by it. - --myFile.Dispose(); - - -} - } - - - {-{{NOTE}}} - Data is always saved in binary format as to have a better writing/reading speed, smaller file size and a - higher level of data protection. - [[[]]] - - [[[CREATING AN INSTANCE]]] - The first thing to do is creating an instance of EasyFileSave class. Usually, you do it once in your Script, - for example in the variables declaration section or in a Start() function. - - {-{{DECLARATION}}} - |-||[1]EasyFileSave variable_name = new EasyFileSave()||| - |-||[2]EasyFileSave variable_name = new EasyFileSave(file_name)||| - - {{Parameter{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {file_name!string (optional)!The name of the file. If omitted, Easy File Save will use 'gamedata' - as name.} - - - - // Import TigerForge namespace for accessing to Easy File Save class. - using TigerForge; - - public class Demo : MonoBehaviour - { - - -// Declare the variable globally. - -EasyFileSave myFile; - - -void Start() - -{ - --// Initialize the EasyFileSave instance. - --myFile = new EasyFileSave(); - -} - - } - - - - // Import TigerForge namespace for accessing to Easy File Save class.xx - using TigerForge; - - public class Demo : MonoBehaviour - { - - -// Declare the variable globally. - -EasyFileSave myFile; - - -void Start() - -{ - --// Initialize the EasyFileSave instance and name the file 'my_game_data'. - --myFile = new EasyFileSave("my_game_data"); - -} - - } - - [[[]]] - - [[[writing]]] - When you declare an instance of EasyFileSave class, the system initializes also the internal storage. This - storage represents the file content. It's a dictionary you have to fill with data. When the filling - operation is completed, you have to just call the Save() method to transfer the storage data into the file. - To fill the storage you have to use the Add() method. - - {{{.ADD}}} - The Add() method adds a new, single value, to the internal storage.

- |||variable_name.Add(key, value, ignoreExistingKey = false*)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value. This key must be unique and it used, during the reading - operation, to get this value.} - {value!object!The value to save.} - {ignoreExistingKey!bool (optional)!By default, if the given key already exists into the 'internal - storage', the existing key value is overwritten by the new value.
Set the optional - 'ignoreExistingKey' parameter to true so as to prevent the reuse of an existing key. In this case, the - original value won't be overwritten and a non-blocking warning will be thrown.} -
- - The Add() method can recognize different type of values and serialize them in the proper - way: - - - in general, everything that is based on object type and can be serialized by - BinaryFormatter;
- - common data types: string, boolean, integer, float, bytes, etc.;
- - common collections: list, dictionary, ecc.;
- - common Unity data types: Vector2, Vector3, Vector4, Quaternion, Transform, Color, Color32, Rect;
- - custom Class instances and collections of this Class (through a built-in dedicated serializer - see - Writing Custom Classes paragraph for details);
- - BoxCollider (through a custom Extension - see Extension paragraph for details). - - {{{.SAVE}}} - The Save() method transfers the data collected into the internal storage into the file. This operation - concludes the writing process and clears the storage to free the memory occupied by it. This method - should be called at the end of the storage filling operation. - - |||variable_name.Save()||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - - - {{Returned Value{}Type{}Description}} - {true or false!boolean!The method returns true if the writing is completed without errors. Otherwise, it - returns false.} - - - - // It's supposed you have previously created a myFile instance. - void SaveMyData() - { - - -// Write some common data type value. - - -myFile.Add("name", "Conan"); - -myFile.Add("age", 32); - -myFile.Add("strenght", 122.5f); - -myFile.Add("has_sword", true); - - -// Write a List of strings. - - -var equipment = new List<string>(); - -equipment.Add("Hammer"); - -equipment.Add("Knife"); - -equipment.Add("Rope"); - - -myFile.Add("hero_equip", equipment); - - -// Write some Unity common type value. - - -myFile.Add("initialLocation", new Vector3(101.5f,-30.4f,22f)); - -myFile.Add("player", gameObject.transform); - - -// Save the collected data into the file and clear the storage. - -// Note that Save() method returns true (writing ok) or false (writing error). So you can use it inside an 'if' statement. - - -myFile.Save(); - - } - - - {{{.APPEND}}} - The Append() method is similar to Save(), but it adds the internal storage content at the end of the file's - existing content. If the file doesn't exist, Append() method simply works as Save() the first time. If the - file exists, this method reads the file content and then add the storage at the end of this content. By - default, if the file and the storage contain one same keys, the value of the file is overwritten with the - storage's value. You can bypass this behavior setting the method's overwrite parameter to false. In this - case, the storage's key is ignored and the file's value is preserved. - - |||[1]variable_name.Append()||| - |||[2]variable_name.Append(overwrite)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {overwrite!boolean (optional)!true (default): file values are updated with storage values if they - share the same key.
false: file values are preserved even if the storage contains same keys. } -
- - {{Returned Value{}Type{}Description}} - {true or false!boolean!The method returns true if the writing is completed without errors. Otherwise, it - returns false.} - - - - myFile.Append(); - - [[[]]] - - [[[Writing custom classes]]] - Easy File Save can save instances of custom classes and collections that use custom classes. Since the use - of custom classes often results in the creation of complex data structures, EasyFileSave uses various - methods to convert these data structures into simpler formats more suitable to be saved and loaded.| - Two techinques are implemented at the moment: XML serialization and Binary conversion. Keep in - mind that both - have pros and cons. You should check if your custom class can be converted without issues or if it's too - complex for a correct conversion. See a C# development manual to better undestand the limitations of those - methods and do some test with your data. - - {{{.ADDSERIALIZED}}} - The AddSerialized() method works exactly as the Add() method, but it convert the data through XML serialization, - so as to turn the data structure into text format. - - |||variable_name.AddSerialized(key, data)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value. This key must be unique and it used, during the reading - operation, to get this value.} - {data!object!The data to save.} - -
- - [System.Serializable] - public class XXItemXX - { - -public string name; - -public int quantity; - } - - // It's supposed you have previously created a myFile instance. - void SaveMyData() - { - - -// Create a List of Item (custom class). - - -var items = new List<XXItemXX>(); - -items.Add(new XXItemXX { name = "Gold", quantity = 15000 }); - -items.Add(new XXItemXX { name = "Darts", quantity = 24 }); - -items.Add(new XXItemXX { name = "Potions", quantity = 10 }); - - -// Add this custom List to the internal storage. - - -myFile.AddSerialized("items", items); - - -// Save the collected data into the file and clear the storage. - - -myFile.Save(); - - } - - - {{{.ADDBINARY}}} - The AddBinary() method works exactly as the Add() method, but it convert the data through BinaryFormat, - so as to turn the data structure into an array of bytes. - - |||variable_name.AddBinary(key, data)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value. This key must be unique and it used, during the reading - operation, to get this value.} - {data!object!The data to save.} - -
- - [System.Serializable] - public class XXItemXX - { - -public string name; - -public int quantity; - } - - // It's supposed you have previously created a myFile instance. - void SaveMyData() - { - - -// Create a List of Item (custom class). - - -var items = new List<XXItemXX>(); - -items.Add(new XXItemXX { name = "Gold", quantity = 15000 }); - -items.Add(new XXItemXX { name = "Darts", quantity = 24 }); - -items.Add(new XXItemXX { name = "Potions", quantity = 10 }); - - -// Add this custom List to the internal storage. - - -myFile.AddBinary("items", items); - - -// Save the collected data into the file and clear the storage. - - -myFile.Save(); - - } - - [[[]]] - - [[[Reading]]] - When you declare an instance of EasyFileSave class, the system initializes also the internal storage. This - storage represents the file content. This means that the reading operation will fill this storage with its - content. As a result, you will have the internal storage with all the file values identified by their unique - ids (the keys you used in the Add() method for writing data). Because the Add() method adds data as a - generic - type, when you read a value it's just an object and you have to convert (cast) it in the proper data - type. - You can get the object value and then manually convert it or you can use one of the built-in Get methods - that convert the values in the most common types. - - {{{.LOAD}}} - The Load() method fills the internal storage with the file content. It must be called before to start - reading the values. It returns true when loading and storage filling is completed, so it must be used in - an - 'if' statement in order to avoid get value issues. - - |||variable_name.Load()||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - - - {{Value{}Type{}Description}} - {true or false!boolean!The method returns true when the reading process is completed without errors and - the internal storage is filled with all the file data. Otherwise, it returns false.} - - - {{{.GET* METHODS}}} - The methods that can read the storage values have the name starting with Get. Basically, the name of the - method specifies which type of data it will get. - - |||variable_name.GetData(key)||| - |||variable_name.GetString(key)||| - |||variable_name.GetBool(key)||| - |||variable_name.GetInt(key)||| - |||variable_name.GetFloat(key)||| - |||variable_name.GetByte(key)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value.} - - - {{Method{}Type{}Description}} - {GetData!object!The value as object.} - {GetString!string!The value as string.} - {GetBool!bool!The value as boolean.} - {GetInt!int!The value as integer.} - {GetFloat!float!The value as float.} - {GetByte!byte!The value as byte.} - - - {{{.GETUNITY* METHODS}}} - These methods get values that are Unity data types. - - |||variable_name.GetUnityVector2(key)||| - |||variable_name.GetUnityVector3(key)||| - |||variable_name.GetUnityVector4(key)||| - |||variable_name.GetUnityQuaternion(key)||| - |||variable_name.GetUnityColor(key)||| - |||variable_name.GetUnityColor32(key)||| - |||variable_name.GetUnityRect(key)||| - |||variable_name.GetUnityTransform(key)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value.} - - - {{Method{}Type{}Description}} - {GetUnityVector2!Vector2!The value as Vector2.} - {GetUnityVector3!Vector3!The value as Vector3.} - {GetUnityVector4!Vector4!The value as Vector4.} - {GetUnityQuaternion!Quaternion!The value as Quaternion.} - {GetUnityColor!Color!The value as Color.} - {GetUnityColor32!Color32!The value as Color32.} - {GetUnityRect!Rect!The value as Rect.} - {GetUnityTransform!Custom object!The Unity transform type contains various Vector3 and Quaternion - values. For this reason, this method gets a custom structure where all these parameters are well - organized. This structure contains the following parameters:
- - (Vector3) position;
- - (Quaternion) rotation;
- - (Vector3) localScale;
- - (Vector3) localPosition;
- - (Quaternion) localRotation;
- - (Vector3) lossyScale;
- - (Vector3) eulerAngles;
- - (Vector3) localEulerAngles;} -
- - {{{.DISPOSE}}} - The Dispose() method manually clears the internal storage, in order to free the memory occupied by it. Even - if it's not mandatory, it's recommended to call Dispose() at the end of the reading operations. Note that - this method is automatically called by the Save() method. - - |||variable_name.Dispose()||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - - - - // It's supposed you have previously created a myFile instance. - void LoadMyData() - { - - -// The Load() method returns true when the storage is filled and ready. - -if (myFile.Load()) - -{ - - --// Use the various Get methods to read each value properly converted. - - --var character = myFile.GetString("name"); - --var age = myFile.GetInt("age"); - --var strenght = myFile.GetFloat("strenght"); - --var has_sword = myFile.GetBool("has_sword"); - - --// Use the various GetUnity methods to read values that are Unity types. - - --var initialLocation = myFile.GetUnityVectorTRE("initialLocation"); - - --// GetUnityTransform() returns a custom object, so it requires a variable. - - --var tr = myFile.GetUnityTransform("player"); - --gameObject.transform.position = tr.position; - --gameObject.transform.rotation = tr.rotation; - --gameObject.transform.localScale = tr.localScale; - - --// Now that all the data has been read, you can call Dispose() to free the memory. - - --myFile.Dispose(); - - -{ - - } - - [[[]]] - - [[[Reading custom classes]]] - Easy File Save can load instances of custom classes and collections that use custom classes. - The methods to be used to read data depend on the system chosen when writing. - - {{{.GETDESERIALISED}}} - The GetDeserialized() method convert the XML data structure into the custom data structure. - - |||variable_name.GetDeserialized(key, type)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value.} - {type!System.Type!The type that must be used for deserialization.} - - - {{Value{}Type{}Description}} - {read data!object!The data as object. It must be manually converted in the proper way (cast).} - - - - [System.Serializable] - public class XXItemXX - { - -public string name; - -public int quantity; - } - - // It's supposed you have previously created a myFile instance. - void LoadMyData() - { - - -// The Load() method returns true when the storage is filled and ready. - -if (myFile.Load()) - -{ - - --// Because the saved data was a List of Item, - --// GetDeserialized() method requires this type as parameter (using typeof to obtain the System.Type). - --// The method returns an object, so it must be manually converted. - - --var items = (List<XXItemXX>)myFile.GetDeserialized("items", typeof(List<XXItemXX>)); - - --// Now that all the data has been read, you can call Dispose() to free the memory. - - --myFile.Dispose(); - - -{ - - } - - - {{{.GETBINARY}}} - The GetBinary() method convert the bytes array data structure into the custom data structure. - - |||variable_name.GetDeserialized(key)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value.} - - - {{Value{}Type{}Description}} - {read data!object!The data as object. It must be manually converted in the proper way (cast).} - - - - [System.Serializable] - public class XXItemXX - { - -public string name; - -public int quantity; - } - - // It's supposed you have previously created a myFile instance. - void LoadMyData() - { - - -// The Load() method returns true when the storage is filled and ready. - -if (myFile.Load()) - -{ - - --// Because the saved data was a List of Item, - --// GetDeserialized() method requires this type as parameter (using typeof to obtain the System.Type). - --// The method returns an object, so it must be manually converted. - - --var items = (List<XXItemXX>)myFile.GetBinary("items"); - - --// Now that all the data has been read, you can call Dispose() to free the memory. - - --myFile.Dispose(); - - -{ - - } - - [[[]]] - - [[[MANAGEMENT METHODS]]] - Easy File Save comes with some methods to manage the file and the system. - - {{{FILE EXISTS}}} - Return true if the file exists (if the file is physically existing in the device storage). - - |||variable_name.FileExists()||| - - {{{DELETE}}} - Delete the file from the device storage (if it exists) and dispose the Easy File Save internal storage. - - |||variable_name.Delete()||| - - {{{KEY EXISTS}}} - Check if the internal storage contains the given key. This control can be useful to check if a certain key - exists before trying to read its value. - - |||variable_name.KeyExists(key)||| - - - // It's supposed you have previously created a myFile instance. - void LoadMyData() - { - - -// The Load() method returns true when the storage is filled and ready. - -if (myFile.Load()) - -{ - - --// Check if 'name' key exists before using the Get method. - - --string name = ""; - --if (myFile.KeyExists("name")) name = myFile.GetString("name"); - - -{ - - } - - - {{{GET FILE NAME}}} - Return the current file name assigned to the instance, with the full path. - - |||variable_name.GetFileName()||| - - {{{DELETE ALL FILES}}} - The EasyFileSave class has a static function to delete all the files currently instantiated. Use it with - caution. - - |||variable_name.DeleteAll()||| - - {{{CLASS SERIALIZATION}}} - The EasyFileSave class has a static function to serialize a custom class instance. It returns the XML - representation of the given data (object). - - |||EasyFileSave.Serialize(data)||| - - {{{CLASS DESERIALIZATION}}} - The EasyFileSave class has a static function to deserialize an XML in the user custom class instance. It - returns an object. - - |||EasyFileSave.Deserialize(data, type)||| - [[[]]] - - [[[Extensions]]] - An Extension allows you to extend what Easy File Save can save and load. With this feature, you can save - and - load data types that aren't built-in in the system, for example, Unity components or complex custom data - types. When you implement an Extension, it becomes part of the Easy File Save system and it's accessible by - all the EasyFileSave instances. - - {-{{EasyFileSaveExtension Class}}} - New Extensions must be developed inside the EasyFileSaveExtension C# script, that's placed inside the - EasyFileSave folder. This script already contains an Extension that allows to save and load - BoxColliders. - - {{{HOW TO CREATE AN EXTENSION}}} - Developing an Extension is pretty easy and it basically requires just some steps. The following instructions - will show how to implement an Extension adding the support for RigidBody Unity component as - example: - - {.{{1.}}} - Inside the Start() function, use the AddExtension() method to declare a new Extension. This - method requires a name for the Extension (a string) and the name of the callBack function (the function to - call in order to make this Extension working). - - - public void Start() - { - - -// Name of this extension and the callBack function which contains the extension configuration. - -AddExtension("BoxCollider", BoxCollider); - - -// My new Extension: support for saving and loading RigidBody. - -AddExtension("RBody", RBodyExtension); - - } - - - {.{{2.}}} - In the Script file (ideally after the Start() function) create the callBack function (for this - example RigidBodyExtension). - - - public void Start() - { - - -// Name of this extension and the callBack function which contains the extension configuration. - -AddExtension("BoxCollider", BoxCollider); - - -// My new Extension: support for saving and loading RigidBody. - -AddExtension("RBody", RBodyExtension); - - } - - // My RigidBodyExtension callback function, as declared in AddExtension() method. - void RBodyExtension() - { - - } - - - {.{{3.}}} - The callBack function is called every time you perform a writing operation. So, it must contain - the logic to collect the RigidBody data you want to save. The Extension system recognizes basic data type - only (string, bool, int, float, byte, etc.), so you must collect only RigidBody values that are of - these types and that are important for your needs. Inside this function you have just to perform 3 - operations: - - 3.1
You have to use the GetData() method to obtain the value you are going to save. GetData() method - requires the Extension name as parameter: - - - // My RigidBodyExtension callback function, as declared in AddExtension() method. - void RBodyExtension() - { - -// Use GetData, with Extension name as parameter, to get the value you are going to save. - -var data = GetData("RBody"); - } - - - 3.2
Because GetData() method returns an object, you have to convert it in the original type (in this - example, RigidBody Unity data type): - - - // My RigidBodyExtension callback function, as declared in AddExtension() method. - void RBodyExtension() - { - -// Use GetData, with Extension name as parameter, to get the value you are going to save. - -var data = GetData("RBody"); - - -// I convert the object from GetData() into a RigidBody data type. - -RigidBody rb = (RigidBody)data; - } - - - 3.3
Now that you have the RigidBody that you're going to save, you have to use the SetParameters() - method to collect the RigidBody values you want to save. This method requires the Extension name followed by - a list of parameters. Each parameter, described by the Par() object, must contain one of the RigidBody - values and a unique name that identifies it: - - - // My RigidBodyExtension callback function, as declared in AddExtension() method. - void RBodyExtension() - { - -// Use GetData, with Extension name as parameter, to get the value you are going to save. - -var data = GetData("RBody"); - - -// I convert the object from GetData() into a RigidBody data type. - -RigidBody rb = (RigidBody)data; - - -// With SerParameters() method you can choose which RigidBody values to save and load. - -// Every single value requires a name. A good practice is to use the same RigidBody property name. - -SetParameters( - --"RBody", - --new Par { name = "angularDrag", value = rb.angularDrag }, - --new Par { name = "angularVelocity", value = rb.angularVelocity }, - --new Par { name = "detectCollisions", value = rb.detectCollisions }, - --new Par { name = "freezeRotation", value = rb.freezeRotation }, - --new Par { name = "useGravity", value = rb.useGravity }, - --new Par { name = "velocity", value = rb.velocity } - -); - } - - - That's all and the new Extension for RigidBody is ready to be used. - - {{{HOW TO SAVE EXTENSION DATA}}} - Because Extension data is a custom functionality, you can't use the standard Add() method, but you must use - AddCustom() method. - - |||variable_name.AddCustom(key, data, extension_name)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value.} - {data!object!The custom data to save.} - {extension_name!string!The name of the Extension that will properly save the data.} - - - - // It's supposed you have previously created a myFile instance. - void SaveMyData() - { - - -// Add my GameObject RigidBody to the internal storage through a dedicated Extension. - - -myFile.AddCustom("player_rigid_body", gameObject.GetComponent<RigidBody>(), "RBody"); - - -// Save the collected data into the file and clear the storage. - - -myFile.Save(); - - } - - - {{{HOW TO LOAD EXTENSION DATA}}} - To get data that has been saved by an Extension you must use GetCustom() method. This method returns a - special dictionary that contains all the saved values, identified by a specific name, and methods to convert - each value in a common data type. - - |||variable_name.GetCustom(key, extension_name)||| - - {{Parameters{}Type{}Description}} - {variable_name!!The name of the EasyFileSave instance.} - {key!string!A unique id to identify the value.} - {extension_name!string!The name of the Extension that will generate the dictionary.} - - - Returned value:
- a special dictionary with the values indentified by unique keys and the following methods to convert (cast) - each value: - - - variable[key].ToString();
- - variable[key].ToBool();
- - variable[key].ToInt();
- - variable[key].ToFloat();
- - variable[key].ToByte();

- - variable[key].data (property that contains the value as object); - - - // It's supposed you have previously created a myFile instance. - void LoadMyData() - { - - -// The Load() method returns true when the storage is filled and ready. - -if (myFile.Load()) - -{ - - --// Use GetCustom to obtain the dictionary with all the saved values. - - --var rb = myFile.GetCustom("player_rigid_body", "RBody"); - - --// Use rb dictionary as needed. - - --var playerRB = gameObject.GetComponent<RigidBody>(); - - --playerRB.angularDrag = rb["angularDrag"].toFloat(); - --playerRB.angularVelocity = rb["angularVelocity"].toFloat(); - --playerRB.detectCollisions = rb["detectCollisions"].toBool(); - --playerRB.freezeRotation = rb["freezeRotation"].toBool(); - --playerRB.useGravity = rb["useGravity"].toBool(); - --playerRB.velocity = rb["velocity"].toFloat(); - - -{ - - } - - [[[]]] - - [[[WRITE / READ TEST]]] - The TestDataSaveLoad() method is a practical way to test the writing and reading operation. This method is - pretty useful to test own data structure, expecially in case you're going to manage complex data structures.| - To use this method just fill the "internal storage" with your data e call TestDataSaveLoad(). In the Unity - Console you will see the test results. - - - void MyTest() - { - - -// The data structure to test. - - -myFile.Add("name", "Conan"); - -myFile.Add("age", 32); - -myFile.Add("strenght", 122.5f); - -myFile.Add("has_sword", true); - - -var equipment = new List<string>(); - -equipment.Add("Hammer"); - -equipment.Add("Knife"); - -equipment.Add("Rope"); - - -myFile.Add("hero_equip", equipment); - - -myFile.Add("initialLocation", new Vector3(101.5f,-30.4f,22f)); - -myFile.Add("player", gameObject.transform); - - -// Test - - -myFile.TestDataSaveLoad(); - - } - - [[[]]] - -
- -
- - - - - - - - - - \ No newline at end of file diff --git a/Assets/ThirdParty/TigerForge/EasyFileSave/Manual.html.meta b/Assets/ThirdParty/TigerForge/EasyFileSave/Manual.html.meta deleted file mode 100644 index 4cf04db..0000000 --- a/Assets/ThirdParty/TigerForge/EasyFileSave/Manual.html.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 71d55db41ccbd50488de878f61bab099 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: