├── TinyGameSaveSystem ├── ProjectSettings │ ├── ProjectVersion.txt │ ├── ClusterInputManager.asset │ ├── PresetManager.asset │ ├── EditorBuildSettings.asset │ ├── XRSettings.asset │ ├── TimeManager.asset │ ├── VFXManager.asset │ ├── AudioManager.asset │ ├── TagManager.asset │ ├── UnityConnectSettings.asset │ ├── EditorSettings.asset │ ├── DynamicsManager.asset │ ├── NavMeshAreas.asset │ ├── Physics2DSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── QualitySettings.asset │ └── ProjectSettings.asset ├── Assets │ ├── Exmaple.meta │ ├── LitJson.meta │ ├── StreamingAssets │ │ ├── GameData.json.meta │ │ └── GameData.json │ ├── Tool.meta │ ├── Exmaple │ │ ├── Scenes │ │ │ ├── SampleScene.unity.meta │ │ │ └── SampleScene.unity │ │ ├── Scenes.meta │ │ ├── Scrpits.meta │ │ └── Scrpits │ │ │ ├── SaveTest.cs.meta │ │ │ └── SaveTest.cs │ ├── GameSaveSystem.meta │ ├── SingletonManager.meta │ ├── StreamingAssets.meta │ ├── LitJson │ │ ├── Lexer.cs.meta │ │ ├── Extensions.cs.meta │ │ ├── IJsonWrapper.cs.meta │ │ ├── JsonData.cs.meta │ │ ├── JsonMapper.cs.meta │ │ ├── JsonReader.cs.meta │ │ ├── JsonWriter.cs.meta │ │ ├── ParserToken.cs.meta │ │ ├── JsonException.cs.meta │ │ ├── JsonMockWrapper.cs.meta │ │ ├── UnityTypeBindings.cs.meta │ │ ├── Netstandard15Polyfill.cs.meta │ │ ├── Netstandard15Polyfill.cs │ │ ├── ParserToken.cs │ │ ├── Extensions.cs │ │ ├── IJsonWrapper.cs │ │ ├── JsonException.cs │ │ ├── JsonMockWrapper.cs │ │ ├── UnityTypeBindings.cs │ │ ├── JsonWriter.cs │ │ ├── JsonReader.cs │ │ ├── Lexer.cs │ │ └── JsonData.cs │ ├── Tool │ │ ├── ToolUtility.cs.meta │ │ └── ToolUtility.cs │ ├── GameSaveSystem │ │ ├── GameData.cs.meta │ │ ├── GameSaveSystem.cs.meta │ │ ├── GameSaveUtility.cs.meta │ │ ├── GameData.cs │ │ ├── GameSaveSystem.cs │ │ └── GameSaveUtility.cs │ └── SingletonManager │ │ ├── Singleton.cs.meta │ │ ├── SingletonManager.cs.meta │ │ ├── Singleton.cs │ │ └── SingletonManager.cs └── Packages │ ├── manifest.json │ └── packages-lock.json └── README.md /TinyGameSaveSystem/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2019.4.9f1 2 | m_EditorVersionWithRevision: 2019.4.9f1 (50fe8a171dd9) 3 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Exmaple.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 466d1c5efb9569146a4e49265e2f95ae 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24e4c2303f488684f8df33ee77435534 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/StreamingAssets/GameData.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05f20344d693f894ba4b8c585a407263 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Tool.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3797e50c70c52447831012095b156b7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Exmaple/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fc0d4010bbf28b4594072e72b8655ab 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Exmaple/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6883e394bddc1064d80f5d2cce6c03cd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Exmaple/Scrpits.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e183866db36125643bba4d2820fe49e2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/GameSaveSystem.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07881d48e89c4794e8145ce3cc91f719 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/SingletonManager.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e72074e80fd738146ac12acd64149e66 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/StreamingAssets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3c38c55a62d74544b9a5a803edf8979 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/Lexer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6ee4aa34aec6b54e89d18efe8d5a6f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/Extensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 375fea2d63470574e9d753d6935171e8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/IJsonWrapper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a217e0837c088749b629a606721fb4d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df135f702bdb16c4ea644ca96368175d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonMapper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ab543118874f8841859d5562afc4ad8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonReader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 080fd553d3da08047ab0298cbfdb2e52 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonWriter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f513552508ac234f87fbbd28be78e5c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/ParserToken.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13415f19664e8ac4eaab52d5335cbc36 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Tool/ToolUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70b73a4879e1403489e2fd06aea31e2a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Exmaple/Scrpits/SaveTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 317ff9fda69aec943a682edd795355be 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/GameSaveSystem/GameData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4150684d50d61f24baf59f9212d84757 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dffd6f51ff858946bb25cc9188dfc6e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonMockWrapper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5f89b15adfb6c14fa4c1b50113ff553 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/UnityTypeBindings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f127a589d0f45ec4bb223bb418674d84 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/GameSaveSystem/GameSaveSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9088239641f4d8e438ed2b65f4df68c7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/GameSaveSystem/GameSaveUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da6bc74b7500e2a4fb1d88f331fdf098 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/Netstandard15Polyfill.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f416728c938e684090c453d56c2678e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/SingletonManager/Singleton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f41a3dcbb3b1b654a9d53caf7651f093 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/SingletonManager/SingletonManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a4fd95ecce575c41acae15b1a291385 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/Netstandard15Polyfill.cs: -------------------------------------------------------------------------------- 1 | #if NETSTANDARD1_5 2 | using System; 3 | using System.Reflection; 4 | namespace LitJson 5 | { 6 | internal static class Netstandard15Polyfill 7 | { 8 | internal static Type GetInterface(this Type type, string name) 9 | { 10 | return type.GetTypeInfo().GetInterface(name); 11 | } 12 | 13 | internal static bool IsClass(this Type type) 14 | { 15 | return type.GetTypeInfo().IsClass; 16 | } 17 | 18 | internal static bool IsEnum(this Type type) 19 | { 20 | return type.GetTypeInfo().IsEnum; 21 | } 22 | } 23 | } 24 | #endif -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/SingletonManager/Singleton.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | [RequireComponent(typeof(SingletonManager))] 4 | public class Singleton : MonoBehaviour where T : Singleton 5 | { 6 | private static T _instance; 7 | 8 | public static T GetInstance() 9 | { 10 | return _instance; 11 | } 12 | 13 | public void SetInstance(T t) 14 | { 15 | if (_instance == null) 16 | { 17 | _instance = t; 18 | } 19 | } 20 | 21 | public virtual void Init() 22 | { 23 | return; 24 | } 25 | 26 | public virtual void Release() 27 | { 28 | return; 29 | } 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/ParserToken.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * ParserToken.cs 4 | * Internal representation of the tokens used by the lexer and the parser. 5 | * 6 | * The authors disclaim copyright to this source code. For more details, see 7 | * the COPYING file included with this distribution. 8 | **/ 9 | #endregion 10 | 11 | 12 | namespace LitJson 13 | { 14 | internal enum ParserToken 15 | { 16 | // Lexer tokens (see section A.1.1. of the manual) 17 | None = System.Char.MaxValue + 1, 18 | Number, 19 | True, 20 | False, 21 | Null, 22 | CharSeq, 23 | // Single char 24 | Char, 25 | 26 | // Parser Rules (see section A.2.1 of the manual) 27 | Text, 28 | Object, 29 | ObjectPrime, 30 | Pair, 31 | PairRest, 32 | Array, 33 | ArrayPrime, 34 | Value, 35 | ValueRest, 36 | String, 37 | 38 | // End of input 39 | End, 40 | 41 | // The empty rule 42 | Epsilon 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/Extensions.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | 5 | namespace LitJson.Extensions { 6 | 7 | /// 8 | /// 拓展方法 9 | /// 10 | public static class Extensions { 11 | 12 | public static void WriteProperty(this JsonWriter w,string name,long value){ 13 | w.WritePropertyName(name); 14 | w.Write(value); 15 | } 16 | 17 | public static void WriteProperty(this JsonWriter w,string name,string value){ 18 | w.WritePropertyName(name); 19 | w.Write(value); 20 | } 21 | 22 | public static void WriteProperty(this JsonWriter w,string name,bool value){ 23 | w.WritePropertyName(name); 24 | w.Write(value); 25 | } 26 | 27 | public static void WriteProperty(this JsonWriter w,string name,double value){ 28 | w.WritePropertyName(name); 29 | w.Write(value); 30 | } 31 | 32 | } 33 | 34 | /// 35 | /// 跳过序列化的标签 36 | /// 37 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)] 38 | public sealed class JsonIgnore : Attribute 39 | { 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/StreamingAssets/GameData.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "SceneDatas" : { 4 | "SampleScene" : { 5 | "SceneName" : "SampleScene", 6 | "SaveObjects" : { 7 | "Cube" : { 8 | "Name" : "Cube", 9 | "SetValues" : { 10 | "Transform" : { 11 | "SavePos" : { 12 | "FunOpera" : "SavePos", 13 | "Value" : "\r\n{\r\n \"x\" : 0.0,\r\n \"y\" : 0.0,\r\n \"z\" : 0.0\r\n}" 14 | } 15 | } 16 | } 17 | } 18 | } 19 | } 20 | }, 21 | "GobalDatas" : { 22 | "GobalTest" : { 23 | "Name" : "GobalTest", 24 | "SetValues" : { 25 | "GobalTest" : { 26 | "GobalTestDebug" : { 27 | "FunOpera" : "GobalTestDebug", 28 | "Value" : "567" 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 0 30 | m_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TinyGameSaveSystem 2 | 基于Json序列化,为游戏提供可靠的存档系统。 3 | 4 | 只需要继承并实现指定接口,便可以存取任何你想要的组件与数值。 5 | Unity内置Mono组件或自定义Mono脚本: 6 | ```csharp 7 | public class SavePos : ISave 8 | { 9 | public string Save(Transform component) 10 | { 11 | return JsonMapper.ToJson(component.position); 12 | } 13 | 14 | public void Load(Transform component, string value) 15 | { 16 | component.position = JsonMapper.ToObject(value); 17 | } 18 | } 19 | ``` 20 | 保存 21 | ```csharp 22 | transform.SaveComponent(); 23 | ``` 24 | 读取 25 | ```csharp 26 | gameObject.LoadComponent(); 27 | ``` 28 | 29 | 30 | 全局数据,不继承Mono的脚本: 31 | ```csharp 32 | public class GobalTest 33 | { 34 | public string test; 35 | } 36 | 37 | public class GobalTestDebug : ISave 38 | { 39 | public string Save(GobalTest component) 40 | { 41 | return component.test; 42 | } 43 | 44 | public void Load(GobalTest component, string value) 45 | { 46 | component.test = value; 47 | } 48 | } 49 | ``` 50 | 保存 51 | ```csharp 52 | gobalTest.SaveGobal(); 53 | ``` 54 | 读取 55 | ```csharp 56 | gobalTest.LoadGobal(); 57 | ``` 58 | 使用的Json解析库是马三大佬魔改的LitJson,链接:https://github.com/XINCGer/LitJson4Unity 59 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Exmaple/Scrpits/SaveTest.cs: -------------------------------------------------------------------------------- 1 | using LitJson; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class GobalTest 7 | { 8 | public string test; 9 | } 10 | 11 | public class SaveTest : MonoBehaviour 12 | { 13 | GobalTest gobalTest = new GobalTest(); 14 | private void Update() 15 | { 16 | if (Input.GetKeyDown(KeyCode.A)) 17 | { 18 | transform.SaveComponent(); 19 | gobalTest.SaveGobal(); 20 | GameSaveUtility.SaveGame(); 21 | } 22 | if (Input.GetKeyDown(KeyCode.S)) 23 | { 24 | gameObject.LoadComponent(); 25 | gobalTest.LoadGobal(); 26 | } 27 | if (Input.GetKeyDown(KeyCode.D)) 28 | { 29 | gobalTest.test = "567"; 30 | } 31 | } 32 | } 33 | public class SavePos : ISave 34 | { 35 | public string Save(Transform component) 36 | { 37 | return JsonMapper.ToJson(component.position); 38 | } 39 | 40 | public void Load(Transform component, string value) 41 | { 42 | component.position = JsonMapper.ToObject(value); 43 | } 44 | } 45 | 46 | public class GobalTestDebug : ISave 47 | { 48 | public string Save(GobalTest component) 49 | { 50 | return component.test; 51 | } 52 | 53 | public void Load(GobalTest component, string value) 54 | { 55 | component.test = value; 56 | Debug.Log(component.test); 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/IJsonWrapper.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * IJsonWrapper.cs 4 | * Interface that represents a type capable of handling all kinds of JSON 5 | * data. This is mainly used when mapping objects through JsonMapper, and 6 | * it's implemented by JsonData. 7 | * 8 | * The authors disclaim copyright to this source code. For more details, see 9 | * the COPYING file included with this distribution. 10 | **/ 11 | #endregion 12 | 13 | 14 | using System.Collections; 15 | using System.Collections.Specialized; 16 | 17 | 18 | namespace LitJson 19 | { 20 | public enum JsonType 21 | { 22 | None, 23 | 24 | Object, 25 | Array, 26 | String, 27 | Int, 28 | Long, 29 | Double, 30 | Boolean 31 | } 32 | 33 | public interface IJsonWrapper : IList, IOrderedDictionary 34 | { 35 | bool IsArray { get; } 36 | bool IsBoolean { get; } 37 | bool IsDouble { get; } 38 | bool IsInt { get; } 39 | bool IsLong { get; } 40 | bool IsObject { get; } 41 | bool IsString { get; } 42 | 43 | bool GetBoolean (); 44 | double GetDouble (); 45 | int GetInt (); 46 | JsonType GetJsonType (); 47 | long GetLong (); 48 | string GetString (); 49 | 50 | void SetBoolean (bool val); 51 | void SetDouble (double val); 52 | void SetInt (int val); 53 | void SetJsonType (JsonType type); 54 | void SetLong (long val); 55 | void SetString (string val); 56 | 57 | string ToJson (); 58 | void ToJson (JsonWriter writer); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/SingletonManager/SingletonManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | public class SingletonManager : MonoBehaviour 6 | { 7 | private static GameObject RootObj { get; set; } 8 | 9 | private static List singletonReleaseList = new List(); 10 | 11 | public void Awake() 12 | { 13 | RootObj = gameObject; 14 | DontDestroyOnLoad(RootObj); 15 | InitSingletons(); 16 | } 17 | 18 | /// 19 | /// 在这里进行所有单例的销毁 20 | /// 21 | public void OnApplicationQuit() 22 | { 23 | for (int i = singletonReleaseList.Count - 1; i >= 0; i--) 24 | { 25 | singletonReleaseList[i]?.Invoke(); 26 | } 27 | } 28 | 29 | /// 30 | /// 在这里进行所有单例的初始化 31 | /// 32 | /// 33 | private void InitSingletons() 34 | { 35 | AddSingleton(); 36 | } 37 | 38 | private static T AddSingleton() where T : Singleton 39 | { 40 | if (RootObj.GetComponent() == null) 41 | { 42 | T component = RootObj.AddComponent(); 43 | component.SetInstance(component); 44 | component.Init(); 45 | singletonReleaseList.Add(delegate () { component.Release(); }); 46 | return component; 47 | } 48 | else 49 | { 50 | return RootObj.GetComponent(); 51 | } 52 | } 53 | 54 | public static T GetSingleton() where T : Singleton 55 | { 56 | T component = RootObj.GetComponent(); 57 | if (component == null) 58 | component = AddSingleton(); 59 | return component; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonException.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * JsonException.cs 4 | * Base class throwed by LitJSON when a parsing error occurs. 5 | * 6 | * The authors disclaim copyright to this source code. For more details, see 7 | * the COPYING file included with this distribution. 8 | **/ 9 | #endregion 10 | 11 | 12 | using System; 13 | 14 | 15 | namespace LitJson 16 | { 17 | public class JsonException : 18 | #if NETSTANDARD1_5 19 | Exception 20 | #else 21 | ApplicationException 22 | #endif 23 | { 24 | public JsonException () : base () 25 | { 26 | } 27 | 28 | internal JsonException (ParserToken token) : 29 | base (String.Format ( 30 | "Invalid token '{0}' in input string", token)) 31 | { 32 | } 33 | 34 | internal JsonException (ParserToken token, 35 | Exception inner_exception) : 36 | base (String.Format ( 37 | "Invalid token '{0}' in input string", token), 38 | inner_exception) 39 | { 40 | } 41 | 42 | internal JsonException (int c) : 43 | base (String.Format ( 44 | "Invalid character '{0}' in input string", (char) c)) 45 | { 46 | } 47 | 48 | internal JsonException (int c, Exception inner_exception) : 49 | base (String.Format ( 50 | "Invalid character '{0}' in input string", (char) c), 51 | inner_exception) 52 | { 53 | } 54 | 55 | 56 | public JsonException (string message) : base (message) 57 | { 58 | } 59 | 60 | public JsonException (string message, Exception inner_exception) : 61 | base (message, inner_exception) 62 | { 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": "1.2.16", 4 | "com.unity.ide.rider": "1.1.4", 5 | "com.unity.ide.vscode": "1.2.1", 6 | "com.unity.test-framework": "1.1.16", 7 | "com.unity.textmeshpro": "2.1.1", 8 | "com.unity.timeline": "1.2.16", 9 | "com.unity.ugui": "1.0.0", 10 | "com.unity.modules.ai": "1.0.0", 11 | "com.unity.modules.androidjni": "1.0.0", 12 | "com.unity.modules.animation": "1.0.0", 13 | "com.unity.modules.assetbundle": "1.0.0", 14 | "com.unity.modules.audio": "1.0.0", 15 | "com.unity.modules.cloth": "1.0.0", 16 | "com.unity.modules.director": "1.0.0", 17 | "com.unity.modules.imageconversion": "1.0.0", 18 | "com.unity.modules.imgui": "1.0.0", 19 | "com.unity.modules.jsonserialize": "1.0.0", 20 | "com.unity.modules.particlesystem": "1.0.0", 21 | "com.unity.modules.physics": "1.0.0", 22 | "com.unity.modules.physics2d": "1.0.0", 23 | "com.unity.modules.screencapture": "1.0.0", 24 | "com.unity.modules.terrain": "1.0.0", 25 | "com.unity.modules.terrainphysics": "1.0.0", 26 | "com.unity.modules.tilemap": "1.0.0", 27 | "com.unity.modules.ui": "1.0.0", 28 | "com.unity.modules.uielements": "1.0.0", 29 | "com.unity.modules.umbra": "1.0.0", 30 | "com.unity.modules.unityanalytics": "1.0.0", 31 | "com.unity.modules.unitywebrequest": "1.0.0", 32 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 33 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 34 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 35 | "com.unity.modules.unitywebrequestwww": "1.0.0", 36 | "com.unity.modules.vehicles": "1.0.0", 37 | "com.unity.modules.video": "1.0.0", 38 | "com.unity.modules.vr": "1.0.0", 39 | "com.unity.modules.wind": "1.0.0", 40 | "com.unity.modules.xr": "1.0.0" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/GameSaveSystem/GameData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | public class GameData 5 | { 6 | public Dictionary SceneDatas { get; set; } 7 | public Dictionary GobalDatas { get; set; } 8 | public GameData() 9 | { 10 | SceneDatas = new Dictionary(); 11 | GobalDatas = new Dictionary(); 12 | } 13 | } 14 | 15 | public class GobalData 16 | { 17 | public string Name { get; set; } 18 | public Dictionary> SetValues { get; set; } 19 | public GobalData() 20 | { 21 | SetValues = new Dictionary>(); 22 | } 23 | public GobalData(string name) 24 | { 25 | Name = name; 26 | SetValues = new Dictionary>(); 27 | } 28 | } 29 | 30 | public class SceneData 31 | { 32 | public string SceneName { get; set; } 33 | public Dictionary SaveObjects { get; set; } 34 | public SceneData() 35 | { 36 | SaveObjects = new Dictionary(); 37 | } 38 | 39 | public SceneData(string sceneName) 40 | { 41 | SceneName = sceneName; 42 | SaveObjects = new Dictionary(); 43 | } 44 | } 45 | 46 | public class SaveObject 47 | { 48 | public string Name { get; set; } 49 | public Dictionary> SetValues { get; set; } 50 | public SaveObject() 51 | { 52 | SetValues = new Dictionary>(); 53 | } 54 | 55 | public SaveObject(string name) 56 | { 57 | Name = name; 58 | SetValues = new Dictionary>(); 59 | } 60 | } 61 | 62 | public class SetValue 63 | { 64 | public string FunOpera { get; set; } 65 | public string Value { get; set; } 66 | } 67 | 68 | /// 69 | /// 统一赋值操作接口 70 | /// 71 | /// 你希望保存组件对象类型 72 | public interface ISave 73 | { 74 | string Save(T component); 75 | void Load(T component, string value); 76 | } -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonMockWrapper.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * JsonMockWrapper.cs 4 | * Mock object implementing IJsonWrapper, to facilitate actions like 5 | * skipping data more efficiently. 6 | * 7 | * The authors disclaim copyright to this source code. For more details, see 8 | * the COPYING file included with this distribution. 9 | **/ 10 | #endregion 11 | 12 | 13 | using System; 14 | using System.Collections; 15 | using System.Collections.Specialized; 16 | 17 | 18 | namespace LitJson 19 | { 20 | public class JsonMockWrapper : IJsonWrapper 21 | { 22 | public bool IsArray { get { return false; } } 23 | public bool IsBoolean { get { return false; } } 24 | public bool IsDouble { get { return false; } } 25 | public bool IsInt { get { return false; } } 26 | public bool IsLong { get { return false; } } 27 | public bool IsObject { get { return false; } } 28 | public bool IsString { get { return false; } } 29 | 30 | public bool GetBoolean () { return false; } 31 | public double GetDouble () { return 0.0; } 32 | public int GetInt () { return 0; } 33 | public JsonType GetJsonType () { return JsonType.None; } 34 | public long GetLong () { return 0L; } 35 | public string GetString () { return ""; } 36 | 37 | public void SetBoolean (bool val) {} 38 | public void SetDouble (double val) {} 39 | public void SetInt (int val) {} 40 | public void SetJsonType (JsonType type) {} 41 | public void SetLong (long val) {} 42 | public void SetString (string val) {} 43 | 44 | public string ToJson () { return ""; } 45 | public void ToJson (JsonWriter writer) {} 46 | 47 | 48 | bool IList.IsFixedSize { get { return true; } } 49 | bool IList.IsReadOnly { get { return true; } } 50 | 51 | object IList.this[int index] { 52 | get { return null; } 53 | set {} 54 | } 55 | 56 | int IList.Add (object value) { return 0; } 57 | void IList.Clear () {} 58 | bool IList.Contains (object value) { return false; } 59 | int IList.IndexOf (object value) { return -1; } 60 | void IList.Insert (int i, object v) {} 61 | void IList.Remove (object value) {} 62 | void IList.RemoveAt (int index) {} 63 | 64 | 65 | int ICollection.Count { get { return 0; } } 66 | bool ICollection.IsSynchronized { get { return false; } } 67 | object ICollection.SyncRoot { get { return null; } } 68 | 69 | void ICollection.CopyTo (Array array, int index) {} 70 | 71 | 72 | IEnumerator IEnumerable.GetEnumerator () { return null; } 73 | 74 | 75 | bool IDictionary.IsFixedSize { get { return true; } } 76 | bool IDictionary.IsReadOnly { get { return true; } } 77 | 78 | ICollection IDictionary.Keys { get { return null; } } 79 | ICollection IDictionary.Values { get { return null; } } 80 | 81 | object IDictionary.this[object key] { 82 | get { return null; } 83 | set {} 84 | } 85 | 86 | void IDictionary.Add (object k, object v) {} 87 | void IDictionary.Clear () {} 88 | bool IDictionary.Contains (object key) { return false; } 89 | void IDictionary.Remove (object key) {} 90 | 91 | IDictionaryEnumerator IDictionary.GetEnumerator () { return null; } 92 | 93 | 94 | object IOrderedDictionary.this[int idx] { 95 | get { return null; } 96 | set {} 97 | } 98 | 99 | IDictionaryEnumerator IOrderedDictionary.GetEnumerator () { 100 | return null; 101 | } 102 | void IOrderedDictionary.Insert (int i, object k, object v) {} 103 | void IOrderedDictionary.RemoveAt (int i) {} 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/UnityTypeBindings.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | 5 | using LitJson.Extensions; 6 | 7 | namespace LitJson 8 | { 9 | 10 | #if UNITY_EDITOR 11 | [UnityEditor.InitializeOnLoad] 12 | #endif 13 | /// 14 | /// Unity内建类型拓展 15 | /// 16 | public static class UnityTypeBindings 17 | { 18 | 19 | static bool registerd; 20 | 21 | static UnityTypeBindings() 22 | { 23 | Register(); 24 | } 25 | 26 | public static void Register() 27 | { 28 | 29 | if (registerd) return; 30 | registerd = true; 31 | 32 | 33 | // 注册Type类型的Exporter 34 | JsonMapper.RegisterExporter((v, w) => 35 | { 36 | w.Write(v.FullName); 37 | }); 38 | 39 | JsonMapper.RegisterImporter((s) => 40 | { 41 | return Type.GetType(s); 42 | }); 43 | 44 | // 注册Vector2类型的Exporter 45 | Action writeVector2 = (v, w) => 46 | { 47 | w.WriteObjectStart(); 48 | w.WriteProperty("x", v.x); 49 | w.WriteProperty("y", v.y); 50 | w.WriteObjectEnd(); 51 | }; 52 | 53 | JsonMapper.RegisterExporter((v, w) => 54 | { 55 | writeVector2(v, w); 56 | }); 57 | 58 | // 注册Vector3类型的Exporter 59 | Action writeVector3 = (v, w) => 60 | { 61 | w.WriteObjectStart(); 62 | w.WriteProperty("x", v.x); 63 | w.WriteProperty("y", v.y); 64 | w.WriteProperty("z", v.z); 65 | w.WriteObjectEnd(); 66 | }; 67 | 68 | JsonMapper.RegisterExporter((v, w) => 69 | { 70 | writeVector3(v, w); 71 | }); 72 | 73 | // 注册Vector4类型的Exporter 74 | JsonMapper.RegisterExporter((v, w) => 75 | { 76 | w.WriteObjectStart(); 77 | w.WriteProperty("x", v.x); 78 | w.WriteProperty("y", v.y); 79 | w.WriteProperty("z", v.z); 80 | w.WriteProperty("w", v.w); 81 | w.WriteObjectEnd(); 82 | }); 83 | 84 | // 注册Quaternion类型的Exporter 85 | JsonMapper.RegisterExporter((v, w) => 86 | { 87 | w.WriteObjectStart(); 88 | w.WriteProperty("x", v.x); 89 | w.WriteProperty("y", v.y); 90 | w.WriteProperty("z", v.z); 91 | w.WriteProperty("w", v.w); 92 | w.WriteObjectEnd(); 93 | }); 94 | 95 | // 注册Color类型的Exporter 96 | JsonMapper.RegisterExporter((v, w) => 97 | { 98 | w.WriteObjectStart(); 99 | w.WriteProperty("r", v.r); 100 | w.WriteProperty("g", v.g); 101 | w.WriteProperty("b", v.b); 102 | w.WriteProperty("a", v.a); 103 | w.WriteObjectEnd(); 104 | }); 105 | 106 | // 注册Color32类型的Exporter 107 | JsonMapper.RegisterExporter((v, w) => 108 | { 109 | w.WriteObjectStart(); 110 | w.WriteProperty("r", v.r); 111 | w.WriteProperty("g", v.g); 112 | w.WriteProperty("b", v.b); 113 | w.WriteProperty("a", v.a); 114 | w.WriteObjectEnd(); 115 | }); 116 | 117 | // 注册Bounds类型的Exporter 118 | JsonMapper.RegisterExporter((v, w) => 119 | { 120 | w.WriteObjectStart(); 121 | 122 | w.WritePropertyName("center"); 123 | writeVector3(v.center, w); 124 | 125 | w.WritePropertyName("size"); 126 | writeVector3(v.size, w); 127 | 128 | w.WriteObjectEnd(); 129 | }); 130 | 131 | // 注册Rect类型的Exporter 132 | JsonMapper.RegisterExporter((v, w) => 133 | { 134 | w.WriteObjectStart(); 135 | w.WriteProperty("x", v.x); 136 | w.WriteProperty("y", v.y); 137 | w.WriteProperty("width", v.width); 138 | w.WriteProperty("height", v.height); 139 | w.WriteObjectEnd(); 140 | }); 141 | 142 | // 注册RectOffset类型的Exporter 143 | JsonMapper.RegisterExporter((v, w) => 144 | { 145 | w.WriteObjectStart(); 146 | w.WriteProperty("top", v.top); 147 | w.WriteProperty("left", v.left); 148 | w.WriteProperty("bottom", v.bottom); 149 | w.WriteProperty("right", v.right); 150 | w.WriteObjectEnd(); 151 | }); 152 | 153 | } 154 | 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/GameSaveSystem/GameSaveSystem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.SceneManagement; 6 | 7 | public class GameSaveSystem : Singleton 8 | { 9 | private GameData gameData; 10 | public static string[] assemblyNames = { "Assembly-CSharp" }; 11 | 12 | private static GameSaveSystem gameSaveSystem 13 | { 14 | get 15 | { 16 | return SingletonManager.GetSingleton(); 17 | } 18 | } 19 | 20 | public GameData GameData 21 | { 22 | get 23 | { 24 | if (null == gameData) 25 | gameData = ToolUtility.LoadJson("GameData"); 26 | if (null == gameData) 27 | gameData = new GameData(); 28 | return gameData; 29 | } 30 | private set 31 | { 32 | gameData = value; 33 | } 34 | } 35 | 36 | public static void SaveComponent(GameObject gameObject, T2 component, string sceneName) 37 | where T1 : ISave 38 | { 39 | if (gameObject.CheckEmpty()) 40 | return; 41 | if (component.CheckEmpty()) 42 | return; 43 | 44 | sceneName = string.IsNullOrEmpty(sceneName) == true ? SceneManager.GetActiveScene().name : sceneName; 45 | 46 | string ISaveName = typeof(T1).Name; 47 | T1 ISave = (T1)ToolUtility.CreateHelperInstance(ISaveName, assemblyNames); 48 | string value; 49 | try 50 | { 51 | value = ISave.Save(component); 52 | } 53 | catch (Exception ex) 54 | { 55 | Debug.LogError(ex); 56 | return; 57 | } 58 | SaveComponent(gameObject.name, value, sceneName); 59 | } 60 | 61 | public static void SaveComponent(string name, string value, string sceneName) 62 | where T1 : ISave 63 | { 64 | if (string.IsNullOrEmpty(name)) 65 | return; 66 | string ISaveName = typeof(T1).Name; 67 | string componentName = typeof(T2).Name; 68 | 69 | SceneData sceneData = GameSaveUtility.GetSceneData(sceneName); 70 | if (null == sceneData) 71 | GameSaveUtility.AddSceneData(sceneName); 72 | SaveObject saveObject = GameSaveUtility.GetSaveObjectData(name, sceneName); 73 | if (null == saveObject) 74 | saveObject = GameSaveUtility.AddSaveObjectData(name, sceneName); 75 | 76 | if (saveObject.SetValues.CheckEmpty()) 77 | saveObject.SetValues = new Dictionary>(); 78 | 79 | Dictionary setValues; 80 | if (saveObject.SetValues.ContainsKey(componentName)) 81 | { 82 | setValues = saveObject.SetValues[componentName]; 83 | } 84 | else 85 | { 86 | setValues = new Dictionary(); 87 | saveObject.SetValues.Add(componentName, setValues); 88 | } 89 | 90 | SetValue setValue = new SetValue 91 | { 92 | FunOpera = ISaveName, 93 | Value = value 94 | }; 95 | if (setValues.ContainsKey(ISaveName)) 96 | setValues[ISaveName] = setValue; 97 | else 98 | setValues.Add(ISaveName, setValue); 99 | } 100 | 101 | public static void SaveGobal(T2 component) 102 | where T1 : ISave 103 | { 104 | if (component.CheckEmpty()) 105 | return; 106 | 107 | ISave ISave = CreateISave(); 108 | string value; 109 | try 110 | { 111 | value = ISave.Save(component); 112 | } 113 | catch (Exception ex) 114 | { 115 | Debug.LogError(ex); 116 | return; 117 | } 118 | string componentName = typeof(T2).Name; 119 | SaveGobal(componentName, value); 120 | } 121 | 122 | public static void SaveGobal(string componentName, string value) 123 | where T1 : ISave 124 | { 125 | if (string.IsNullOrEmpty(componentName)) 126 | return; 127 | string ISaveName = typeof(T1).Name; 128 | 129 | GobalData gobalData = GameSaveUtility.GetGobalObjectData(componentName); 130 | if (null == gobalData) 131 | gobalData = GameSaveUtility.AddGobalObjectData(componentName); 132 | 133 | if (gobalData.SetValues.CheckEmpty()) 134 | gobalData.SetValues = new Dictionary>(); 135 | Dictionary setValues; 136 | if (gobalData.SetValues.ContainsKey(componentName)) 137 | { 138 | setValues = gobalData.SetValues[componentName]; 139 | } 140 | else 141 | { 142 | setValues = new Dictionary(); 143 | gobalData.SetValues.Add(componentName, setValues); 144 | } 145 | 146 | SetValue setValue = new SetValue 147 | { 148 | FunOpera = ISaveName, 149 | Value = value 150 | }; 151 | if (setValues.ContainsKey(ISaveName)) 152 | setValues[ISaveName] = setValue; 153 | else 154 | setValues.Add(ISaveName, setValue); 155 | } 156 | 157 | public static bool Load(T2 component, SetValue setValue) 158 | where T1 : ISave 159 | { 160 | if (component.CheckEmpty()) 161 | return false; 162 | if (setValue.CheckEmpty()) 163 | return false; 164 | 165 | ISave ISave = CreateISave(); 166 | try 167 | { 168 | ISave.Load(component, setValue.Value); 169 | } 170 | catch (Exception ex) 171 | { 172 | Debug.LogError(ex); 173 | return false; 174 | } 175 | return true; 176 | } 177 | 178 | public static ISave CreateISave() 179 | where T1 : ISave 180 | { 181 | string ISaveName = typeof(T1).Name; 182 | T1 ISave = (T1)ToolUtility.CreateHelperInstance(ISaveName, assemblyNames); 183 | return ISave; 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/GameSaveSystem/GameSaveUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Reflection; 5 | using UnityEngine; 6 | using UnityEngine.SceneManagement; 7 | 8 | public static class GameSaveUtility 9 | { 10 | private static GameSaveSystem gameSaveSystem 11 | { 12 | get 13 | { 14 | return SingletonManager.GetSingleton(); 15 | } 16 | } 17 | public static SceneData AddSceneData(string sceneName) 18 | { 19 | if (gameSaveSystem.GameData.SceneDatas.ContainsKey(sceneName)) 20 | { 21 | Debug.LogError(string.Format("存档已存在{0}对应的场景", sceneName)); 22 | return null; 23 | } 24 | else 25 | { 26 | SceneData sceneData = new SceneData(sceneName); 27 | gameSaveSystem.GameData.SceneDatas.Add(sceneName, sceneData); 28 | return sceneData; 29 | } 30 | } 31 | 32 | public static SceneData GetSceneData(string sceneName) 33 | { 34 | if (gameSaveSystem.GameData.SceneDatas.ContainsKey(sceneName)) 35 | { 36 | return gameSaveSystem.GameData.SceneDatas[sceneName]; 37 | } 38 | else 39 | { 40 | return null; 41 | } 42 | } 43 | 44 | public static SaveObject AddSaveObjectData(string name, string sceneName) 45 | { 46 | SceneData sceneData = GetSceneData(sceneName); 47 | if (null == sceneData) 48 | AddSceneData(sceneName); 49 | if (sceneData.SaveObjects.ContainsKey(name)) 50 | { 51 | Debug.LogError(string.Format("存档已存在{0}对应的物体", name)); 52 | return null; 53 | } 54 | else 55 | { 56 | SaveObject saveObject = new SaveObject(name); 57 | sceneData.SaveObjects.Add(name, saveObject); 58 | return saveObject; 59 | } 60 | } 61 | 62 | public static SaveObject GetSaveObjectData(string name, string sceneName = "") 63 | { 64 | sceneName = string.IsNullOrEmpty(sceneName) == true ? SceneManager.GetActiveScene().name : sceneName; 65 | SceneData sceneData = GetSceneData(sceneName); 66 | if (null == sceneData) 67 | { 68 | Debug.LogError(string.Format("存档未找到{0}对应的场景", sceneName)); 69 | return null; 70 | } 71 | if (sceneData.SaveObjects.ContainsKey(name)) 72 | return sceneData.SaveObjects[name]; 73 | else 74 | return null; 75 | } 76 | 77 | private static SetValue GetComponentSetValue(GameObject gameObject, SaveObject saveObject) 78 | where T1 : ISave 79 | { 80 | string ISaveName = typeof(T1).Name; 81 | string componentName = typeof(T2).Name; 82 | if (null == saveObject) 83 | { 84 | Debug.LogError(string.Format("存档未找到{0}对应的物体", gameObject.name)); 85 | return null; 86 | } 87 | if (false == saveObject.SetValues.ContainsKey(componentName)) 88 | { 89 | Debug.LogError(string.Format("存档未找到{0}对应的组件类型", componentName)); 90 | return null; 91 | } 92 | Dictionary setValues = saveObject.SetValues[componentName]; 93 | if (false == setValues.ContainsKey(ISaveName)) 94 | { 95 | Debug.LogError(string.Format("存档未找到{0}对应的赋值操作类型", ISaveName)); 96 | return null; 97 | } 98 | return setValues[ISaveName]; 99 | } 100 | 101 | public static GobalData AddGobalObjectData(string name) 102 | { 103 | if (gameSaveSystem.GameData.GobalDatas.ContainsKey(name)) 104 | { 105 | Debug.LogError(string.Format("存档已存在{0}对应的物体", name)); 106 | return null; 107 | } 108 | else 109 | { 110 | GobalData gobalData = new GobalData(name); 111 | gameSaveSystem.GameData.GobalDatas.Add(name, gobalData); 112 | return gobalData; 113 | } 114 | } 115 | 116 | public static GobalData GetGobalObjectData(string name) 117 | { 118 | if (gameSaveSystem.GameData.GobalDatas.ContainsKey(name)) 119 | return gameSaveSystem.GameData.GobalDatas[name]; 120 | else 121 | return null; 122 | } 123 | 124 | private static SetValue GetGobalSetValue(GobalData gobalData) 125 | where T1 : ISave 126 | { 127 | string ISaveName = typeof(T1).Name; 128 | string componentName = typeof(T2).Name; 129 | if (null == gobalData) 130 | { 131 | Debug.LogError(string.Format("存档未找到{0}全局数据", componentName)); 132 | return null; 133 | } 134 | if (false == gobalData.SetValues.ContainsKey(componentName)) 135 | { 136 | Debug.LogError(string.Format("存档未找到{0}对应的组件类型", componentName)); 137 | return null; 138 | } 139 | Dictionary setValues = gobalData.SetValues[componentName]; 140 | if (false == setValues.ContainsKey(ISaveName)) 141 | { 142 | Debug.LogError(string.Format("存档未找到{0}对应的赋值操作类型", ISaveName)); 143 | return null; 144 | } 145 | return setValues[ISaveName]; 146 | } 147 | 148 | 149 | /// 150 | /// 保存游戏数据 151 | /// 152 | public static void SaveGame() 153 | { 154 | ToolUtility.SaveJson(gameSaveSystem.GameData, "GameData"); 155 | } 156 | 157 | /// 158 | /// 保存场景对象组件,只写进内存中的存档 159 | /// 160 | /// 赋值操作对象类型。 161 | /// 你希望保存组件对象类型 162 | /// 请务必保证该类型中的泛型,是你希望保存组件对象类型 163 | /// gameObject 164 | /// 场景名,不填为当前场景 165 | public static void SaveComponent(this GameObject gameObject, string sceneName = "") 166 | where T1 : ISave 167 | { 168 | if (gameObject.CheckEmpty()) 169 | return; 170 | T2 component = gameObject.GetComponent(); 171 | if (component.CheckEmpty()) 172 | return; 173 | GameSaveSystem.SaveComponent(gameObject, component, sceneName); 174 | } 175 | 176 | public static void SaveComponent(this T2 component, string sceneName = "") 177 | where T1 : ISave 178 | where T2 : Component 179 | { 180 | if (component.CheckEmpty()) 181 | return; 182 | GameSaveSystem.SaveComponent(component.gameObject, component, sceneName); 183 | } 184 | 185 | /// 186 | /// 保存全局数据,只读当前内存中的存档 187 | /// 188 | /// 赋值操作对象类型。 189 | /// 你希望保存组件对象类型 190 | /// 请务必保证该类型中的泛型,是你希望保存组件对象类型 191 | /// 全局对象 192 | public static void SaveGobal(this T2 component) 193 | where T1 : ISave 194 | { 195 | if (component.CheckEmpty()) 196 | return; 197 | GameSaveSystem.SaveGobal(component); 198 | } 199 | 200 | /// 201 | /// 读取内存中的存档值 202 | /// 203 | /// 赋值操作对象类型。 204 | /// 你希望保存组件对象类型 205 | /// 请务必保证该类型中的泛型,是你希望保存组件对象类型 206 | /// gameObject 207 | /// 场景名,不填为当前场景 208 | /// 209 | public static bool LoadComponent(this GameObject gameObject, string sceneName = "") 210 | where T1 : ISave 211 | where T2 : Component 212 | { 213 | if (gameObject.CheckEmpty()) 214 | return false; 215 | T2 component = gameObject.GetComponent(); 216 | if (component.CheckEmpty()) 217 | return false; 218 | 219 | SaveObject saveObject = GetSaveObjectData(gameObject.name, sceneName); 220 | SetValue setValue = GetComponentSetValue(gameObject, saveObject); 221 | if (null == setValue) 222 | return false; 223 | bool result = GameSaveSystem.Load( component, setValue); 224 | return result; 225 | } 226 | 227 | /// 228 | /// 读取内存中的全局数据 229 | /// 230 | /// 赋值操作对象类型。 231 | /// 你希望保存组件对象类型 232 | /// 请务必保证该类型中的泛型,是你希望保存组件对象类型 233 | /// 全局对象 234 | /// 235 | public static bool LoadGobal(this T2 component) 236 | where T1 : ISave 237 | { 238 | if (component.CheckEmpty()) 239 | return false; 240 | string componentName = typeof(T2).Name; 241 | GobalData gobalData = GetGobalObjectData(componentName); 242 | SetValue setValue = GetGobalSetValue(gobalData); 243 | if (null == setValue) 244 | return false; 245 | bool result = GameSaveSystem.Load( component, setValue); 246 | return result; 247 | } 248 | } 249 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.collab-proxy": { 4 | "version": "1.2.16", 5 | "depth": 0, 6 | "source": "registry", 7 | "dependencies": {}, 8 | "url": "https://packages.unity.com" 9 | }, 10 | "com.unity.ext.nunit": { 11 | "version": "1.0.0", 12 | "depth": 1, 13 | "source": "registry", 14 | "dependencies": {}, 15 | "url": "https://packages.unity.com" 16 | }, 17 | "com.unity.ide.rider": { 18 | "version": "1.1.4", 19 | "depth": 0, 20 | "source": "registry", 21 | "dependencies": { 22 | "com.unity.test-framework": "1.1.1" 23 | }, 24 | "url": "https://packages.unity.com" 25 | }, 26 | "com.unity.ide.vscode": { 27 | "version": "1.2.1", 28 | "depth": 0, 29 | "source": "registry", 30 | "dependencies": {}, 31 | "url": "https://packages.unity.com" 32 | }, 33 | "com.unity.test-framework": { 34 | "version": "1.1.16", 35 | "depth": 0, 36 | "source": "registry", 37 | "dependencies": { 38 | "com.unity.ext.nunit": "1.0.0", 39 | "com.unity.modules.imgui": "1.0.0", 40 | "com.unity.modules.jsonserialize": "1.0.0" 41 | }, 42 | "url": "https://packages.unity.com" 43 | }, 44 | "com.unity.textmeshpro": { 45 | "version": "2.1.1", 46 | "depth": 0, 47 | "source": "registry", 48 | "dependencies": { 49 | "com.unity.ugui": "1.0.0" 50 | }, 51 | "url": "https://packages.unity.com" 52 | }, 53 | "com.unity.timeline": { 54 | "version": "1.2.16", 55 | "depth": 0, 56 | "source": "registry", 57 | "dependencies": {}, 58 | "url": "https://packages.unity.com" 59 | }, 60 | "com.unity.ugui": { 61 | "version": "1.0.0", 62 | "depth": 0, 63 | "source": "builtin", 64 | "dependencies": { 65 | "com.unity.modules.ui": "1.0.0", 66 | "com.unity.modules.imgui": "1.0.0" 67 | } 68 | }, 69 | "com.unity.modules.ai": { 70 | "version": "1.0.0", 71 | "depth": 0, 72 | "source": "builtin", 73 | "dependencies": {} 74 | }, 75 | "com.unity.modules.androidjni": { 76 | "version": "1.0.0", 77 | "depth": 0, 78 | "source": "builtin", 79 | "dependencies": {} 80 | }, 81 | "com.unity.modules.animation": { 82 | "version": "1.0.0", 83 | "depth": 0, 84 | "source": "builtin", 85 | "dependencies": {} 86 | }, 87 | "com.unity.modules.assetbundle": { 88 | "version": "1.0.0", 89 | "depth": 0, 90 | "source": "builtin", 91 | "dependencies": {} 92 | }, 93 | "com.unity.modules.audio": { 94 | "version": "1.0.0", 95 | "depth": 0, 96 | "source": "builtin", 97 | "dependencies": {} 98 | }, 99 | "com.unity.modules.cloth": { 100 | "version": "1.0.0", 101 | "depth": 0, 102 | "source": "builtin", 103 | "dependencies": { 104 | "com.unity.modules.physics": "1.0.0" 105 | } 106 | }, 107 | "com.unity.modules.director": { 108 | "version": "1.0.0", 109 | "depth": 0, 110 | "source": "builtin", 111 | "dependencies": { 112 | "com.unity.modules.audio": "1.0.0", 113 | "com.unity.modules.animation": "1.0.0" 114 | } 115 | }, 116 | "com.unity.modules.imageconversion": { 117 | "version": "1.0.0", 118 | "depth": 0, 119 | "source": "builtin", 120 | "dependencies": {} 121 | }, 122 | "com.unity.modules.imgui": { 123 | "version": "1.0.0", 124 | "depth": 0, 125 | "source": "builtin", 126 | "dependencies": {} 127 | }, 128 | "com.unity.modules.jsonserialize": { 129 | "version": "1.0.0", 130 | "depth": 0, 131 | "source": "builtin", 132 | "dependencies": {} 133 | }, 134 | "com.unity.modules.particlesystem": { 135 | "version": "1.0.0", 136 | "depth": 0, 137 | "source": "builtin", 138 | "dependencies": {} 139 | }, 140 | "com.unity.modules.physics": { 141 | "version": "1.0.0", 142 | "depth": 0, 143 | "source": "builtin", 144 | "dependencies": {} 145 | }, 146 | "com.unity.modules.physics2d": { 147 | "version": "1.0.0", 148 | "depth": 0, 149 | "source": "builtin", 150 | "dependencies": {} 151 | }, 152 | "com.unity.modules.screencapture": { 153 | "version": "1.0.0", 154 | "depth": 0, 155 | "source": "builtin", 156 | "dependencies": { 157 | "com.unity.modules.imageconversion": "1.0.0" 158 | } 159 | }, 160 | "com.unity.modules.subsystems": { 161 | "version": "1.0.0", 162 | "depth": 1, 163 | "source": "builtin", 164 | "dependencies": { 165 | "com.unity.modules.jsonserialize": "1.0.0" 166 | } 167 | }, 168 | "com.unity.modules.terrain": { 169 | "version": "1.0.0", 170 | "depth": 0, 171 | "source": "builtin", 172 | "dependencies": {} 173 | }, 174 | "com.unity.modules.terrainphysics": { 175 | "version": "1.0.0", 176 | "depth": 0, 177 | "source": "builtin", 178 | "dependencies": { 179 | "com.unity.modules.physics": "1.0.0", 180 | "com.unity.modules.terrain": "1.0.0" 181 | } 182 | }, 183 | "com.unity.modules.tilemap": { 184 | "version": "1.0.0", 185 | "depth": 0, 186 | "source": "builtin", 187 | "dependencies": { 188 | "com.unity.modules.physics2d": "1.0.0" 189 | } 190 | }, 191 | "com.unity.modules.ui": { 192 | "version": "1.0.0", 193 | "depth": 0, 194 | "source": "builtin", 195 | "dependencies": {} 196 | }, 197 | "com.unity.modules.uielements": { 198 | "version": "1.0.0", 199 | "depth": 0, 200 | "source": "builtin", 201 | "dependencies": { 202 | "com.unity.modules.imgui": "1.0.0", 203 | "com.unity.modules.jsonserialize": "1.0.0" 204 | } 205 | }, 206 | "com.unity.modules.umbra": { 207 | "version": "1.0.0", 208 | "depth": 0, 209 | "source": "builtin", 210 | "dependencies": {} 211 | }, 212 | "com.unity.modules.unityanalytics": { 213 | "version": "1.0.0", 214 | "depth": 0, 215 | "source": "builtin", 216 | "dependencies": { 217 | "com.unity.modules.unitywebrequest": "1.0.0", 218 | "com.unity.modules.jsonserialize": "1.0.0" 219 | } 220 | }, 221 | "com.unity.modules.unitywebrequest": { 222 | "version": "1.0.0", 223 | "depth": 0, 224 | "source": "builtin", 225 | "dependencies": {} 226 | }, 227 | "com.unity.modules.unitywebrequestassetbundle": { 228 | "version": "1.0.0", 229 | "depth": 0, 230 | "source": "builtin", 231 | "dependencies": { 232 | "com.unity.modules.assetbundle": "1.0.0", 233 | "com.unity.modules.unitywebrequest": "1.0.0" 234 | } 235 | }, 236 | "com.unity.modules.unitywebrequestaudio": { 237 | "version": "1.0.0", 238 | "depth": 0, 239 | "source": "builtin", 240 | "dependencies": { 241 | "com.unity.modules.unitywebrequest": "1.0.0", 242 | "com.unity.modules.audio": "1.0.0" 243 | } 244 | }, 245 | "com.unity.modules.unitywebrequesttexture": { 246 | "version": "1.0.0", 247 | "depth": 0, 248 | "source": "builtin", 249 | "dependencies": { 250 | "com.unity.modules.unitywebrequest": "1.0.0", 251 | "com.unity.modules.imageconversion": "1.0.0" 252 | } 253 | }, 254 | "com.unity.modules.unitywebrequestwww": { 255 | "version": "1.0.0", 256 | "depth": 0, 257 | "source": "builtin", 258 | "dependencies": { 259 | "com.unity.modules.unitywebrequest": "1.0.0", 260 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 261 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 262 | "com.unity.modules.audio": "1.0.0", 263 | "com.unity.modules.assetbundle": "1.0.0", 264 | "com.unity.modules.imageconversion": "1.0.0" 265 | } 266 | }, 267 | "com.unity.modules.vehicles": { 268 | "version": "1.0.0", 269 | "depth": 0, 270 | "source": "builtin", 271 | "dependencies": { 272 | "com.unity.modules.physics": "1.0.0" 273 | } 274 | }, 275 | "com.unity.modules.video": { 276 | "version": "1.0.0", 277 | "depth": 0, 278 | "source": "builtin", 279 | "dependencies": { 280 | "com.unity.modules.audio": "1.0.0", 281 | "com.unity.modules.ui": "1.0.0", 282 | "com.unity.modules.unitywebrequest": "1.0.0" 283 | } 284 | }, 285 | "com.unity.modules.vr": { 286 | "version": "1.0.0", 287 | "depth": 0, 288 | "source": "builtin", 289 | "dependencies": { 290 | "com.unity.modules.jsonserialize": "1.0.0", 291 | "com.unity.modules.physics": "1.0.0", 292 | "com.unity.modules.xr": "1.0.0" 293 | } 294 | }, 295 | "com.unity.modules.wind": { 296 | "version": "1.0.0", 297 | "depth": 0, 298 | "source": "builtin", 299 | "dependencies": {} 300 | }, 301 | "com.unity.modules.xr": { 302 | "version": "1.0.0", 303 | "depth": 0, 304 | "source": "builtin", 305 | "dependencies": { 306 | "com.unity.modules.physics": "1.0.0", 307 | "com.unity.modules.jsonserialize": "1.0.0", 308 | "com.unity.modules.subsystems": "1.0.0" 309 | } 310 | } 311 | } 312 | } 313 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Tool/ToolUtility.cs: -------------------------------------------------------------------------------- 1 | using LitJson; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Reflection; 7 | using UnityEditor; 8 | using UnityEngine; 9 | 10 | public static class ToolUtility 11 | { 12 | /// 13 | /// 序列化对象转为Json 14 | /// 15 | /// 16 | /// 17 | public static void SaveJson(object saveData, string path) 18 | { 19 | //ToJson接口将你的列表类传进去,,并自动转换为string类型 20 | string json = JsonMapper.ToJson(saveData); 21 | string filePath = string.Format("{0}/{1}.json", Application.streamingAssetsPath, path); 22 | //找到当前路径 23 | FileInfo file = new FileInfo(filePath); 24 | //判断有没有文件,有则打开文件,没有创建后打开文件 25 | StreamWriter sw = file.CreateText(); 26 | //将转换好的字符串存进文件, 27 | sw.WriteLine(json); 28 | //注意释放资源 29 | sw.Close(); 30 | sw.Dispose(); 31 | #if UNITY_EDITOR 32 | AssetDatabase.Refresh(); 33 | #endif 34 | } 35 | 36 | /// 37 | /// 反序列化Json转为对象 38 | /// 39 | /// 40 | /// 41 | /// 42 | public static T LoadJson(string path) 43 | { 44 | string textAsset; 45 | string filePath = string.Format("{0}/{1}.json", Application.streamingAssetsPath, path); 46 | if (!File.Exists(filePath)) 47 | return default(T); 48 | textAsset = File.ReadAllText(filePath); 49 | if (string.IsNullOrEmpty(textAsset)) 50 | return default(T); 51 | JsonData jsonData = JsonMapper.ToObject(textAsset); 52 | return JsonMapper.ToObject(jsonData.ToJson()); 53 | } 54 | 55 | /// 56 | /// 获取对应名字的子节点上的对应类型组件 57 | /// 58 | /// 59 | /// 父节点 transform 60 | /// 子节点名字 61 | /// 返回对应组件,没有找到返回null 62 | public static T GetComponetOnChildNode(this Transform transform, string nodeName) 63 | { 64 | if (null == transform) 65 | { 66 | #if UNITY_EDITOR 67 | string stackInfo = new System.Diagnostics.StackTrace(true).ToString(); 68 | Debug.LogError(string.Format("{0}获取失败,路径{1}", typeof(T).ToString(), nodeName)); 69 | #endif 70 | return default(T); 71 | } 72 | 73 | var nodeTrans = transform.Find(nodeName); 74 | if (null == nodeTrans) 75 | { 76 | #if UNITY_EDITOR 77 | string stackInfo = new System.Diagnostics.StackTrace(true).ToString(); 78 | Debug.LogError(string.Format("{0}获取失败,路径{1}", typeof(T).ToString(), nodeName)); 79 | #endif 80 | return default(T); 81 | } 82 | 83 | T result = nodeTrans.GetComponent(); 84 | if (null == result) 85 | { 86 | #if UNITY_EDITOR 87 | string stackInfo = new System.Diagnostics.StackTrace(true).ToString(); 88 | Debug.LogError(string.Format("{0}获取失败,路径{1}", typeof(T).ToString(), nodeName)); 89 | #endif 90 | return default(T); 91 | } 92 | return result; 93 | } 94 | 95 | /// 96 | /// 检查对象是否为空 97 | /// 98 | public static bool CheckEmpty(this T checkObj, int id = -1) 99 | { 100 | if (null == checkObj) 101 | { 102 | #if UNITY_EDITOR 103 | if (id == -1) 104 | { 105 | Debug.LogError(string.Format("{0}获取失败", typeof(T).ToString())); 106 | } 107 | else 108 | { 109 | Debug.LogError(string.Format("{0}获取失败,使用ID:{1}", typeof(T).ToString(), id)); 110 | } 111 | #endif 112 | return true; 113 | } 114 | else 115 | return false; 116 | } 117 | 118 | /// 119 | /// 检查数组长度 120 | /// 121 | public static bool CheckArray(this T[] item, int length) 122 | { 123 | if (item.CheckEmpty()) 124 | return false; 125 | if (item.Length < length) 126 | { 127 | #if UNITY_EDITOR 128 | Debug.LogError("需求参数长度不对啊!小老弟怎么回事啊?"); 129 | #endif 130 | return false; 131 | } 132 | 133 | else 134 | return true; 135 | } 136 | 137 | /// 138 | /// 检查二维数组长度 139 | /// 140 | public static bool CheckArrayArray(this T[][] item, int length_1, int length_2) 141 | { 142 | if (item.CheckEmpty()) 143 | return false; 144 | if (item.Length < length_1) 145 | { 146 | #if UNITY_EDITOR 147 | Debug.LogError("需求参数长度不对啊!小老弟怎么回事啊?"); 148 | #endif 149 | return false; 150 | } 151 | for (int i = 0; i < length_1; i++) 152 | { 153 | if (item[i].CheckEmpty()) 154 | { 155 | #if UNITY_EDITOR 156 | Debug.LogError("数组为空!小老弟怎么回事啊?"); 157 | #endif 158 | return false; 159 | } 160 | if (item[i].Length < length_2) 161 | { 162 | #if UNITY_EDITOR 163 | Debug.LogError("需求参数长度不对啊!小老弟怎么回事啊?"); 164 | #endif 165 | return false; 166 | } 167 | } 168 | return true; 169 | } 170 | 171 | /// 172 | /// 检查列表长度 173 | /// 174 | public static bool CheckArray(this List item, int length) 175 | { 176 | if (item.CheckEmpty()) 177 | return false; 178 | if (item.Count < length) 179 | { 180 | #if UNITY_EDITOR 181 | Debug.LogError("需求参数长度不对啊!小老弟怎么回事啊?"); 182 | #endif 183 | return false; 184 | } 185 | 186 | else 187 | return true; 188 | } 189 | 190 | /// 191 | /// 检查二维列表长度 192 | /// 193 | public static bool CheckArrayArray(this List> item, int length_1, int length_2) 194 | { 195 | if (item.CheckEmpty()) 196 | return false; 197 | if (item.Count < length_1) 198 | { 199 | #if UNITY_EDITOR 200 | Debug.LogError("需求参数长度不对啊!小老弟怎么回事啊?"); 201 | #endif 202 | return false; 203 | } 204 | for (int i = 0; i < length_1; i++) 205 | { 206 | if (item[i].CheckEmpty()) 207 | { 208 | #if UNITY_EDITOR 209 | Debug.LogError("数组为空!小老弟怎么回事啊?"); 210 | #endif 211 | return false; 212 | } 213 | if (item[i].Count < length_2) 214 | { 215 | #if UNITY_EDITOR 216 | Debug.LogError("需求参数长度不对啊!小老弟怎么回事啊?"); 217 | #endif 218 | return false; 219 | } 220 | } 221 | return true; 222 | } 223 | 224 | /// 225 | /// 获得指定子物体到父物体的路径 226 | /// 227 | /// 228 | /// 229 | /// 230 | public static string GetNamePathToParent(Transform child, Transform parent) 231 | { 232 | if (child.CheckEmpty() || parent.CheckEmpty()) 233 | return ""; 234 | 235 | string path = child.name; 236 | Transform tempParent = child.parent; 237 | while (tempParent != null) 238 | { 239 | if (tempParent == parent) 240 | return path; 241 | path = string.Format("{0}/{1}", tempParent.name, path); 242 | tempParent = tempParent.parent; 243 | } 244 | return ""; 245 | } 246 | 247 | /// 248 | /// 获得目标物体在场景下的完整路径 249 | /// 250 | /// 251 | /// 252 | public static string GetNamePathToScene(Transform transform) 253 | { 254 | if (transform.CheckEmpty()) 255 | return ""; 256 | string path = transform.name; 257 | Transform tempParent = transform.parent; 258 | if (null != tempParent) 259 | path = transform.parent.gameObject.name + "/" + path; 260 | while (null != tempParent) 261 | { 262 | if (tempParent.parent != null) 263 | { 264 | tempParent = tempParent.parent; 265 | path = tempParent.name + "/" + path; 266 | } 267 | else 268 | { 269 | break; 270 | } 271 | } 272 | return path; 273 | } 274 | 275 | /// 276 | /// 获得场景内所有对象包括不活跃的 277 | /// 278 | /// 279 | public static List GetAllSceneObjectsWithInactive() 280 | { 281 | var allTransforms = Resources.FindObjectsOfTypeAll(typeof(Transform)); 282 | var previousSelection = Selection.objects; 283 | Selection.objects = allTransforms.Cast() 284 | .Where(x => x != null) 285 | .Select(x => x.gameObject) 286 | .Cast().ToArray(); 287 | 288 | var selectedTransforms = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab); 289 | Selection.objects = previousSelection; 290 | 291 | return selectedTransforms.Select(tr => tr.gameObject).ToList(); 292 | } 293 | 294 | /// 295 | /// 反射创建实例 296 | /// 297 | public static object CreateHelperInstance(string funOperaName, string[] assemblyNames) 298 | { 299 | foreach (string assemblyName in assemblyNames) 300 | { 301 | Assembly assembly = Assembly.Load(assemblyName); 302 | 303 | object instance = assembly.CreateInstance(funOperaName); 304 | if (instance != null) 305 | { 306 | return instance; 307 | } 308 | } 309 | return null; 310 | } 311 | } 312 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/Exmaple/Scenes/SampleScene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 705507994} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 0 56 | m_LightmapEditorSettings: 57 | serializedVersion: 12 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_ExtractAmbientOcclusion: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 2 75 | m_BakeBackend: 1 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVREnvironmentSampleCount: 500 81 | m_PVREnvironmentReferencePointCount: 2048 82 | m_PVRFilteringMode: 2 83 | m_PVRDenoiserTypeDirect: 0 84 | m_PVRDenoiserTypeIndirect: 0 85 | m_PVRDenoiserTypeAO: 0 86 | m_PVRFilterTypeDirect: 0 87 | m_PVRFilterTypeIndirect: 0 88 | m_PVRFilterTypeAO: 0 89 | m_PVREnvironmentMIS: 0 90 | m_PVRCulling: 1 91 | m_PVRFilteringGaussRadiusDirect: 1 92 | m_PVRFilteringGaussRadiusIndirect: 5 93 | m_PVRFilteringGaussRadiusAO: 2 94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 96 | m_PVRFilteringAtrousPositionSigmaAO: 1 97 | m_ExportTrainingData: 0 98 | m_TrainingDataDestination: TrainingData 99 | m_LightProbeSampleCountMultiplier: 4 100 | m_LightingDataAsset: {fileID: 0} 101 | m_UseShadowmask: 1 102 | --- !u!196 &4 103 | NavMeshSettings: 104 | serializedVersion: 2 105 | m_ObjectHideFlags: 0 106 | m_BuildSettings: 107 | serializedVersion: 2 108 | agentTypeID: 0 109 | agentRadius: 0.5 110 | agentHeight: 2 111 | agentSlope: 45 112 | agentClimb: 0.4 113 | ledgeDropHeight: 0 114 | maxJumpAcrossDistance: 0 115 | minRegionArea: 2 116 | manualCellSize: 0 117 | cellSize: 0.16666667 118 | manualTileSize: 0 119 | tileSize: 256 120 | accuratePlacement: 0 121 | debug: 122 | m_Flags: 0 123 | m_NavMeshData: {fileID: 0} 124 | --- !u!1 &310720263 125 | GameObject: 126 | m_ObjectHideFlags: 0 127 | m_CorrespondingSourceObject: {fileID: 0} 128 | m_PrefabInstance: {fileID: 0} 129 | m_PrefabAsset: {fileID: 0} 130 | serializedVersion: 6 131 | m_Component: 132 | - component: {fileID: 310720265} 133 | - component: {fileID: 310720264} 134 | m_Layer: 0 135 | m_Name: SingletonManager 136 | m_TagString: Untagged 137 | m_Icon: {fileID: 0} 138 | m_NavMeshLayer: 0 139 | m_StaticEditorFlags: 0 140 | m_IsActive: 1 141 | --- !u!114 &310720264 142 | MonoBehaviour: 143 | m_ObjectHideFlags: 0 144 | m_CorrespondingSourceObject: {fileID: 0} 145 | m_PrefabInstance: {fileID: 0} 146 | m_PrefabAsset: {fileID: 0} 147 | m_GameObject: {fileID: 310720263} 148 | m_Enabled: 1 149 | m_EditorHideFlags: 0 150 | m_Script: {fileID: 11500000, guid: 0a4fd95ecce575c41acae15b1a291385, type: 3} 151 | m_Name: 152 | m_EditorClassIdentifier: 153 | --- !u!4 &310720265 154 | Transform: 155 | m_ObjectHideFlags: 0 156 | m_CorrespondingSourceObject: {fileID: 0} 157 | m_PrefabInstance: {fileID: 0} 158 | m_PrefabAsset: {fileID: 0} 159 | m_GameObject: {fileID: 310720263} 160 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 161 | m_LocalPosition: {x: 0, y: 0, z: 0} 162 | m_LocalScale: {x: 1, y: 1, z: 1} 163 | m_Children: [] 164 | m_Father: {fileID: 0} 165 | m_RootOrder: 3 166 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 167 | --- !u!1 &568569454 168 | GameObject: 169 | m_ObjectHideFlags: 0 170 | m_CorrespondingSourceObject: {fileID: 0} 171 | m_PrefabInstance: {fileID: 0} 172 | m_PrefabAsset: {fileID: 0} 173 | serializedVersion: 6 174 | m_Component: 175 | - component: {fileID: 568569459} 176 | - component: {fileID: 568569458} 177 | - component: {fileID: 568569457} 178 | - component: {fileID: 568569456} 179 | - component: {fileID: 568569455} 180 | m_Layer: 0 181 | m_Name: Cube 182 | m_TagString: Untagged 183 | m_Icon: {fileID: 0} 184 | m_NavMeshLayer: 0 185 | m_StaticEditorFlags: 0 186 | m_IsActive: 1 187 | --- !u!114 &568569455 188 | MonoBehaviour: 189 | m_ObjectHideFlags: 0 190 | m_CorrespondingSourceObject: {fileID: 0} 191 | m_PrefabInstance: {fileID: 0} 192 | m_PrefabAsset: {fileID: 0} 193 | m_GameObject: {fileID: 568569454} 194 | m_Enabled: 1 195 | m_EditorHideFlags: 0 196 | m_Script: {fileID: 11500000, guid: 317ff9fda69aec943a682edd795355be, type: 3} 197 | m_Name: 198 | m_EditorClassIdentifier: 199 | --- !u!65 &568569456 200 | BoxCollider: 201 | m_ObjectHideFlags: 0 202 | m_CorrespondingSourceObject: {fileID: 0} 203 | m_PrefabInstance: {fileID: 0} 204 | m_PrefabAsset: {fileID: 0} 205 | m_GameObject: {fileID: 568569454} 206 | m_Material: {fileID: 0} 207 | m_IsTrigger: 0 208 | m_Enabled: 1 209 | serializedVersion: 2 210 | m_Size: {x: 1, y: 1, z: 1} 211 | m_Center: {x: 0, y: 0, z: 0} 212 | --- !u!23 &568569457 213 | MeshRenderer: 214 | m_ObjectHideFlags: 0 215 | m_CorrespondingSourceObject: {fileID: 0} 216 | m_PrefabInstance: {fileID: 0} 217 | m_PrefabAsset: {fileID: 0} 218 | m_GameObject: {fileID: 568569454} 219 | m_Enabled: 1 220 | m_CastShadows: 1 221 | m_ReceiveShadows: 1 222 | m_DynamicOccludee: 1 223 | m_MotionVectors: 1 224 | m_LightProbeUsage: 1 225 | m_ReflectionProbeUsage: 1 226 | m_RayTracingMode: 2 227 | m_RenderingLayerMask: 1 228 | m_RendererPriority: 0 229 | m_Materials: 230 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 231 | m_StaticBatchInfo: 232 | firstSubMesh: 0 233 | subMeshCount: 0 234 | m_StaticBatchRoot: {fileID: 0} 235 | m_ProbeAnchor: {fileID: 0} 236 | m_LightProbeVolumeOverride: {fileID: 0} 237 | m_ScaleInLightmap: 1 238 | m_ReceiveGI: 1 239 | m_PreserveUVs: 0 240 | m_IgnoreNormalsForChartDetection: 0 241 | m_ImportantGI: 0 242 | m_StitchLightmapSeams: 1 243 | m_SelectedEditorRenderState: 3 244 | m_MinimumChartSize: 4 245 | m_AutoUVMaxDistance: 0.5 246 | m_AutoUVMaxAngle: 89 247 | m_LightmapParameters: {fileID: 0} 248 | m_SortingLayerID: 0 249 | m_SortingLayer: 0 250 | m_SortingOrder: 0 251 | --- !u!33 &568569458 252 | MeshFilter: 253 | m_ObjectHideFlags: 0 254 | m_CorrespondingSourceObject: {fileID: 0} 255 | m_PrefabInstance: {fileID: 0} 256 | m_PrefabAsset: {fileID: 0} 257 | m_GameObject: {fileID: 568569454} 258 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 259 | --- !u!4 &568569459 260 | Transform: 261 | m_ObjectHideFlags: 0 262 | m_CorrespondingSourceObject: {fileID: 0} 263 | m_PrefabInstance: {fileID: 0} 264 | m_PrefabAsset: {fileID: 0} 265 | m_GameObject: {fileID: 568569454} 266 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 267 | m_LocalPosition: {x: 0, y: 0, z: 0} 268 | m_LocalScale: {x: 1, y: 1, z: 1} 269 | m_Children: [] 270 | m_Father: {fileID: 0} 271 | m_RootOrder: 2 272 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 273 | --- !u!1 &705507993 274 | GameObject: 275 | m_ObjectHideFlags: 0 276 | m_CorrespondingSourceObject: {fileID: 0} 277 | m_PrefabInstance: {fileID: 0} 278 | m_PrefabAsset: {fileID: 0} 279 | serializedVersion: 6 280 | m_Component: 281 | - component: {fileID: 705507995} 282 | - component: {fileID: 705507994} 283 | m_Layer: 0 284 | m_Name: Directional Light 285 | m_TagString: Untagged 286 | m_Icon: {fileID: 0} 287 | m_NavMeshLayer: 0 288 | m_StaticEditorFlags: 0 289 | m_IsActive: 1 290 | --- !u!108 &705507994 291 | Light: 292 | m_ObjectHideFlags: 0 293 | m_CorrespondingSourceObject: {fileID: 0} 294 | m_PrefabInstance: {fileID: 0} 295 | m_PrefabAsset: {fileID: 0} 296 | m_GameObject: {fileID: 705507993} 297 | m_Enabled: 1 298 | serializedVersion: 10 299 | m_Type: 1 300 | m_Shape: 0 301 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 302 | m_Intensity: 1 303 | m_Range: 10 304 | m_SpotAngle: 30 305 | m_InnerSpotAngle: 21.80208 306 | m_CookieSize: 10 307 | m_Shadows: 308 | m_Type: 2 309 | m_Resolution: -1 310 | m_CustomResolution: -1 311 | m_Strength: 1 312 | m_Bias: 0.05 313 | m_NormalBias: 0.4 314 | m_NearPlane: 0.2 315 | m_CullingMatrixOverride: 316 | e00: 1 317 | e01: 0 318 | e02: 0 319 | e03: 0 320 | e10: 0 321 | e11: 1 322 | e12: 0 323 | e13: 0 324 | e20: 0 325 | e21: 0 326 | e22: 1 327 | e23: 0 328 | e30: 0 329 | e31: 0 330 | e32: 0 331 | e33: 1 332 | m_UseCullingMatrixOverride: 0 333 | m_Cookie: {fileID: 0} 334 | m_DrawHalo: 0 335 | m_Flare: {fileID: 0} 336 | m_RenderMode: 0 337 | m_CullingMask: 338 | serializedVersion: 2 339 | m_Bits: 4294967295 340 | m_RenderingLayerMask: 1 341 | m_Lightmapping: 1 342 | m_LightShadowCasterMode: 0 343 | m_AreaSize: {x: 1, y: 1} 344 | m_BounceIntensity: 1 345 | m_ColorTemperature: 6570 346 | m_UseColorTemperature: 0 347 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} 348 | m_UseBoundingSphereOverride: 0 349 | m_ShadowRadius: 0 350 | m_ShadowAngle: 0 351 | --- !u!4 &705507995 352 | Transform: 353 | m_ObjectHideFlags: 0 354 | m_CorrespondingSourceObject: {fileID: 0} 355 | m_PrefabInstance: {fileID: 0} 356 | m_PrefabAsset: {fileID: 0} 357 | m_GameObject: {fileID: 705507993} 358 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 359 | m_LocalPosition: {x: 0, y: 3, z: 0} 360 | m_LocalScale: {x: 1, y: 1, z: 1} 361 | m_Children: [] 362 | m_Father: {fileID: 0} 363 | m_RootOrder: 1 364 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 365 | --- !u!1 &963194225 366 | GameObject: 367 | m_ObjectHideFlags: 0 368 | m_CorrespondingSourceObject: {fileID: 0} 369 | m_PrefabInstance: {fileID: 0} 370 | m_PrefabAsset: {fileID: 0} 371 | serializedVersion: 6 372 | m_Component: 373 | - component: {fileID: 963194228} 374 | - component: {fileID: 963194227} 375 | - component: {fileID: 963194226} 376 | m_Layer: 0 377 | m_Name: Main Camera 378 | m_TagString: MainCamera 379 | m_Icon: {fileID: 0} 380 | m_NavMeshLayer: 0 381 | m_StaticEditorFlags: 0 382 | m_IsActive: 1 383 | --- !u!81 &963194226 384 | AudioListener: 385 | m_ObjectHideFlags: 0 386 | m_CorrespondingSourceObject: {fileID: 0} 387 | m_PrefabInstance: {fileID: 0} 388 | m_PrefabAsset: {fileID: 0} 389 | m_GameObject: {fileID: 963194225} 390 | m_Enabled: 1 391 | --- !u!20 &963194227 392 | Camera: 393 | m_ObjectHideFlags: 0 394 | m_CorrespondingSourceObject: {fileID: 0} 395 | m_PrefabInstance: {fileID: 0} 396 | m_PrefabAsset: {fileID: 0} 397 | m_GameObject: {fileID: 963194225} 398 | m_Enabled: 1 399 | serializedVersion: 2 400 | m_ClearFlags: 1 401 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 402 | m_projectionMatrixMode: 1 403 | m_GateFitMode: 2 404 | m_FOVAxisMode: 0 405 | m_SensorSize: {x: 36, y: 24} 406 | m_LensShift: {x: 0, y: 0} 407 | m_FocalLength: 50 408 | m_NormalizedViewPortRect: 409 | serializedVersion: 2 410 | x: 0 411 | y: 0 412 | width: 1 413 | height: 1 414 | near clip plane: 0.3 415 | far clip plane: 1000 416 | field of view: 60 417 | orthographic: 0 418 | orthographic size: 5 419 | m_Depth: -1 420 | m_CullingMask: 421 | serializedVersion: 2 422 | m_Bits: 4294967295 423 | m_RenderingPath: -1 424 | m_TargetTexture: {fileID: 0} 425 | m_TargetDisplay: 0 426 | m_TargetEye: 3 427 | m_HDR: 1 428 | m_AllowMSAA: 1 429 | m_AllowDynamicResolution: 0 430 | m_ForceIntoRT: 0 431 | m_OcclusionCulling: 1 432 | m_StereoConvergence: 10 433 | m_StereoSeparation: 0.022 434 | --- !u!4 &963194228 435 | Transform: 436 | m_ObjectHideFlags: 0 437 | m_CorrespondingSourceObject: {fileID: 0} 438 | m_PrefabInstance: {fileID: 0} 439 | m_PrefabAsset: {fileID: 0} 440 | m_GameObject: {fileID: 963194225} 441 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 442 | m_LocalPosition: {x: 0, y: 1, z: -10} 443 | m_LocalScale: {x: 1, y: 1, z: 1} 444 | m_Children: [] 445 | m_Father: {fileID: 0} 446 | m_RootOrder: 0 447 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 448 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonWriter.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * JsonWriter.cs 4 | * Stream-like facility to output JSON text. 5 | * 6 | * The authors disclaim copyright to this source code. For more details, see 7 | * the COPYING file included with this distribution. 8 | **/ 9 | #endregion 10 | 11 | 12 | using System; 13 | using System.Collections.Generic; 14 | using System.Globalization; 15 | using System.IO; 16 | using System.Text; 17 | 18 | 19 | namespace LitJson 20 | { 21 | internal enum Condition 22 | { 23 | InArray, 24 | InObject, 25 | NotAProperty, 26 | Property, 27 | Value 28 | } 29 | 30 | internal class WriterContext 31 | { 32 | public int Count; 33 | public bool InArray; 34 | public bool InObject; 35 | public bool ExpectingValue; 36 | public int Padding; 37 | } 38 | 39 | public class JsonWriter 40 | { 41 | #region Fields 42 | private static readonly NumberFormatInfo number_format; 43 | 44 | private WriterContext context; 45 | private Stack ctx_stack; 46 | private bool has_reached_end; 47 | private char[] hex_seq; 48 | private int indentation; 49 | private int indent_value; 50 | private StringBuilder inst_string_builder; 51 | private bool pretty_print; 52 | private bool validate; 53 | private bool lower_case_properties; 54 | private TextWriter writer; 55 | #endregion 56 | 57 | 58 | #region Properties 59 | public int IndentValue { 60 | get { return indent_value; } 61 | set { 62 | indentation = (indentation / indent_value) * value; 63 | indent_value = value; 64 | } 65 | } 66 | 67 | public bool PrettyPrint { 68 | get { return pretty_print; } 69 | set { pretty_print = value; } 70 | } 71 | 72 | public TextWriter TextWriter { 73 | get { return writer; } 74 | } 75 | 76 | public bool Validate { 77 | get { return validate; } 78 | set { validate = value; } 79 | } 80 | 81 | public bool LowerCaseProperties { 82 | get { return lower_case_properties; } 83 | set { lower_case_properties = value; } 84 | } 85 | #endregion 86 | 87 | 88 | #region Constructors 89 | static JsonWriter () 90 | { 91 | number_format = NumberFormatInfo.InvariantInfo; 92 | } 93 | 94 | public JsonWriter () 95 | { 96 | inst_string_builder = new StringBuilder (); 97 | writer = new StringWriter (inst_string_builder); 98 | 99 | Init (); 100 | } 101 | 102 | public JsonWriter (StringBuilder sb) : 103 | this (new StringWriter (sb)) 104 | { 105 | } 106 | 107 | public JsonWriter (TextWriter writer) 108 | { 109 | if (writer == null) 110 | throw new ArgumentNullException ("writer"); 111 | 112 | this.writer = writer; 113 | 114 | Init (); 115 | } 116 | #endregion 117 | 118 | 119 | #region Private Methods 120 | private void DoValidation (Condition cond) 121 | { 122 | if (! context.ExpectingValue) 123 | context.Count++; 124 | 125 | if (! validate) 126 | return; 127 | 128 | if (has_reached_end) 129 | throw new JsonException ( 130 | "A complete JSON symbol has already been written"); 131 | 132 | switch (cond) { 133 | case Condition.InArray: 134 | if (! context.InArray) 135 | throw new JsonException ( 136 | "Can't close an array here"); 137 | break; 138 | 139 | case Condition.InObject: 140 | if (! context.InObject || context.ExpectingValue) 141 | throw new JsonException ( 142 | "Can't close an object here"); 143 | break; 144 | 145 | case Condition.NotAProperty: 146 | if (context.InObject && ! context.ExpectingValue) 147 | throw new JsonException ( 148 | "Expected a property"); 149 | break; 150 | 151 | case Condition.Property: 152 | if (! context.InObject || context.ExpectingValue) 153 | throw new JsonException ( 154 | "Can't add a property here"); 155 | break; 156 | 157 | case Condition.Value: 158 | if (! context.InArray && 159 | (! context.InObject || ! context.ExpectingValue)) 160 | throw new JsonException ( 161 | "Can't add a value here"); 162 | 163 | break; 164 | } 165 | } 166 | 167 | private void Init () 168 | { 169 | has_reached_end = false; 170 | hex_seq = new char[4]; 171 | indentation = 0; 172 | indent_value = 4; 173 | pretty_print = true; 174 | validate = true; 175 | lower_case_properties = false; 176 | 177 | ctx_stack = new Stack (); 178 | context = new WriterContext (); 179 | ctx_stack.Push (context); 180 | } 181 | 182 | private static void IntToHex (int n, char[] hex) 183 | { 184 | int num; 185 | 186 | for (int i = 0; i < 4; i++) { 187 | num = n % 16; 188 | 189 | if (num < 10) 190 | hex[3 - i] = (char) ('0' + num); 191 | else 192 | hex[3 - i] = (char) ('A' + (num - 10)); 193 | 194 | n >>= 4; 195 | } 196 | } 197 | 198 | private void Indent () 199 | { 200 | if (pretty_print) 201 | indentation += indent_value; 202 | } 203 | 204 | 205 | private void Put (string str) 206 | { 207 | if (pretty_print && ! context.ExpectingValue) 208 | for (int i = 0; i < indentation; i++) 209 | writer.Write (' '); 210 | 211 | writer.Write (str); 212 | } 213 | 214 | private void PutNewline () 215 | { 216 | PutNewline (true); 217 | } 218 | 219 | private void PutNewline (bool add_comma) 220 | { 221 | if (add_comma && ! context.ExpectingValue && 222 | context.Count > 1) 223 | writer.Write (','); 224 | 225 | if (pretty_print && ! context.ExpectingValue) 226 | writer.Write (Environment.NewLine); 227 | } 228 | 229 | private void PutString (string str) 230 | { 231 | Put (String.Empty); 232 | 233 | writer.Write ('"'); 234 | 235 | int n = str.Length; 236 | for (int i = 0; i < n; i++) { 237 | switch (str[i]) { 238 | case '\n': 239 | writer.Write ("\\n"); 240 | continue; 241 | 242 | case '\r': 243 | writer.Write ("\\r"); 244 | continue; 245 | 246 | case '\t': 247 | writer.Write ("\\t"); 248 | continue; 249 | 250 | case '"': 251 | case '\\': 252 | writer.Write ('\\'); 253 | writer.Write (str[i]); 254 | continue; 255 | 256 | case '\f': 257 | writer.Write ("\\f"); 258 | continue; 259 | 260 | case '\b': 261 | writer.Write ("\\b"); 262 | continue; 263 | } 264 | 265 | if ((int) str[i] >= 32 && (int) str[i] <= 126) { 266 | writer.Write (str[i]); 267 | continue; 268 | } 269 | 270 | // Default, turn into a \uXXXX sequence 271 | IntToHex ((int) str[i], hex_seq); 272 | writer.Write ("\\u"); 273 | writer.Write (hex_seq); 274 | } 275 | 276 | writer.Write ('"'); 277 | } 278 | 279 | private void Unindent () 280 | { 281 | if (pretty_print) 282 | indentation -= indent_value; 283 | } 284 | #endregion 285 | 286 | 287 | public override string ToString () 288 | { 289 | if (inst_string_builder == null) 290 | return String.Empty; 291 | 292 | return inst_string_builder.ToString (); 293 | } 294 | 295 | public void Reset () 296 | { 297 | has_reached_end = false; 298 | 299 | ctx_stack.Clear (); 300 | context = new WriterContext (); 301 | ctx_stack.Push (context); 302 | 303 | if (inst_string_builder != null) 304 | inst_string_builder.Remove (0, inst_string_builder.Length); 305 | } 306 | 307 | public void Write (bool boolean) 308 | { 309 | DoValidation (Condition.Value); 310 | PutNewline (); 311 | 312 | Put (boolean ? "true" : "false"); 313 | 314 | context.ExpectingValue = false; 315 | } 316 | 317 | public void Write (decimal number) 318 | { 319 | DoValidation (Condition.Value); 320 | PutNewline (); 321 | 322 | Put (Convert.ToString (number, number_format)); 323 | 324 | context.ExpectingValue = false; 325 | } 326 | 327 | public void Write (double number) 328 | { 329 | DoValidation (Condition.Value); 330 | PutNewline (); 331 | 332 | string str = Convert.ToString (number, number_format); 333 | Put (str); 334 | 335 | if (str.IndexOf ('.') == -1 && 336 | str.IndexOf ('E') == -1) 337 | writer.Write (".0"); 338 | 339 | context.ExpectingValue = false; 340 | } 341 | 342 | public void Write(float number) 343 | { 344 | DoValidation(Condition.Value); 345 | PutNewline(); 346 | 347 | string str = Convert.ToString(number, number_format); 348 | Put(str); 349 | 350 | context.ExpectingValue = false; 351 | } 352 | 353 | public void Write (int number) 354 | { 355 | DoValidation (Condition.Value); 356 | PutNewline (); 357 | 358 | Put (Convert.ToString (number, number_format)); 359 | 360 | context.ExpectingValue = false; 361 | } 362 | 363 | public void Write (long number) 364 | { 365 | DoValidation (Condition.Value); 366 | PutNewline (); 367 | 368 | Put (Convert.ToString (number, number_format)); 369 | 370 | context.ExpectingValue = false; 371 | } 372 | 373 | public void Write (string str) 374 | { 375 | DoValidation (Condition.Value); 376 | PutNewline (); 377 | 378 | if (str == null) 379 | Put ("null"); 380 | else 381 | PutString (str); 382 | 383 | context.ExpectingValue = false; 384 | } 385 | 386 | [CLSCompliant(false)] 387 | public void Write (ulong number) 388 | { 389 | DoValidation (Condition.Value); 390 | PutNewline (); 391 | 392 | Put (Convert.ToString (number, number_format)); 393 | 394 | context.ExpectingValue = false; 395 | } 396 | 397 | public void WriteArrayEnd () 398 | { 399 | DoValidation (Condition.InArray); 400 | PutNewline (false); 401 | 402 | ctx_stack.Pop (); 403 | if (ctx_stack.Count == 1) 404 | has_reached_end = true; 405 | else { 406 | context = ctx_stack.Peek (); 407 | context.ExpectingValue = false; 408 | } 409 | 410 | Unindent (); 411 | Put ("]"); 412 | } 413 | 414 | public void WriteArrayStart () 415 | { 416 | DoValidation (Condition.NotAProperty); 417 | PutNewline (); 418 | 419 | Put ("["); 420 | 421 | context = new WriterContext (); 422 | context.InArray = true; 423 | ctx_stack.Push (context); 424 | 425 | Indent (); 426 | } 427 | 428 | public void WriteObjectEnd () 429 | { 430 | DoValidation (Condition.InObject); 431 | PutNewline (false); 432 | 433 | ctx_stack.Pop (); 434 | if (ctx_stack.Count == 1) 435 | has_reached_end = true; 436 | else { 437 | context = ctx_stack.Peek (); 438 | context.ExpectingValue = false; 439 | } 440 | 441 | Unindent (); 442 | Put ("}"); 443 | } 444 | 445 | public void WriteObjectStart () 446 | { 447 | DoValidation (Condition.NotAProperty); 448 | PutNewline (); 449 | 450 | Put ("{"); 451 | 452 | context = new WriterContext (); 453 | context.InObject = true; 454 | ctx_stack.Push (context); 455 | 456 | Indent (); 457 | } 458 | 459 | public void WritePropertyName (string property_name) 460 | { 461 | DoValidation (Condition.Property); 462 | PutNewline (); 463 | string propertyName = (property_name == null || !lower_case_properties) 464 | ? property_name 465 | : property_name.ToLowerInvariant(); 466 | 467 | PutString (propertyName); 468 | 469 | if (pretty_print) { 470 | if (propertyName.Length > context.Padding) 471 | context.Padding = propertyName.Length; 472 | 473 | for (int i = context.Padding - propertyName.Length; 474 | i >= 0; i--) 475 | writer.Write (' '); 476 | 477 | writer.Write (": "); 478 | } else 479 | writer.Write (':'); 480 | 481 | context.ExpectingValue = true; 482 | } 483 | } 484 | } 485 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonReader.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * JsonReader.cs 4 | * Stream-like access to JSON text. 5 | * 6 | * The authors disclaim copyright to this source code. For more details, see 7 | * the COPYING file included with this distribution. 8 | **/ 9 | #endregion 10 | 11 | 12 | using System; 13 | using System.Collections.Generic; 14 | using System.Globalization; 15 | using System.IO; 16 | using System.Text; 17 | 18 | 19 | namespace LitJson 20 | { 21 | public enum JsonToken 22 | { 23 | None, 24 | 25 | ObjectStart, 26 | PropertyName, 27 | ObjectEnd, 28 | 29 | ArrayStart, 30 | ArrayEnd, 31 | 32 | Int, 33 | Long, 34 | Double, 35 | 36 | String, 37 | 38 | Boolean, 39 | Null 40 | } 41 | 42 | 43 | public class JsonReader 44 | { 45 | #region Fields 46 | private static readonly IDictionary> parse_table; 47 | 48 | private Stack automaton_stack; 49 | private int current_input; 50 | private int current_symbol; 51 | private bool end_of_json; 52 | private bool end_of_input; 53 | private Lexer lexer; 54 | private bool parser_in_string; 55 | private bool parser_return; 56 | private bool read_started; 57 | private TextReader reader; 58 | private bool reader_is_owned; 59 | private bool skip_non_members; 60 | private object token_value; 61 | private JsonToken token; 62 | #endregion 63 | 64 | 65 | #region Public Properties 66 | public bool AllowComments { 67 | get { return lexer.AllowComments; } 68 | set { lexer.AllowComments = value; } 69 | } 70 | 71 | public bool AllowSingleQuotedStrings { 72 | get { return lexer.AllowSingleQuotedStrings; } 73 | set { lexer.AllowSingleQuotedStrings = value; } 74 | } 75 | 76 | public bool SkipNonMembers { 77 | get { return skip_non_members; } 78 | set { skip_non_members = value; } 79 | } 80 | 81 | public bool EndOfInput { 82 | get { return end_of_input; } 83 | } 84 | 85 | public bool EndOfJson { 86 | get { return end_of_json; } 87 | } 88 | 89 | public JsonToken Token { 90 | get { return token; } 91 | } 92 | 93 | public object Value { 94 | get { return token_value; } 95 | } 96 | #endregion 97 | 98 | 99 | #region Constructors 100 | static JsonReader () 101 | { 102 | parse_table = PopulateParseTable (); 103 | } 104 | 105 | public JsonReader (string json_text) : 106 | this (new StringReader (json_text), true) 107 | { 108 | } 109 | 110 | public JsonReader (TextReader reader) : 111 | this (reader, false) 112 | { 113 | } 114 | 115 | private JsonReader (TextReader reader, bool owned) 116 | { 117 | if (reader == null) 118 | throw new ArgumentNullException ("reader"); 119 | 120 | parser_in_string = false; 121 | parser_return = false; 122 | 123 | read_started = false; 124 | automaton_stack = new Stack (); 125 | automaton_stack.Push ((int) ParserToken.End); 126 | automaton_stack.Push ((int) ParserToken.Text); 127 | 128 | lexer = new Lexer (reader); 129 | 130 | end_of_input = false; 131 | end_of_json = false; 132 | 133 | skip_non_members = true; 134 | 135 | this.reader = reader; 136 | reader_is_owned = owned; 137 | } 138 | #endregion 139 | 140 | 141 | #region Static Methods 142 | private static IDictionary> PopulateParseTable () 143 | { 144 | // See section A.2. of the manual for details 145 | IDictionary> parse_table = new Dictionary> (); 146 | 147 | TableAddRow (parse_table, ParserToken.Array); 148 | TableAddCol (parse_table, ParserToken.Array, '[', 149 | '[', 150 | (int) ParserToken.ArrayPrime); 151 | 152 | TableAddRow (parse_table, ParserToken.ArrayPrime); 153 | TableAddCol (parse_table, ParserToken.ArrayPrime, '"', 154 | (int) ParserToken.Value, 155 | 156 | (int) ParserToken.ValueRest, 157 | ']'); 158 | TableAddCol (parse_table, ParserToken.ArrayPrime, '[', 159 | (int) ParserToken.Value, 160 | (int) ParserToken.ValueRest, 161 | ']'); 162 | TableAddCol (parse_table, ParserToken.ArrayPrime, ']', 163 | ']'); 164 | TableAddCol (parse_table, ParserToken.ArrayPrime, '{', 165 | (int) ParserToken.Value, 166 | (int) ParserToken.ValueRest, 167 | ']'); 168 | TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.Number, 169 | (int) ParserToken.Value, 170 | (int) ParserToken.ValueRest, 171 | ']'); 172 | TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.True, 173 | (int) ParserToken.Value, 174 | (int) ParserToken.ValueRest, 175 | ']'); 176 | TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.False, 177 | (int) ParserToken.Value, 178 | (int) ParserToken.ValueRest, 179 | ']'); 180 | TableAddCol (parse_table, ParserToken.ArrayPrime, (int) ParserToken.Null, 181 | (int) ParserToken.Value, 182 | (int) ParserToken.ValueRest, 183 | ']'); 184 | 185 | TableAddRow (parse_table, ParserToken.Object); 186 | TableAddCol (parse_table, ParserToken.Object, '{', 187 | '{', 188 | (int) ParserToken.ObjectPrime); 189 | 190 | TableAddRow (parse_table, ParserToken.ObjectPrime); 191 | TableAddCol (parse_table, ParserToken.ObjectPrime, '"', 192 | (int) ParserToken.Pair, 193 | (int) ParserToken.PairRest, 194 | '}'); 195 | TableAddCol (parse_table, ParserToken.ObjectPrime, '}', 196 | '}'); 197 | 198 | TableAddRow (parse_table, ParserToken.Pair); 199 | TableAddCol (parse_table, ParserToken.Pair, '"', 200 | (int) ParserToken.String, 201 | ':', 202 | (int) ParserToken.Value); 203 | 204 | TableAddRow (parse_table, ParserToken.PairRest); 205 | TableAddCol (parse_table, ParserToken.PairRest, ',', 206 | ',', 207 | (int) ParserToken.Pair, 208 | (int) ParserToken.PairRest); 209 | TableAddCol (parse_table, ParserToken.PairRest, '}', 210 | (int) ParserToken.Epsilon); 211 | 212 | TableAddRow (parse_table, ParserToken.String); 213 | TableAddCol (parse_table, ParserToken.String, '"', 214 | '"', 215 | (int) ParserToken.CharSeq, 216 | '"'); 217 | 218 | TableAddRow (parse_table, ParserToken.Text); 219 | TableAddCol (parse_table, ParserToken.Text, '[', 220 | (int) ParserToken.Array); 221 | TableAddCol (parse_table, ParserToken.Text, '{', 222 | (int) ParserToken.Object); 223 | 224 | TableAddRow (parse_table, ParserToken.Value); 225 | TableAddCol (parse_table, ParserToken.Value, '"', 226 | (int) ParserToken.String); 227 | TableAddCol (parse_table, ParserToken.Value, '[', 228 | (int) ParserToken.Array); 229 | TableAddCol (parse_table, ParserToken.Value, '{', 230 | (int) ParserToken.Object); 231 | TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.Number, 232 | (int) ParserToken.Number); 233 | TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.True, 234 | (int) ParserToken.True); 235 | TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.False, 236 | (int) ParserToken.False); 237 | TableAddCol (parse_table, ParserToken.Value, (int) ParserToken.Null, 238 | (int) ParserToken.Null); 239 | 240 | TableAddRow (parse_table, ParserToken.ValueRest); 241 | TableAddCol (parse_table, ParserToken.ValueRest, ',', 242 | ',', 243 | (int) ParserToken.Value, 244 | (int) ParserToken.ValueRest); 245 | TableAddCol (parse_table, ParserToken.ValueRest, ']', 246 | (int) ParserToken.Epsilon); 247 | 248 | return parse_table; 249 | } 250 | 251 | private static void TableAddCol (IDictionary> parse_table, ParserToken row, int col, 252 | params int[] symbols) 253 | { 254 | parse_table[(int) row].Add (col, symbols); 255 | } 256 | 257 | private static void TableAddRow (IDictionary> parse_table, ParserToken rule) 258 | { 259 | parse_table.Add ((int) rule, new Dictionary ()); 260 | } 261 | #endregion 262 | 263 | 264 | #region Private Methods 265 | private void ProcessNumber (string number) 266 | { 267 | if (number.IndexOf ('.') != -1 || 268 | number.IndexOf ('e') != -1 || 269 | number.IndexOf ('E') != -1) { 270 | 271 | double n_double; 272 | if (double.TryParse (number, NumberStyles.Any, CultureInfo.InvariantCulture, out n_double)) { 273 | token = JsonToken.Double; 274 | token_value = n_double; 275 | 276 | return; 277 | } 278 | } 279 | 280 | int n_int32; 281 | if (int.TryParse (number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int32)) { 282 | token = JsonToken.Int; 283 | token_value = n_int32; 284 | 285 | return; 286 | } 287 | 288 | long n_int64; 289 | if (long.TryParse (number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_int64)) { 290 | token = JsonToken.Long; 291 | token_value = n_int64; 292 | 293 | return; 294 | } 295 | 296 | ulong n_uint64; 297 | if (ulong.TryParse(number, NumberStyles.Integer, CultureInfo.InvariantCulture, out n_uint64)) 298 | { 299 | token = JsonToken.Long; 300 | token_value = n_uint64; 301 | 302 | return; 303 | } 304 | 305 | // Shouldn't happen, but just in case, return something 306 | token = JsonToken.Int; 307 | token_value = 0; 308 | } 309 | 310 | private void ProcessSymbol () 311 | { 312 | if (current_symbol == '[') { 313 | token = JsonToken.ArrayStart; 314 | parser_return = true; 315 | 316 | } else if (current_symbol == ']') { 317 | token = JsonToken.ArrayEnd; 318 | parser_return = true; 319 | 320 | } else if (current_symbol == '{') { 321 | token = JsonToken.ObjectStart; 322 | parser_return = true; 323 | 324 | } else if (current_symbol == '}') { 325 | token = JsonToken.ObjectEnd; 326 | parser_return = true; 327 | 328 | } else if (current_symbol == '"') { 329 | if (parser_in_string) { 330 | parser_in_string = false; 331 | 332 | parser_return = true; 333 | 334 | } else { 335 | if (token == JsonToken.None) 336 | token = JsonToken.String; 337 | 338 | parser_in_string = true; 339 | } 340 | 341 | } else if (current_symbol == (int) ParserToken.CharSeq) { 342 | token_value = lexer.StringValue; 343 | 344 | } else if (current_symbol == (int) ParserToken.False) { 345 | token = JsonToken.Boolean; 346 | token_value = false; 347 | parser_return = true; 348 | 349 | } else if (current_symbol == (int) ParserToken.Null) { 350 | token = JsonToken.Null; 351 | parser_return = true; 352 | 353 | } else if (current_symbol == (int) ParserToken.Number) { 354 | ProcessNumber (lexer.StringValue); 355 | 356 | parser_return = true; 357 | 358 | } else if (current_symbol == (int) ParserToken.Pair) { 359 | token = JsonToken.PropertyName; 360 | 361 | } else if (current_symbol == (int) ParserToken.True) { 362 | token = JsonToken.Boolean; 363 | token_value = true; 364 | parser_return = true; 365 | 366 | } 367 | } 368 | 369 | private bool ReadToken () 370 | { 371 | if (end_of_input) 372 | return false; 373 | 374 | lexer.NextToken (); 375 | 376 | if (lexer.EndOfInput) { 377 | Close (); 378 | 379 | return false; 380 | } 381 | 382 | current_input = lexer.Token; 383 | 384 | return true; 385 | } 386 | #endregion 387 | 388 | 389 | public void Close () 390 | { 391 | if (end_of_input) 392 | return; 393 | 394 | end_of_input = true; 395 | end_of_json = true; 396 | 397 | if (reader_is_owned) 398 | { 399 | using(reader){} 400 | } 401 | 402 | reader = null; 403 | } 404 | 405 | public bool Read () 406 | { 407 | if (end_of_input) 408 | return false; 409 | 410 | if (end_of_json) { 411 | end_of_json = false; 412 | automaton_stack.Clear (); 413 | automaton_stack.Push ((int) ParserToken.End); 414 | automaton_stack.Push ((int) ParserToken.Text); 415 | } 416 | 417 | parser_in_string = false; 418 | parser_return = false; 419 | 420 | token = JsonToken.None; 421 | token_value = null; 422 | 423 | if (! read_started) { 424 | read_started = true; 425 | 426 | if (! ReadToken ()) 427 | return false; 428 | } 429 | 430 | 431 | int[] entry_symbols; 432 | 433 | while (true) { 434 | if (parser_return) { 435 | if (automaton_stack.Peek () == (int) ParserToken.End) 436 | end_of_json = true; 437 | 438 | return true; 439 | } 440 | 441 | current_symbol = automaton_stack.Pop (); 442 | 443 | ProcessSymbol (); 444 | 445 | if (current_symbol == current_input) { 446 | if (! ReadToken ()) { 447 | if (automaton_stack.Peek () != (int) ParserToken.End) 448 | throw new JsonException ( 449 | "Input doesn't evaluate to proper JSON text"); 450 | 451 | if (parser_return) 452 | return true; 453 | 454 | return false; 455 | } 456 | 457 | continue; 458 | } 459 | 460 | try { 461 | 462 | entry_symbols = 463 | parse_table[current_symbol][current_input]; 464 | 465 | } catch (KeyNotFoundException e) { 466 | throw new JsonException ((ParserToken) current_input, e); 467 | } 468 | 469 | if (entry_symbols[0] == (int) ParserToken.Epsilon) 470 | continue; 471 | 472 | for (int i = entry_symbols.Length - 1; i >= 0; i--) 473 | automaton_stack.Push (entry_symbols[i]); 474 | } 475 | } 476 | 477 | } 478 | } 479 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 20 7 | productGUID: ee20b7aef1f968d41878cc0da64fe7a2 8 | AndroidProfiler: 0 9 | AndroidFilterTouchesWhenObscured: 0 10 | AndroidEnableSustainedPerformanceMode: 0 11 | defaultScreenOrientation: 4 12 | targetDevice: 2 13 | useOnDemandResources: 0 14 | accelerometerFrequency: 60 15 | companyName: DefaultCompany 16 | productName: TinyGameSaveSystem 17 | defaultCursor: {fileID: 0} 18 | cursorHotspot: {x: 0, y: 0} 19 | m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} 20 | m_ShowUnitySplashScreen: 1 21 | m_ShowUnitySplashLogo: 1 22 | m_SplashScreenOverlayOpacity: 1 23 | m_SplashScreenAnimation: 1 24 | m_SplashScreenLogoStyle: 1 25 | m_SplashScreenDrawMode: 0 26 | m_SplashScreenBackgroundAnimationZoom: 1 27 | m_SplashScreenLogoAnimationZoom: 1 28 | m_SplashScreenBackgroundLandscapeAspect: 1 29 | m_SplashScreenBackgroundPortraitAspect: 1 30 | m_SplashScreenBackgroundLandscapeUvs: 31 | serializedVersion: 2 32 | x: 0 33 | y: 0 34 | width: 1 35 | height: 1 36 | m_SplashScreenBackgroundPortraitUvs: 37 | serializedVersion: 2 38 | x: 0 39 | y: 0 40 | width: 1 41 | height: 1 42 | m_SplashScreenLogos: [] 43 | m_VirtualRealitySplashScreen: {fileID: 0} 44 | m_HolographicTrackingLossScreen: {fileID: 0} 45 | defaultScreenWidth: 1024 46 | defaultScreenHeight: 768 47 | defaultScreenWidthWeb: 960 48 | defaultScreenHeightWeb: 600 49 | m_StereoRenderingPath: 0 50 | m_ActiveColorSpace: 0 51 | m_MTRendering: 1 52 | m_StackTraceTypes: 010000000100000001000000010000000100000001000000 53 | iosShowActivityIndicatorOnLoading: -1 54 | androidShowActivityIndicatorOnLoading: -1 55 | iosUseCustomAppBackgroundBehavior: 0 56 | iosAllowHTTPDownload: 1 57 | allowedAutorotateToPortrait: 1 58 | allowedAutorotateToPortraitUpsideDown: 1 59 | allowedAutorotateToLandscapeRight: 1 60 | allowedAutorotateToLandscapeLeft: 1 61 | useOSAutorotation: 1 62 | use32BitDisplayBuffer: 1 63 | preserveFramebufferAlpha: 0 64 | disableDepthAndStencilBuffers: 0 65 | androidStartInFullscreen: 1 66 | androidRenderOutsideSafeArea: 1 67 | androidUseSwappy: 0 68 | androidBlitType: 0 69 | defaultIsNativeResolution: 1 70 | macRetinaSupport: 1 71 | runInBackground: 1 72 | captureSingleScreen: 0 73 | muteOtherAudioSources: 0 74 | Prepare IOS For Recording: 0 75 | Force IOS Speakers When Recording: 0 76 | deferSystemGesturesMode: 0 77 | hideHomeButton: 0 78 | submitAnalytics: 1 79 | usePlayerLog: 1 80 | bakeCollisionMeshes: 0 81 | forceSingleInstance: 0 82 | useFlipModelSwapchain: 1 83 | resizableWindow: 0 84 | useMacAppStoreValidation: 0 85 | macAppStoreCategory: public.app-category.games 86 | gpuSkinning: 1 87 | xboxPIXTextureCapture: 0 88 | xboxEnableAvatar: 0 89 | xboxEnableKinect: 0 90 | xboxEnableKinectAutoTracking: 0 91 | xboxEnableFitness: 0 92 | visibleInBackground: 1 93 | allowFullscreenSwitch: 1 94 | fullscreenMode: 1 95 | xboxSpeechDB: 0 96 | xboxEnableHeadOrientation: 0 97 | xboxEnableGuest: 0 98 | xboxEnablePIXSampling: 0 99 | metalFramebufferOnly: 0 100 | xboxOneResolution: 0 101 | xboxOneSResolution: 0 102 | xboxOneXResolution: 3 103 | xboxOneMonoLoggingLevel: 0 104 | xboxOneLoggingLevel: 1 105 | xboxOneDisableEsram: 0 106 | xboxOneEnableTypeOptimization: 0 107 | xboxOnePresentImmediateThreshold: 0 108 | switchQueueCommandMemory: 0 109 | switchQueueControlMemory: 16384 110 | switchQueueComputeMemory: 262144 111 | switchNVNShaderPoolsGranularity: 33554432 112 | switchNVNDefaultPoolsGranularity: 16777216 113 | switchNVNOtherPoolsGranularity: 16777216 114 | switchNVNMaxPublicTextureIDCount: 0 115 | switchNVNMaxPublicSamplerIDCount: 0 116 | stadiaPresentMode: 0 117 | stadiaTargetFramerate: 0 118 | vulkanNumSwapchainBuffers: 3 119 | vulkanEnableSetSRGBWrite: 0 120 | vulkanEnableLateAcquireNextImage: 0 121 | m_SupportedAspectRatios: 122 | 4:3: 1 123 | 5:4: 1 124 | 16:10: 1 125 | 16:9: 1 126 | Others: 1 127 | bundleVersion: 0.1 128 | preloadedAssets: [] 129 | metroInputSource: 0 130 | wsaTransparentSwapchain: 0 131 | m_HolographicPauseOnTrackingLoss: 1 132 | xboxOneDisableKinectGpuReservation: 1 133 | xboxOneEnable7thCore: 1 134 | vrSettings: 135 | cardboard: 136 | depthFormat: 0 137 | enableTransitionView: 0 138 | daydream: 139 | depthFormat: 0 140 | useSustainedPerformanceMode: 0 141 | enableVideoLayer: 0 142 | useProtectedVideoMemory: 0 143 | minimumSupportedHeadTracking: 0 144 | maximumSupportedHeadTracking: 1 145 | hololens: 146 | depthFormat: 1 147 | depthBufferSharingEnabled: 1 148 | lumin: 149 | depthFormat: 0 150 | frameTiming: 2 151 | enableGLCache: 0 152 | glCacheMaxBlobSize: 524288 153 | glCacheMaxFileSize: 8388608 154 | oculus: 155 | sharedDepthBuffer: 1 156 | dashSupport: 1 157 | lowOverheadMode: 0 158 | protectedContext: 0 159 | v2Signing: 1 160 | enable360StereoCapture: 0 161 | isWsaHolographicRemotingEnabled: 0 162 | enableFrameTimingStats: 0 163 | useHDRDisplay: 0 164 | D3DHDRBitDepth: 0 165 | m_ColorGamuts: 00000000 166 | targetPixelDensity: 30 167 | resolutionScalingMode: 0 168 | androidSupportedAspectRatio: 1 169 | androidMaxAspectRatio: 2.1 170 | applicationIdentifier: {} 171 | buildNumber: {} 172 | AndroidBundleVersionCode: 1 173 | AndroidMinSdkVersion: 19 174 | AndroidTargetSdkVersion: 0 175 | AndroidPreferredInstallLocation: 1 176 | aotOptions: 177 | stripEngineCode: 1 178 | iPhoneStrippingLevel: 0 179 | iPhoneScriptCallOptimization: 0 180 | ForceInternetPermission: 0 181 | ForceSDCardPermission: 0 182 | CreateWallpaper: 0 183 | APKExpansionFiles: 0 184 | keepLoadedShadersAlive: 0 185 | StripUnusedMeshComponents: 1 186 | VertexChannelCompressionMask: 4054 187 | iPhoneSdkVersion: 988 188 | iOSTargetOSVersionString: 10.0 189 | tvOSSdkVersion: 0 190 | tvOSRequireExtendedGameController: 0 191 | tvOSTargetOSVersionString: 10.0 192 | uIPrerenderedIcon: 0 193 | uIRequiresPersistentWiFi: 0 194 | uIRequiresFullScreen: 1 195 | uIStatusBarHidden: 1 196 | uIExitOnSuspend: 0 197 | uIStatusBarStyle: 0 198 | appleTVSplashScreen: {fileID: 0} 199 | appleTVSplashScreen2x: {fileID: 0} 200 | tvOSSmallIconLayers: [] 201 | tvOSSmallIconLayers2x: [] 202 | tvOSLargeIconLayers: [] 203 | tvOSLargeIconLayers2x: [] 204 | tvOSTopShelfImageLayers: [] 205 | tvOSTopShelfImageLayers2x: [] 206 | tvOSTopShelfImageWideLayers: [] 207 | tvOSTopShelfImageWideLayers2x: [] 208 | iOSLaunchScreenType: 0 209 | iOSLaunchScreenPortrait: {fileID: 0} 210 | iOSLaunchScreenLandscape: {fileID: 0} 211 | iOSLaunchScreenBackgroundColor: 212 | serializedVersion: 2 213 | rgba: 0 214 | iOSLaunchScreenFillPct: 100 215 | iOSLaunchScreenSize: 100 216 | iOSLaunchScreenCustomXibPath: 217 | iOSLaunchScreeniPadType: 0 218 | iOSLaunchScreeniPadImage: {fileID: 0} 219 | iOSLaunchScreeniPadBackgroundColor: 220 | serializedVersion: 2 221 | rgba: 0 222 | iOSLaunchScreeniPadFillPct: 100 223 | iOSLaunchScreeniPadSize: 100 224 | iOSLaunchScreeniPadCustomXibPath: 225 | iOSUseLaunchScreenStoryboard: 0 226 | iOSLaunchScreenCustomStoryboardPath: 227 | iOSDeviceRequirements: [] 228 | iOSURLSchemes: [] 229 | iOSBackgroundModes: 0 230 | iOSMetalForceHardShadows: 0 231 | metalEditorSupport: 1 232 | metalAPIValidation: 1 233 | iOSRenderExtraFrameOnPause: 0 234 | appleDeveloperTeamID: 235 | iOSManualSigningProvisioningProfileID: 236 | tvOSManualSigningProvisioningProfileID: 237 | iOSManualSigningProvisioningProfileType: 0 238 | tvOSManualSigningProvisioningProfileType: 0 239 | appleEnableAutomaticSigning: 0 240 | iOSRequireARKit: 0 241 | iOSAutomaticallyDetectAndAddCapabilities: 1 242 | appleEnableProMotion: 0 243 | clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea 244 | templatePackageId: com.unity.template.3d@4.2.8 245 | templateDefaultScene: Assets/Scenes/SampleScene.unity 246 | AndroidTargetArchitectures: 1 247 | AndroidSplashScreenScale: 0 248 | androidSplashScreen: {fileID: 0} 249 | AndroidKeystoreName: 250 | AndroidKeyaliasName: 251 | AndroidBuildApkPerCpuArchitecture: 0 252 | AndroidTVCompatibility: 0 253 | AndroidIsGame: 1 254 | AndroidEnableTango: 0 255 | androidEnableBanner: 1 256 | androidUseLowAccuracyLocation: 0 257 | androidUseCustomKeystore: 0 258 | m_AndroidBanners: 259 | - width: 320 260 | height: 180 261 | banner: {fileID: 0} 262 | androidGamepadSupportLevel: 0 263 | AndroidValidateAppBundleSize: 1 264 | AndroidAppBundleSizeToValidate: 150 265 | m_BuildTargetIcons: [] 266 | m_BuildTargetPlatformIcons: [] 267 | m_BuildTargetBatching: 268 | - m_BuildTarget: Standalone 269 | m_StaticBatching: 1 270 | m_DynamicBatching: 0 271 | - m_BuildTarget: tvOS 272 | m_StaticBatching: 1 273 | m_DynamicBatching: 0 274 | - m_BuildTarget: Android 275 | m_StaticBatching: 1 276 | m_DynamicBatching: 0 277 | - m_BuildTarget: iPhone 278 | m_StaticBatching: 1 279 | m_DynamicBatching: 0 280 | - m_BuildTarget: WebGL 281 | m_StaticBatching: 0 282 | m_DynamicBatching: 0 283 | m_BuildTargetGraphicsJobs: 284 | - m_BuildTarget: MacStandaloneSupport 285 | m_GraphicsJobs: 0 286 | - m_BuildTarget: Switch 287 | m_GraphicsJobs: 1 288 | - m_BuildTarget: MetroSupport 289 | m_GraphicsJobs: 1 290 | - m_BuildTarget: AppleTVSupport 291 | m_GraphicsJobs: 0 292 | - m_BuildTarget: BJMSupport 293 | m_GraphicsJobs: 1 294 | - m_BuildTarget: LinuxStandaloneSupport 295 | m_GraphicsJobs: 1 296 | - m_BuildTarget: PS4Player 297 | m_GraphicsJobs: 1 298 | - m_BuildTarget: iOSSupport 299 | m_GraphicsJobs: 0 300 | - m_BuildTarget: WindowsStandaloneSupport 301 | m_GraphicsJobs: 1 302 | - m_BuildTarget: XboxOnePlayer 303 | m_GraphicsJobs: 1 304 | - m_BuildTarget: LuminSupport 305 | m_GraphicsJobs: 0 306 | - m_BuildTarget: AndroidPlayer 307 | m_GraphicsJobs: 0 308 | - m_BuildTarget: WebGLSupport 309 | m_GraphicsJobs: 0 310 | m_BuildTargetGraphicsJobMode: 311 | - m_BuildTarget: PS4Player 312 | m_GraphicsJobMode: 0 313 | - m_BuildTarget: XboxOnePlayer 314 | m_GraphicsJobMode: 0 315 | m_BuildTargetGraphicsAPIs: 316 | - m_BuildTarget: AndroidPlayer 317 | m_APIs: 150000000b000000 318 | m_Automatic: 0 319 | - m_BuildTarget: iOSSupport 320 | m_APIs: 10000000 321 | m_Automatic: 1 322 | - m_BuildTarget: AppleTVSupport 323 | m_APIs: 10000000 324 | m_Automatic: 0 325 | - m_BuildTarget: WebGLSupport 326 | m_APIs: 0b000000 327 | m_Automatic: 1 328 | m_BuildTargetVRSettings: 329 | - m_BuildTarget: Standalone 330 | m_Enabled: 0 331 | m_Devices: 332 | - Oculus 333 | - OpenVR 334 | openGLRequireES31: 0 335 | openGLRequireES31AEP: 0 336 | openGLRequireES32: 0 337 | m_TemplateCustomTags: {} 338 | mobileMTRendering: 339 | Android: 1 340 | iPhone: 1 341 | tvOS: 1 342 | m_BuildTargetGroupLightmapEncodingQuality: [] 343 | m_BuildTargetGroupLightmapSettings: [] 344 | playModeTestRunnerEnabled: 0 345 | runPlayModeTestAsEditModeTest: 0 346 | actionOnDotNetUnhandledException: 1 347 | enableInternalProfiler: 0 348 | logObjCUncaughtExceptions: 1 349 | enableCrashReportAPI: 0 350 | cameraUsageDescription: 351 | locationUsageDescription: 352 | microphoneUsageDescription: 353 | switchNetLibKey: 354 | switchSocketMemoryPoolSize: 6144 355 | switchSocketAllocatorPoolSize: 128 356 | switchSocketConcurrencyLimit: 14 357 | switchScreenResolutionBehavior: 2 358 | switchUseCPUProfiler: 0 359 | switchApplicationID: 0x01004b9000490000 360 | switchNSODependencies: 361 | switchTitleNames_0: 362 | switchTitleNames_1: 363 | switchTitleNames_2: 364 | switchTitleNames_3: 365 | switchTitleNames_4: 366 | switchTitleNames_5: 367 | switchTitleNames_6: 368 | switchTitleNames_7: 369 | switchTitleNames_8: 370 | switchTitleNames_9: 371 | switchTitleNames_10: 372 | switchTitleNames_11: 373 | switchTitleNames_12: 374 | switchTitleNames_13: 375 | switchTitleNames_14: 376 | switchPublisherNames_0: 377 | switchPublisherNames_1: 378 | switchPublisherNames_2: 379 | switchPublisherNames_3: 380 | switchPublisherNames_4: 381 | switchPublisherNames_5: 382 | switchPublisherNames_6: 383 | switchPublisherNames_7: 384 | switchPublisherNames_8: 385 | switchPublisherNames_9: 386 | switchPublisherNames_10: 387 | switchPublisherNames_11: 388 | switchPublisherNames_12: 389 | switchPublisherNames_13: 390 | switchPublisherNames_14: 391 | switchIcons_0: {fileID: 0} 392 | switchIcons_1: {fileID: 0} 393 | switchIcons_2: {fileID: 0} 394 | switchIcons_3: {fileID: 0} 395 | switchIcons_4: {fileID: 0} 396 | switchIcons_5: {fileID: 0} 397 | switchIcons_6: {fileID: 0} 398 | switchIcons_7: {fileID: 0} 399 | switchIcons_8: {fileID: 0} 400 | switchIcons_9: {fileID: 0} 401 | switchIcons_10: {fileID: 0} 402 | switchIcons_11: {fileID: 0} 403 | switchIcons_12: {fileID: 0} 404 | switchIcons_13: {fileID: 0} 405 | switchIcons_14: {fileID: 0} 406 | switchSmallIcons_0: {fileID: 0} 407 | switchSmallIcons_1: {fileID: 0} 408 | switchSmallIcons_2: {fileID: 0} 409 | switchSmallIcons_3: {fileID: 0} 410 | switchSmallIcons_4: {fileID: 0} 411 | switchSmallIcons_5: {fileID: 0} 412 | switchSmallIcons_6: {fileID: 0} 413 | switchSmallIcons_7: {fileID: 0} 414 | switchSmallIcons_8: {fileID: 0} 415 | switchSmallIcons_9: {fileID: 0} 416 | switchSmallIcons_10: {fileID: 0} 417 | switchSmallIcons_11: {fileID: 0} 418 | switchSmallIcons_12: {fileID: 0} 419 | switchSmallIcons_13: {fileID: 0} 420 | switchSmallIcons_14: {fileID: 0} 421 | switchManualHTML: 422 | switchAccessibleURLs: 423 | switchLegalInformation: 424 | switchMainThreadStackSize: 1048576 425 | switchPresenceGroupId: 426 | switchLogoHandling: 0 427 | switchReleaseVersion: 0 428 | switchDisplayVersion: 1.0.0 429 | switchStartupUserAccount: 0 430 | switchTouchScreenUsage: 0 431 | switchSupportedLanguagesMask: 0 432 | switchLogoType: 0 433 | switchApplicationErrorCodeCategory: 434 | switchUserAccountSaveDataSize: 0 435 | switchUserAccountSaveDataJournalSize: 0 436 | switchApplicationAttribute: 0 437 | switchCardSpecSize: -1 438 | switchCardSpecClock: -1 439 | switchRatingsMask: 0 440 | switchRatingsInt_0: 0 441 | switchRatingsInt_1: 0 442 | switchRatingsInt_2: 0 443 | switchRatingsInt_3: 0 444 | switchRatingsInt_4: 0 445 | switchRatingsInt_5: 0 446 | switchRatingsInt_6: 0 447 | switchRatingsInt_7: 0 448 | switchRatingsInt_8: 0 449 | switchRatingsInt_9: 0 450 | switchRatingsInt_10: 0 451 | switchRatingsInt_11: 0 452 | switchRatingsInt_12: 0 453 | switchLocalCommunicationIds_0: 454 | switchLocalCommunicationIds_1: 455 | switchLocalCommunicationIds_2: 456 | switchLocalCommunicationIds_3: 457 | switchLocalCommunicationIds_4: 458 | switchLocalCommunicationIds_5: 459 | switchLocalCommunicationIds_6: 460 | switchLocalCommunicationIds_7: 461 | switchParentalControl: 0 462 | switchAllowsScreenshot: 1 463 | switchAllowsVideoCapturing: 1 464 | switchAllowsRuntimeAddOnContentInstall: 0 465 | switchDataLossConfirmation: 0 466 | switchUserAccountLockEnabled: 0 467 | switchSystemResourceMemory: 16777216 468 | switchSupportedNpadStyles: 22 469 | switchNativeFsCacheSize: 32 470 | switchIsHoldTypeHorizontal: 0 471 | switchSupportedNpadCount: 8 472 | switchSocketConfigEnabled: 0 473 | switchTcpInitialSendBufferSize: 32 474 | switchTcpInitialReceiveBufferSize: 64 475 | switchTcpAutoSendBufferSizeMax: 256 476 | switchTcpAutoReceiveBufferSizeMax: 256 477 | switchUdpSendBufferSize: 9 478 | switchUdpReceiveBufferSize: 42 479 | switchSocketBufferEfficiency: 4 480 | switchSocketInitializeEnabled: 1 481 | switchNetworkInterfaceManagerInitializeEnabled: 1 482 | switchPlayerConnectionEnabled: 1 483 | ps4NPAgeRating: 12 484 | ps4NPTitleSecret: 485 | ps4NPTrophyPackPath: 486 | ps4ParentalLevel: 11 487 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 488 | ps4Category: 0 489 | ps4MasterVersion: 01.00 490 | ps4AppVersion: 01.00 491 | ps4AppType: 0 492 | ps4ParamSfxPath: 493 | ps4VideoOutPixelFormat: 0 494 | ps4VideoOutInitialWidth: 1920 495 | ps4VideoOutBaseModeInitialWidth: 1920 496 | ps4VideoOutReprojectionRate: 60 497 | ps4PronunciationXMLPath: 498 | ps4PronunciationSIGPath: 499 | ps4BackgroundImagePath: 500 | ps4StartupImagePath: 501 | ps4StartupImagesFolder: 502 | ps4IconImagesFolder: 503 | ps4SaveDataImagePath: 504 | ps4SdkOverride: 505 | ps4BGMPath: 506 | ps4ShareFilePath: 507 | ps4ShareOverlayImagePath: 508 | ps4PrivacyGuardImagePath: 509 | ps4ExtraSceSysFile: 510 | ps4NPtitleDatPath: 511 | ps4RemotePlayKeyAssignment: -1 512 | ps4RemotePlayKeyMappingDir: 513 | ps4PlayTogetherPlayerCount: 0 514 | ps4EnterButtonAssignment: 1 515 | ps4ApplicationParam1: 0 516 | ps4ApplicationParam2: 0 517 | ps4ApplicationParam3: 0 518 | ps4ApplicationParam4: 0 519 | ps4DownloadDataSize: 0 520 | ps4GarlicHeapSize: 2048 521 | ps4ProGarlicHeapSize: 2560 522 | playerPrefsMaxSize: 32768 523 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ 524 | ps4pnSessions: 1 525 | ps4pnPresence: 1 526 | ps4pnFriends: 1 527 | ps4pnGameCustomData: 1 528 | playerPrefsSupport: 0 529 | enableApplicationExit: 0 530 | resetTempFolder: 1 531 | restrictedAudioUsageRights: 0 532 | ps4UseResolutionFallback: 0 533 | ps4ReprojectionSupport: 0 534 | ps4UseAudio3dBackend: 0 535 | ps4UseLowGarlicFragmentationMode: 1 536 | ps4SocialScreenEnabled: 0 537 | ps4ScriptOptimizationLevel: 0 538 | ps4Audio3dVirtualSpeakerCount: 14 539 | ps4attribCpuUsage: 0 540 | ps4PatchPkgPath: 541 | ps4PatchLatestPkgPath: 542 | ps4PatchChangeinfoPath: 543 | ps4PatchDayOne: 0 544 | ps4attribUserManagement: 0 545 | ps4attribMoveSupport: 0 546 | ps4attrib3DSupport: 0 547 | ps4attribShareSupport: 0 548 | ps4attribExclusiveVR: 0 549 | ps4disableAutoHideSplash: 0 550 | ps4videoRecordingFeaturesUsed: 0 551 | ps4contentSearchFeaturesUsed: 0 552 | ps4CompatibilityPS5: 0 553 | ps4GPU800MHz: 1 554 | ps4attribEyeToEyeDistanceSettingVR: 0 555 | ps4IncludedModules: [] 556 | ps4attribVROutputEnabled: 0 557 | monoEnv: 558 | splashScreenBackgroundSourceLandscape: {fileID: 0} 559 | splashScreenBackgroundSourcePortrait: {fileID: 0} 560 | blurSplashScreenBackground: 1 561 | spritePackerPolicy: 562 | webGLMemorySize: 16 563 | webGLExceptionSupport: 1 564 | webGLNameFilesAsHashes: 0 565 | webGLDataCaching: 1 566 | webGLDebugSymbols: 0 567 | webGLEmscriptenArgs: 568 | webGLModulesDirectory: 569 | webGLTemplate: APPLICATION:Default 570 | webGLAnalyzeBuildSize: 0 571 | webGLUseEmbeddedResources: 0 572 | webGLCompressionFormat: 1 573 | webGLLinkerTarget: 1 574 | webGLThreadsSupport: 0 575 | webGLWasmStreaming: 0 576 | scriptingDefineSymbols: {} 577 | platformArchitecture: {} 578 | scriptingBackend: {} 579 | il2cppCompilerConfiguration: {} 580 | managedStrippingLevel: {} 581 | incrementalIl2cppBuild: {} 582 | allowUnsafeCode: 0 583 | additionalIl2CppArgs: 584 | scriptingRuntimeVersion: 1 585 | gcIncremental: 0 586 | gcWBarrierValidation: 0 587 | apiCompatibilityLevelPerPlatform: {} 588 | m_RenderingPath: 1 589 | m_MobileRenderingPath: 1 590 | metroPackageName: Template_3D 591 | metroPackageVersion: 592 | metroCertificatePath: 593 | metroCertificatePassword: 594 | metroCertificateSubject: 595 | metroCertificateIssuer: 596 | metroCertificateNotAfter: 0000000000000000 597 | metroApplicationDescription: Template_3D 598 | wsaImages: {} 599 | metroTileShortName: 600 | metroTileShowName: 0 601 | metroMediumTileShowName: 0 602 | metroLargeTileShowName: 0 603 | metroWideTileShowName: 0 604 | metroSupportStreamingInstall: 0 605 | metroLastRequiredScene: 0 606 | metroDefaultTileSize: 1 607 | metroTileForegroundText: 2 608 | metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} 609 | metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, 610 | a: 1} 611 | metroSplashScreenUseBackgroundColor: 0 612 | platformCapabilities: {} 613 | metroTargetDeviceFamilies: {} 614 | metroFTAName: 615 | metroFTAFileTypes: [] 616 | metroProtocolName: 617 | XboxOneProductId: 618 | XboxOneUpdateKey: 619 | XboxOneSandboxId: 620 | XboxOneContentId: 621 | XboxOneTitleId: 622 | XboxOneSCId: 623 | XboxOneGameOsOverridePath: 624 | XboxOnePackagingOverridePath: 625 | XboxOneAppManifestOverridePath: 626 | XboxOneVersion: 1.0.0.0 627 | XboxOnePackageEncryption: 0 628 | XboxOnePackageUpdateGranularity: 2 629 | XboxOneDescription: 630 | XboxOneLanguage: 631 | - enus 632 | XboxOneCapability: [] 633 | XboxOneGameRating: {} 634 | XboxOneIsContentPackage: 0 635 | XboxOneEnableGPUVariability: 1 636 | XboxOneSockets: {} 637 | XboxOneSplashScreen: {fileID: 0} 638 | XboxOneAllowedProductIds: [] 639 | XboxOnePersistentLocalStorageSize: 0 640 | XboxOneXTitleMemory: 8 641 | XboxOneOverrideIdentityName: 642 | XboxOneOverrideIdentityPublisher: 643 | vrEditorSettings: 644 | daydream: 645 | daydreamIconForeground: {fileID: 0} 646 | daydreamIconBackground: {fileID: 0} 647 | cloudServicesEnabled: 648 | UNet: 1 649 | luminIcon: 650 | m_Name: 651 | m_ModelFolderPath: 652 | m_PortalFolderPath: 653 | luminCert: 654 | m_CertPath: 655 | m_SignPackage: 1 656 | luminIsChannelApp: 0 657 | luminVersion: 658 | m_VersionCode: 1 659 | m_VersionName: 660 | apiCompatibilityLevel: 6 661 | cloudProjectId: 662 | framebufferDepthMemorylessMode: 0 663 | projectName: 664 | organizationId: 665 | cloudEnabled: 0 666 | enableNativePlatformBackendsForNewInputSystem: 0 667 | disableOldInputManagerSupport: 0 668 | legacyClampBlendShapeWeights: 0 669 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/Lexer.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * Lexer.cs 4 | * JSON lexer implementation based on a finite state machine. 5 | * 6 | * The authors disclaim copyright to this source code. For more details, see 7 | * the COPYING file included with this distribution. 8 | **/ 9 | #endregion 10 | 11 | 12 | using System; 13 | using System.Collections.Generic; 14 | using System.IO; 15 | using System.Text; 16 | 17 | 18 | namespace LitJson 19 | { 20 | internal class FsmContext 21 | { 22 | public bool Return; 23 | public int NextState; 24 | public Lexer L; 25 | public int StateStack; 26 | } 27 | 28 | 29 | internal class Lexer 30 | { 31 | #region Fields 32 | private delegate bool StateHandler (FsmContext ctx); 33 | 34 | private static readonly int[] fsm_return_table; 35 | private static readonly StateHandler[] fsm_handler_table; 36 | 37 | private bool allow_comments; 38 | private bool allow_single_quoted_strings; 39 | private bool end_of_input; 40 | private FsmContext fsm_context; 41 | private int input_buffer; 42 | private int input_char; 43 | private TextReader reader; 44 | private int state; 45 | private StringBuilder string_buffer; 46 | private string string_value; 47 | private int token; 48 | private int unichar; 49 | #endregion 50 | 51 | 52 | #region Properties 53 | public bool AllowComments { 54 | get { return allow_comments; } 55 | set { allow_comments = value; } 56 | } 57 | 58 | public bool AllowSingleQuotedStrings { 59 | get { return allow_single_quoted_strings; } 60 | set { allow_single_quoted_strings = value; } 61 | } 62 | 63 | public bool EndOfInput { 64 | get { return end_of_input; } 65 | } 66 | 67 | public int Token { 68 | get { return token; } 69 | } 70 | 71 | public string StringValue { 72 | get { return string_value; } 73 | } 74 | #endregion 75 | 76 | 77 | #region Constructors 78 | static Lexer () 79 | { 80 | PopulateFsmTables (out fsm_handler_table, out fsm_return_table); 81 | } 82 | 83 | public Lexer (TextReader reader) 84 | { 85 | allow_comments = true; 86 | allow_single_quoted_strings = true; 87 | 88 | input_buffer = 0; 89 | string_buffer = new StringBuilder (128); 90 | state = 1; 91 | end_of_input = false; 92 | this.reader = reader; 93 | 94 | fsm_context = new FsmContext (); 95 | fsm_context.L = this; 96 | } 97 | #endregion 98 | 99 | 100 | #region Static Methods 101 | private static int HexValue (int digit) 102 | { 103 | switch (digit) { 104 | case 'a': 105 | case 'A': 106 | return 10; 107 | 108 | case 'b': 109 | case 'B': 110 | return 11; 111 | 112 | case 'c': 113 | case 'C': 114 | return 12; 115 | 116 | case 'd': 117 | case 'D': 118 | return 13; 119 | 120 | case 'e': 121 | case 'E': 122 | return 14; 123 | 124 | case 'f': 125 | case 'F': 126 | return 15; 127 | 128 | default: 129 | return digit - '0'; 130 | } 131 | } 132 | 133 | private static void PopulateFsmTables (out StateHandler[] fsm_handler_table, out int[] fsm_return_table) 134 | { 135 | // See section A.1. of the manual for details of the finite 136 | // state machine. 137 | fsm_handler_table = new StateHandler[28] { 138 | State1, 139 | State2, 140 | State3, 141 | State4, 142 | State5, 143 | State6, 144 | State7, 145 | State8, 146 | State9, 147 | State10, 148 | State11, 149 | State12, 150 | State13, 151 | State14, 152 | State15, 153 | State16, 154 | State17, 155 | State18, 156 | State19, 157 | State20, 158 | State21, 159 | State22, 160 | State23, 161 | State24, 162 | State25, 163 | State26, 164 | State27, 165 | State28 166 | }; 167 | 168 | fsm_return_table = new int[28] { 169 | (int) ParserToken.Char, 170 | 0, 171 | (int) ParserToken.Number, 172 | (int) ParserToken.Number, 173 | 0, 174 | (int) ParserToken.Number, 175 | 0, 176 | (int) ParserToken.Number, 177 | 0, 178 | 0, 179 | (int) ParserToken.True, 180 | 0, 181 | 0, 182 | 0, 183 | (int) ParserToken.False, 184 | 0, 185 | 0, 186 | (int) ParserToken.Null, 187 | (int) ParserToken.CharSeq, 188 | (int) ParserToken.Char, 189 | 0, 190 | 0, 191 | (int) ParserToken.CharSeq, 192 | (int) ParserToken.Char, 193 | 0, 194 | 0, 195 | 0, 196 | 0 197 | }; 198 | } 199 | 200 | private static char ProcessEscChar (int esc_char) 201 | { 202 | switch (esc_char) { 203 | case '"': 204 | case '\'': 205 | case '\\': 206 | case '/': 207 | return Convert.ToChar (esc_char); 208 | 209 | case 'n': 210 | return '\n'; 211 | 212 | case 't': 213 | return '\t'; 214 | 215 | case 'r': 216 | return '\r'; 217 | 218 | case 'b': 219 | return '\b'; 220 | 221 | case 'f': 222 | return '\f'; 223 | 224 | default: 225 | // Unreachable 226 | return '?'; 227 | } 228 | } 229 | 230 | private static bool State1 (FsmContext ctx) 231 | { 232 | while (ctx.L.GetChar ()) { 233 | if (ctx.L.input_char == ' ' || 234 | ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') 235 | continue; 236 | 237 | if (ctx.L.input_char >= '1' && ctx.L.input_char <= '9') { 238 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 239 | ctx.NextState = 3; 240 | return true; 241 | } 242 | 243 | switch (ctx.L.input_char) { 244 | case '"': 245 | ctx.NextState = 19; 246 | ctx.Return = true; 247 | return true; 248 | 249 | case ',': 250 | case ':': 251 | case '[': 252 | case ']': 253 | case '{': 254 | case '}': 255 | ctx.NextState = 1; 256 | ctx.Return = true; 257 | return true; 258 | 259 | case '-': 260 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 261 | ctx.NextState = 2; 262 | return true; 263 | 264 | case '0': 265 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 266 | ctx.NextState = 4; 267 | return true; 268 | 269 | case 'f': 270 | ctx.NextState = 12; 271 | return true; 272 | 273 | case 'n': 274 | ctx.NextState = 16; 275 | return true; 276 | 277 | case 't': 278 | ctx.NextState = 9; 279 | return true; 280 | 281 | case '\'': 282 | if (! ctx.L.allow_single_quoted_strings) 283 | return false; 284 | 285 | ctx.L.input_char = '"'; 286 | ctx.NextState = 23; 287 | ctx.Return = true; 288 | return true; 289 | 290 | case '/': 291 | if (! ctx.L.allow_comments) 292 | return false; 293 | 294 | ctx.NextState = 25; 295 | return true; 296 | 297 | default: 298 | return false; 299 | } 300 | } 301 | 302 | return true; 303 | } 304 | 305 | private static bool State2 (FsmContext ctx) 306 | { 307 | ctx.L.GetChar (); 308 | 309 | if (ctx.L.input_char >= '1' && ctx.L.input_char<= '9') { 310 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 311 | ctx.NextState = 3; 312 | return true; 313 | } 314 | 315 | switch (ctx.L.input_char) { 316 | case '0': 317 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 318 | ctx.NextState = 4; 319 | return true; 320 | 321 | default: 322 | return false; 323 | } 324 | } 325 | 326 | private static bool State3 (FsmContext ctx) 327 | { 328 | while (ctx.L.GetChar ()) { 329 | if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { 330 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 331 | continue; 332 | } 333 | 334 | if (ctx.L.input_char == ' ' || 335 | ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { 336 | ctx.Return = true; 337 | ctx.NextState = 1; 338 | return true; 339 | } 340 | 341 | switch (ctx.L.input_char) { 342 | case ',': 343 | case ']': 344 | case '}': 345 | ctx.L.UngetChar (); 346 | ctx.Return = true; 347 | ctx.NextState = 1; 348 | return true; 349 | 350 | case '.': 351 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 352 | ctx.NextState = 5; 353 | return true; 354 | 355 | case 'e': 356 | case 'E': 357 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 358 | ctx.NextState = 7; 359 | return true; 360 | 361 | default: 362 | return false; 363 | } 364 | } 365 | return true; 366 | } 367 | 368 | private static bool State4 (FsmContext ctx) 369 | { 370 | ctx.L.GetChar (); 371 | 372 | if (ctx.L.input_char == ' ' || 373 | ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { 374 | ctx.Return = true; 375 | ctx.NextState = 1; 376 | return true; 377 | } 378 | 379 | switch (ctx.L.input_char) { 380 | case ',': 381 | case ']': 382 | case '}': 383 | ctx.L.UngetChar (); 384 | ctx.Return = true; 385 | ctx.NextState = 1; 386 | return true; 387 | 388 | case '.': 389 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 390 | ctx.NextState = 5; 391 | return true; 392 | 393 | case 'e': 394 | case 'E': 395 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 396 | ctx.NextState = 7; 397 | return true; 398 | 399 | default: 400 | return false; 401 | } 402 | } 403 | 404 | private static bool State5 (FsmContext ctx) 405 | { 406 | ctx.L.GetChar (); 407 | 408 | if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { 409 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 410 | ctx.NextState = 6; 411 | return true; 412 | } 413 | 414 | return false; 415 | } 416 | 417 | private static bool State6 (FsmContext ctx) 418 | { 419 | while (ctx.L.GetChar ()) { 420 | if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9') { 421 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 422 | continue; 423 | } 424 | 425 | if (ctx.L.input_char == ' ' || 426 | ctx.L.input_char >= '\t' && ctx.L.input_char <= '\r') { 427 | ctx.Return = true; 428 | ctx.NextState = 1; 429 | return true; 430 | } 431 | 432 | switch (ctx.L.input_char) { 433 | case ',': 434 | case ']': 435 | case '}': 436 | ctx.L.UngetChar (); 437 | ctx.Return = true; 438 | ctx.NextState = 1; 439 | return true; 440 | 441 | case 'e': 442 | case 'E': 443 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 444 | ctx.NextState = 7; 445 | return true; 446 | 447 | default: 448 | return false; 449 | } 450 | } 451 | 452 | return true; 453 | } 454 | 455 | private static bool State7 (FsmContext ctx) 456 | { 457 | ctx.L.GetChar (); 458 | 459 | if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') { 460 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 461 | ctx.NextState = 8; 462 | return true; 463 | } 464 | 465 | switch (ctx.L.input_char) { 466 | case '+': 467 | case '-': 468 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 469 | ctx.NextState = 8; 470 | return true; 471 | 472 | default: 473 | return false; 474 | } 475 | } 476 | 477 | private static bool State8 (FsmContext ctx) 478 | { 479 | while (ctx.L.GetChar ()) { 480 | if (ctx.L.input_char >= '0' && ctx.L.input_char<= '9') { 481 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 482 | continue; 483 | } 484 | 485 | if (ctx.L.input_char == ' ' || 486 | ctx.L.input_char >= '\t' && ctx.L.input_char<= '\r') { 487 | ctx.Return = true; 488 | ctx.NextState = 1; 489 | return true; 490 | } 491 | 492 | switch (ctx.L.input_char) { 493 | case ',': 494 | case ']': 495 | case '}': 496 | ctx.L.UngetChar (); 497 | ctx.Return = true; 498 | ctx.NextState = 1; 499 | return true; 500 | 501 | default: 502 | return false; 503 | } 504 | } 505 | 506 | return true; 507 | } 508 | 509 | private static bool State9 (FsmContext ctx) 510 | { 511 | ctx.L.GetChar (); 512 | 513 | switch (ctx.L.input_char) { 514 | case 'r': 515 | ctx.NextState = 10; 516 | return true; 517 | 518 | default: 519 | return false; 520 | } 521 | } 522 | 523 | private static bool State10 (FsmContext ctx) 524 | { 525 | ctx.L.GetChar (); 526 | 527 | switch (ctx.L.input_char) { 528 | case 'u': 529 | ctx.NextState = 11; 530 | return true; 531 | 532 | default: 533 | return false; 534 | } 535 | } 536 | 537 | private static bool State11 (FsmContext ctx) 538 | { 539 | ctx.L.GetChar (); 540 | 541 | switch (ctx.L.input_char) { 542 | case 'e': 543 | ctx.Return = true; 544 | ctx.NextState = 1; 545 | return true; 546 | 547 | default: 548 | return false; 549 | } 550 | } 551 | 552 | private static bool State12 (FsmContext ctx) 553 | { 554 | ctx.L.GetChar (); 555 | 556 | switch (ctx.L.input_char) { 557 | case 'a': 558 | ctx.NextState = 13; 559 | return true; 560 | 561 | default: 562 | return false; 563 | } 564 | } 565 | 566 | private static bool State13 (FsmContext ctx) 567 | { 568 | ctx.L.GetChar (); 569 | 570 | switch (ctx.L.input_char) { 571 | case 'l': 572 | ctx.NextState = 14; 573 | return true; 574 | 575 | default: 576 | return false; 577 | } 578 | } 579 | 580 | private static bool State14 (FsmContext ctx) 581 | { 582 | ctx.L.GetChar (); 583 | 584 | switch (ctx.L.input_char) { 585 | case 's': 586 | ctx.NextState = 15; 587 | return true; 588 | 589 | default: 590 | return false; 591 | } 592 | } 593 | 594 | private static bool State15 (FsmContext ctx) 595 | { 596 | ctx.L.GetChar (); 597 | 598 | switch (ctx.L.input_char) { 599 | case 'e': 600 | ctx.Return = true; 601 | ctx.NextState = 1; 602 | return true; 603 | 604 | default: 605 | return false; 606 | } 607 | } 608 | 609 | private static bool State16 (FsmContext ctx) 610 | { 611 | ctx.L.GetChar (); 612 | 613 | switch (ctx.L.input_char) { 614 | case 'u': 615 | ctx.NextState = 17; 616 | return true; 617 | 618 | default: 619 | return false; 620 | } 621 | } 622 | 623 | private static bool State17 (FsmContext ctx) 624 | { 625 | ctx.L.GetChar (); 626 | 627 | switch (ctx.L.input_char) { 628 | case 'l': 629 | ctx.NextState = 18; 630 | return true; 631 | 632 | default: 633 | return false; 634 | } 635 | } 636 | 637 | private static bool State18 (FsmContext ctx) 638 | { 639 | ctx.L.GetChar (); 640 | 641 | switch (ctx.L.input_char) { 642 | case 'l': 643 | ctx.Return = true; 644 | ctx.NextState = 1; 645 | return true; 646 | 647 | default: 648 | return false; 649 | } 650 | } 651 | 652 | private static bool State19 (FsmContext ctx) 653 | { 654 | while (ctx.L.GetChar ()) { 655 | switch (ctx.L.input_char) { 656 | case '"': 657 | ctx.L.UngetChar (); 658 | ctx.Return = true; 659 | ctx.NextState = 20; 660 | return true; 661 | 662 | case '\\': 663 | ctx.StateStack = 19; 664 | ctx.NextState = 21; 665 | return true; 666 | 667 | default: 668 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 669 | continue; 670 | } 671 | } 672 | 673 | return true; 674 | } 675 | 676 | private static bool State20 (FsmContext ctx) 677 | { 678 | ctx.L.GetChar (); 679 | 680 | switch (ctx.L.input_char) { 681 | case '"': 682 | ctx.Return = true; 683 | ctx.NextState = 1; 684 | return true; 685 | 686 | default: 687 | return false; 688 | } 689 | } 690 | 691 | private static bool State21 (FsmContext ctx) 692 | { 693 | ctx.L.GetChar (); 694 | 695 | switch (ctx.L.input_char) { 696 | case 'u': 697 | ctx.NextState = 22; 698 | return true; 699 | 700 | case '"': 701 | case '\'': 702 | case '/': 703 | case '\\': 704 | case 'b': 705 | case 'f': 706 | case 'n': 707 | case 'r': 708 | case 't': 709 | ctx.L.string_buffer.Append ( 710 | ProcessEscChar (ctx.L.input_char)); 711 | ctx.NextState = ctx.StateStack; 712 | return true; 713 | 714 | default: 715 | return false; 716 | } 717 | } 718 | 719 | private static bool State22 (FsmContext ctx) 720 | { 721 | int counter = 0; 722 | int mult = 4096; 723 | 724 | ctx.L.unichar = 0; 725 | 726 | while (ctx.L.GetChar ()) { 727 | 728 | if (ctx.L.input_char >= '0' && ctx.L.input_char <= '9' || 729 | ctx.L.input_char >= 'A' && ctx.L.input_char <= 'F' || 730 | ctx.L.input_char >= 'a' && ctx.L.input_char <= 'f') { 731 | 732 | ctx.L.unichar += HexValue (ctx.L.input_char) * mult; 733 | 734 | counter++; 735 | mult /= 16; 736 | 737 | if (counter == 4) { 738 | ctx.L.string_buffer.Append ( 739 | Convert.ToChar (ctx.L.unichar)); 740 | ctx.NextState = ctx.StateStack; 741 | return true; 742 | } 743 | 744 | continue; 745 | } 746 | 747 | return false; 748 | } 749 | 750 | return true; 751 | } 752 | 753 | private static bool State23 (FsmContext ctx) 754 | { 755 | while (ctx.L.GetChar ()) { 756 | switch (ctx.L.input_char) { 757 | case '\'': 758 | ctx.L.UngetChar (); 759 | ctx.Return = true; 760 | ctx.NextState = 24; 761 | return true; 762 | 763 | case '\\': 764 | ctx.StateStack = 23; 765 | ctx.NextState = 21; 766 | return true; 767 | 768 | default: 769 | ctx.L.string_buffer.Append ((char) ctx.L.input_char); 770 | continue; 771 | } 772 | } 773 | 774 | return true; 775 | } 776 | 777 | private static bool State24 (FsmContext ctx) 778 | { 779 | ctx.L.GetChar (); 780 | 781 | switch (ctx.L.input_char) { 782 | case '\'': 783 | ctx.L.input_char = '"'; 784 | ctx.Return = true; 785 | ctx.NextState = 1; 786 | return true; 787 | 788 | default: 789 | return false; 790 | } 791 | } 792 | 793 | private static bool State25 (FsmContext ctx) 794 | { 795 | ctx.L.GetChar (); 796 | 797 | switch (ctx.L.input_char) { 798 | case '*': 799 | ctx.NextState = 27; 800 | return true; 801 | 802 | case '/': 803 | ctx.NextState = 26; 804 | return true; 805 | 806 | default: 807 | return false; 808 | } 809 | } 810 | 811 | private static bool State26 (FsmContext ctx) 812 | { 813 | while (ctx.L.GetChar ()) { 814 | if (ctx.L.input_char == '\n') { 815 | ctx.NextState = 1; 816 | return true; 817 | } 818 | } 819 | 820 | return true; 821 | } 822 | 823 | private static bool State27 (FsmContext ctx) 824 | { 825 | while (ctx.L.GetChar ()) { 826 | if (ctx.L.input_char == '*') { 827 | ctx.NextState = 28; 828 | return true; 829 | } 830 | } 831 | 832 | return true; 833 | } 834 | 835 | private static bool State28 (FsmContext ctx) 836 | { 837 | while (ctx.L.GetChar ()) { 838 | if (ctx.L.input_char == '*') 839 | continue; 840 | 841 | if (ctx.L.input_char == '/') { 842 | ctx.NextState = 1; 843 | return true; 844 | } 845 | 846 | ctx.NextState = 27; 847 | return true; 848 | } 849 | 850 | return true; 851 | } 852 | #endregion 853 | 854 | 855 | private bool GetChar () 856 | { 857 | if ((input_char = NextChar ()) != -1) 858 | return true; 859 | 860 | end_of_input = true; 861 | return false; 862 | } 863 | 864 | private int NextChar () 865 | { 866 | if (input_buffer != 0) { 867 | int tmp = input_buffer; 868 | input_buffer = 0; 869 | 870 | return tmp; 871 | } 872 | 873 | return reader.Read (); 874 | } 875 | 876 | public bool NextToken () 877 | { 878 | StateHandler handler; 879 | fsm_context.Return = false; 880 | 881 | while (true) { 882 | handler = fsm_handler_table[state - 1]; 883 | 884 | if (! handler (fsm_context)) 885 | throw new JsonException (input_char); 886 | 887 | if (end_of_input) 888 | return false; 889 | 890 | if (fsm_context.Return) { 891 | string_value = string_buffer.ToString (); 892 | string_buffer.Remove (0, string_buffer.Length); 893 | token = fsm_return_table[state - 1]; 894 | 895 | if (token == (int) ParserToken.Char) 896 | token = input_char; 897 | 898 | state = fsm_context.NextState; 899 | 900 | return true; 901 | } 902 | 903 | state = fsm_context.NextState; 904 | } 905 | } 906 | 907 | private void UngetChar () 908 | { 909 | input_buffer = input_char; 910 | } 911 | } 912 | } 913 | -------------------------------------------------------------------------------- /TinyGameSaveSystem/Assets/LitJson/JsonData.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * JsonData.cs 4 | * Generic type to hold JSON data (objects, arrays, and so on). This is 5 | * the default type returned by JsonMapper.ToObject(). 6 | * 7 | * The authors disclaim copyright to this source code. For more details, see 8 | * the COPYING file included with this distribution. 9 | **/ 10 | #endregion 11 | 12 | 13 | using System; 14 | using System.Collections; 15 | using System.Collections.Generic; 16 | using System.Collections.Specialized; 17 | using System.IO; 18 | 19 | 20 | namespace LitJson 21 | { 22 | public class JsonData : IJsonWrapper, IEquatable 23 | { 24 | #region Fields 25 | private IList inst_array; 26 | private bool inst_boolean; 27 | private double inst_double; 28 | private int inst_int; 29 | private long inst_long; 30 | private IDictionary inst_object; 31 | private string inst_string; 32 | private string json; 33 | private JsonType type; 34 | 35 | // Used to implement the IOrderedDictionary interface 36 | private IList> object_list; 37 | #endregion 38 | 39 | 40 | #region Properties 41 | public int Count { 42 | get { return EnsureCollection ().Count; } 43 | } 44 | 45 | public bool IsArray { 46 | get { return type == JsonType.Array; } 47 | } 48 | 49 | public bool IsBoolean { 50 | get { return type == JsonType.Boolean; } 51 | } 52 | 53 | public bool IsDouble { 54 | get { return type == JsonType.Double; } 55 | } 56 | 57 | public bool IsInt { 58 | get { return type == JsonType.Int; } 59 | } 60 | 61 | public bool IsLong { 62 | get { return type == JsonType.Long; } 63 | } 64 | 65 | public bool IsObject { 66 | get { return type == JsonType.Object; } 67 | } 68 | 69 | public bool IsString { 70 | get { return type == JsonType.String; } 71 | } 72 | 73 | public ICollection Keys { 74 | get { EnsureDictionary (); return inst_object.Keys; } 75 | } 76 | 77 | /// 78 | /// Determines whether the json contains an element that has the specified key. 79 | /// 80 | /// The key to locate in the json. 81 | /// true if the json contains an element that has the specified key; otherwise, false. 82 | public Boolean ContainsKey(String key) { 83 | EnsureDictionary(); 84 | return this.inst_object.Keys.Contains(key); 85 | } 86 | #endregion 87 | 88 | 89 | #region ICollection Properties 90 | int ICollection.Count { 91 | get { 92 | return Count; 93 | } 94 | } 95 | 96 | bool ICollection.IsSynchronized { 97 | get { 98 | return EnsureCollection ().IsSynchronized; 99 | } 100 | } 101 | 102 | object ICollection.SyncRoot { 103 | get { 104 | return EnsureCollection ().SyncRoot; 105 | } 106 | } 107 | #endregion 108 | 109 | 110 | #region IDictionary Properties 111 | bool IDictionary.IsFixedSize { 112 | get { 113 | return EnsureDictionary ().IsFixedSize; 114 | } 115 | } 116 | 117 | bool IDictionary.IsReadOnly { 118 | get { 119 | return EnsureDictionary ().IsReadOnly; 120 | } 121 | } 122 | 123 | ICollection IDictionary.Keys { 124 | get { 125 | EnsureDictionary (); 126 | IList keys = new List (); 127 | 128 | foreach (KeyValuePair entry in 129 | object_list) { 130 | keys.Add (entry.Key); 131 | } 132 | 133 | return (ICollection) keys; 134 | } 135 | } 136 | 137 | ICollection IDictionary.Values { 138 | get { 139 | EnsureDictionary (); 140 | IList values = new List (); 141 | 142 | foreach (KeyValuePair entry in 143 | object_list) { 144 | values.Add (entry.Value); 145 | } 146 | 147 | return (ICollection) values; 148 | } 149 | } 150 | #endregion 151 | 152 | 153 | 154 | #region IJsonWrapper Properties 155 | bool IJsonWrapper.IsArray { 156 | get { return IsArray; } 157 | } 158 | 159 | bool IJsonWrapper.IsBoolean { 160 | get { return IsBoolean; } 161 | } 162 | 163 | bool IJsonWrapper.IsDouble { 164 | get { return IsDouble; } 165 | } 166 | 167 | bool IJsonWrapper.IsInt { 168 | get { return IsInt; } 169 | } 170 | 171 | bool IJsonWrapper.IsLong { 172 | get { return IsLong; } 173 | } 174 | 175 | bool IJsonWrapper.IsObject { 176 | get { return IsObject; } 177 | } 178 | 179 | bool IJsonWrapper.IsString { 180 | get { return IsString; } 181 | } 182 | #endregion 183 | 184 | 185 | #region IList Properties 186 | bool IList.IsFixedSize { 187 | get { 188 | return EnsureList ().IsFixedSize; 189 | } 190 | } 191 | 192 | bool IList.IsReadOnly { 193 | get { 194 | return EnsureList ().IsReadOnly; 195 | } 196 | } 197 | #endregion 198 | 199 | 200 | #region IDictionary Indexer 201 | object IDictionary.this[object key] { 202 | get { 203 | return EnsureDictionary ()[key]; 204 | } 205 | 206 | set { 207 | if (! (key is String)) 208 | throw new ArgumentException ( 209 | "The key has to be a string"); 210 | 211 | JsonData data = ToJsonData (value); 212 | 213 | this[(string) key] = data; 214 | } 215 | } 216 | #endregion 217 | 218 | 219 | #region IOrderedDictionary Indexer 220 | object IOrderedDictionary.this[int idx] { 221 | get { 222 | EnsureDictionary (); 223 | return object_list[idx].Value; 224 | } 225 | 226 | set { 227 | EnsureDictionary (); 228 | JsonData data = ToJsonData (value); 229 | 230 | KeyValuePair old_entry = object_list[idx]; 231 | 232 | inst_object[old_entry.Key] = data; 233 | 234 | KeyValuePair entry = 235 | new KeyValuePair (old_entry.Key, data); 236 | 237 | object_list[idx] = entry; 238 | } 239 | } 240 | #endregion 241 | 242 | 243 | #region IList Indexer 244 | object IList.this[int index] { 245 | get { 246 | return EnsureList ()[index]; 247 | } 248 | 249 | set { 250 | EnsureList (); 251 | JsonData data = ToJsonData (value); 252 | 253 | this[index] = data; 254 | } 255 | } 256 | #endregion 257 | 258 | 259 | #region Public Indexers 260 | public JsonData this[string prop_name] { 261 | get { 262 | EnsureDictionary (); 263 | return inst_object[prop_name]; 264 | } 265 | 266 | set { 267 | EnsureDictionary (); 268 | 269 | KeyValuePair entry = 270 | new KeyValuePair (prop_name, value); 271 | 272 | if (inst_object.ContainsKey (prop_name)) { 273 | for (int i = 0; i < object_list.Count; i++) { 274 | if (object_list[i].Key == prop_name) { 275 | object_list[i] = entry; 276 | break; 277 | } 278 | } 279 | } else 280 | object_list.Add (entry); 281 | 282 | inst_object[prop_name] = value; 283 | 284 | json = null; 285 | } 286 | } 287 | 288 | public JsonData this[int index] { 289 | get { 290 | EnsureCollection (); 291 | 292 | if (type == JsonType.Array) 293 | return inst_array[index]; 294 | 295 | return object_list[index].Value; 296 | } 297 | 298 | set { 299 | EnsureCollection (); 300 | 301 | if (type == JsonType.Array) 302 | inst_array[index] = value; 303 | else { 304 | KeyValuePair entry = object_list[index]; 305 | KeyValuePair new_entry = 306 | new KeyValuePair (entry.Key, value); 307 | 308 | object_list[index] = new_entry; 309 | inst_object[entry.Key] = value; 310 | } 311 | 312 | json = null; 313 | } 314 | } 315 | #endregion 316 | 317 | 318 | #region Constructors 319 | public JsonData () 320 | { 321 | } 322 | 323 | public JsonData (bool boolean) 324 | { 325 | type = JsonType.Boolean; 326 | inst_boolean = boolean; 327 | } 328 | 329 | public JsonData (double number) 330 | { 331 | type = JsonType.Double; 332 | inst_double = number; 333 | } 334 | 335 | public JsonData (int number) 336 | { 337 | type = JsonType.Int; 338 | inst_int = number; 339 | } 340 | 341 | public JsonData (long number) 342 | { 343 | type = JsonType.Long; 344 | inst_long = number; 345 | } 346 | 347 | public JsonData (object obj) 348 | { 349 | if (obj is Boolean) { 350 | type = JsonType.Boolean; 351 | inst_boolean = (bool) obj; 352 | return; 353 | } 354 | 355 | if (obj is Double) { 356 | type = JsonType.Double; 357 | inst_double = (double) obj; 358 | return; 359 | } 360 | 361 | if (obj is Int32) { 362 | type = JsonType.Int; 363 | inst_int = (int) obj; 364 | return; 365 | } 366 | 367 | if (obj is Int64) { 368 | type = JsonType.Long; 369 | inst_long = (long) obj; 370 | return; 371 | } 372 | 373 | if (obj is String) { 374 | type = JsonType.String; 375 | inst_string = (string) obj; 376 | return; 377 | } 378 | 379 | throw new ArgumentException ( 380 | "Unable to wrap the given object with JsonData"); 381 | } 382 | 383 | public JsonData (string str) 384 | { 385 | type = JsonType.String; 386 | inst_string = str; 387 | } 388 | #endregion 389 | 390 | 391 | #region Implicit Conversions 392 | public static implicit operator JsonData (Boolean data) 393 | { 394 | return new JsonData (data); 395 | } 396 | 397 | public static implicit operator JsonData (Double data) 398 | { 399 | return new JsonData (data); 400 | } 401 | 402 | public static implicit operator JsonData (Int32 data) 403 | { 404 | return new JsonData (data); 405 | } 406 | 407 | public static implicit operator JsonData (Int64 data) 408 | { 409 | return new JsonData (data); 410 | } 411 | 412 | public static implicit operator JsonData (String data) 413 | { 414 | return new JsonData (data); 415 | } 416 | #endregion 417 | 418 | 419 | #region Explicit Conversions 420 | public static explicit operator Boolean (JsonData data) 421 | { 422 | if (data.type != JsonType.Boolean) 423 | throw new InvalidCastException ( 424 | "Instance of JsonData doesn't hold a double"); 425 | 426 | return data.inst_boolean; 427 | } 428 | 429 | public static explicit operator Double (JsonData data) 430 | { 431 | if (data.type != JsonType.Double) 432 | throw new InvalidCastException ( 433 | "Instance of JsonData doesn't hold a double"); 434 | 435 | return data.inst_double; 436 | } 437 | 438 | public static explicit operator Int32(JsonData data) 439 | { 440 | if (data.type != JsonType.Int && data.type != JsonType.Long) 441 | { 442 | throw new InvalidCastException( 443 | "Instance of JsonData doesn't hold an int"); 444 | } 445 | 446 | // cast may truncate data... but that's up to the user to consider 447 | return data.type == JsonType.Int ? data.inst_int : (int)data.inst_long; 448 | } 449 | 450 | public static explicit operator Int64(JsonData data) 451 | { 452 | if (data.type != JsonType.Long && data.type != JsonType.Int) 453 | { 454 | throw new InvalidCastException( 455 | "Instance of JsonData doesn't hold a long"); 456 | } 457 | 458 | return data.type == JsonType.Long ? data.inst_long : data.inst_int; 459 | } 460 | 461 | public static explicit operator String (JsonData data) 462 | { 463 | if (data.type != JsonType.String) 464 | throw new InvalidCastException ( 465 | "Instance of JsonData doesn't hold a string"); 466 | 467 | return data.inst_string; 468 | } 469 | #endregion 470 | 471 | 472 | #region ICollection Methods 473 | void ICollection.CopyTo (Array array, int index) 474 | { 475 | EnsureCollection ().CopyTo (array, index); 476 | } 477 | #endregion 478 | 479 | 480 | #region IDictionary Methods 481 | void IDictionary.Add (object key, object value) 482 | { 483 | JsonData data = ToJsonData (value); 484 | 485 | EnsureDictionary ().Add (key, data); 486 | 487 | KeyValuePair entry = 488 | new KeyValuePair ((string) key, data); 489 | object_list.Add (entry); 490 | 491 | json = null; 492 | } 493 | 494 | void IDictionary.Clear () 495 | { 496 | EnsureDictionary ().Clear (); 497 | object_list.Clear (); 498 | json = null; 499 | } 500 | 501 | bool IDictionary.Contains (object key) 502 | { 503 | return EnsureDictionary ().Contains (key); 504 | } 505 | 506 | IDictionaryEnumerator IDictionary.GetEnumerator () 507 | { 508 | return ((IOrderedDictionary) this).GetEnumerator (); 509 | } 510 | 511 | void IDictionary.Remove (object key) 512 | { 513 | EnsureDictionary ().Remove (key); 514 | 515 | for (int i = 0; i < object_list.Count; i++) { 516 | if (object_list[i].Key == (string) key) { 517 | object_list.RemoveAt (i); 518 | break; 519 | } 520 | } 521 | 522 | json = null; 523 | } 524 | #endregion 525 | 526 | 527 | #region IEnumerable Methods 528 | IEnumerator IEnumerable.GetEnumerator () 529 | { 530 | return EnsureCollection ().GetEnumerator (); 531 | } 532 | #endregion 533 | 534 | 535 | #region IJsonWrapper Methods 536 | bool IJsonWrapper.GetBoolean () 537 | { 538 | if (type != JsonType.Boolean) 539 | throw new InvalidOperationException ( 540 | "JsonData instance doesn't hold a boolean"); 541 | 542 | return inst_boolean; 543 | } 544 | 545 | double IJsonWrapper.GetDouble () 546 | { 547 | if (type != JsonType.Double) 548 | throw new InvalidOperationException ( 549 | "JsonData instance doesn't hold a double"); 550 | 551 | return inst_double; 552 | } 553 | 554 | int IJsonWrapper.GetInt () 555 | { 556 | if (type != JsonType.Int) 557 | throw new InvalidOperationException ( 558 | "JsonData instance doesn't hold an int"); 559 | 560 | return inst_int; 561 | } 562 | 563 | long IJsonWrapper.GetLong () 564 | { 565 | if (type != JsonType.Long) 566 | throw new InvalidOperationException ( 567 | "JsonData instance doesn't hold a long"); 568 | 569 | return inst_long; 570 | } 571 | 572 | string IJsonWrapper.GetString () 573 | { 574 | if (type != JsonType.String) 575 | throw new InvalidOperationException ( 576 | "JsonData instance doesn't hold a string"); 577 | 578 | return inst_string; 579 | } 580 | 581 | void IJsonWrapper.SetBoolean (bool val) 582 | { 583 | type = JsonType.Boolean; 584 | inst_boolean = val; 585 | json = null; 586 | } 587 | 588 | void IJsonWrapper.SetDouble (double val) 589 | { 590 | type = JsonType.Double; 591 | inst_double = val; 592 | json = null; 593 | } 594 | 595 | void IJsonWrapper.SetInt (int val) 596 | { 597 | type = JsonType.Int; 598 | inst_int = val; 599 | json = null; 600 | } 601 | 602 | void IJsonWrapper.SetLong (long val) 603 | { 604 | type = JsonType.Long; 605 | inst_long = val; 606 | json = null; 607 | } 608 | 609 | void IJsonWrapper.SetString (string val) 610 | { 611 | type = JsonType.String; 612 | inst_string = val; 613 | json = null; 614 | } 615 | 616 | string IJsonWrapper.ToJson () 617 | { 618 | return ToJson (); 619 | } 620 | 621 | void IJsonWrapper.ToJson (JsonWriter writer) 622 | { 623 | ToJson (writer); 624 | } 625 | #endregion 626 | 627 | 628 | #region IList Methods 629 | int IList.Add (object value) 630 | { 631 | return Add (value); 632 | } 633 | 634 | void IList.Clear () 635 | { 636 | EnsureList ().Clear (); 637 | json = null; 638 | } 639 | 640 | bool IList.Contains (object value) 641 | { 642 | return EnsureList ().Contains (value); 643 | } 644 | 645 | int IList.IndexOf (object value) 646 | { 647 | return EnsureList ().IndexOf (value); 648 | } 649 | 650 | void IList.Insert (int index, object value) 651 | { 652 | EnsureList ().Insert (index, value); 653 | json = null; 654 | } 655 | 656 | void IList.Remove (object value) 657 | { 658 | EnsureList ().Remove (value); 659 | json = null; 660 | } 661 | 662 | void IList.RemoveAt (int index) 663 | { 664 | EnsureList ().RemoveAt (index); 665 | json = null; 666 | } 667 | #endregion 668 | 669 | 670 | #region IOrderedDictionary Methods 671 | IDictionaryEnumerator IOrderedDictionary.GetEnumerator () 672 | { 673 | EnsureDictionary (); 674 | 675 | return new OrderedDictionaryEnumerator ( 676 | object_list.GetEnumerator ()); 677 | } 678 | 679 | void IOrderedDictionary.Insert (int idx, object key, object value) 680 | { 681 | string property = (string) key; 682 | JsonData data = ToJsonData (value); 683 | 684 | this[property] = data; 685 | 686 | KeyValuePair entry = 687 | new KeyValuePair (property, data); 688 | 689 | object_list.Insert (idx, entry); 690 | } 691 | 692 | void IOrderedDictionary.RemoveAt (int idx) 693 | { 694 | EnsureDictionary (); 695 | 696 | inst_object.Remove (object_list[idx].Key); 697 | object_list.RemoveAt (idx); 698 | } 699 | #endregion 700 | 701 | 702 | #region Private Methods 703 | private ICollection EnsureCollection () 704 | { 705 | if (type == JsonType.Array) 706 | return (ICollection) inst_array; 707 | 708 | if (type == JsonType.Object) 709 | return (ICollection) inst_object; 710 | 711 | throw new InvalidOperationException ( 712 | "The JsonData instance has to be initialized first"); 713 | } 714 | 715 | private IDictionary EnsureDictionary () 716 | { 717 | if (type == JsonType.Object) 718 | return (IDictionary) inst_object; 719 | 720 | if (type != JsonType.None) 721 | throw new InvalidOperationException ( 722 | "Instance of JsonData is not a dictionary"); 723 | 724 | type = JsonType.Object; 725 | inst_object = new Dictionary (); 726 | object_list = new List> (); 727 | 728 | return (IDictionary) inst_object; 729 | } 730 | 731 | private IList EnsureList () 732 | { 733 | if (type == JsonType.Array) 734 | return (IList) inst_array; 735 | 736 | if (type != JsonType.None) 737 | throw new InvalidOperationException ( 738 | "Instance of JsonData is not a list"); 739 | 740 | type = JsonType.Array; 741 | inst_array = new List (); 742 | 743 | return (IList) inst_array; 744 | } 745 | 746 | private JsonData ToJsonData (object obj) 747 | { 748 | if (obj == null) 749 | return null; 750 | 751 | if (obj is JsonData) 752 | return (JsonData) obj; 753 | 754 | return new JsonData (obj); 755 | } 756 | 757 | private static void WriteJson (IJsonWrapper obj, JsonWriter writer) 758 | { 759 | if (obj == null) { 760 | writer.Write (null); 761 | return; 762 | } 763 | 764 | if (obj.IsString) { 765 | writer.Write (obj.GetString ()); 766 | return; 767 | } 768 | 769 | if (obj.IsBoolean) { 770 | writer.Write (obj.GetBoolean ()); 771 | return; 772 | } 773 | 774 | if (obj.IsDouble) { 775 | writer.Write (obj.GetDouble ()); 776 | return; 777 | } 778 | 779 | if (obj.IsInt) { 780 | writer.Write (obj.GetInt ()); 781 | return; 782 | } 783 | 784 | if (obj.IsLong) { 785 | writer.Write (obj.GetLong ()); 786 | return; 787 | } 788 | 789 | if (obj.IsArray) { 790 | writer.WriteArrayStart (); 791 | foreach (object elem in (IList) obj) 792 | WriteJson ((JsonData) elem, writer); 793 | writer.WriteArrayEnd (); 794 | 795 | return; 796 | } 797 | 798 | if (obj.IsObject) { 799 | writer.WriteObjectStart (); 800 | 801 | foreach (DictionaryEntry entry in ((IDictionary) obj)) { 802 | writer.WritePropertyName ((string) entry.Key); 803 | WriteJson ((JsonData) entry.Value, writer); 804 | } 805 | writer.WriteObjectEnd (); 806 | 807 | return; 808 | } 809 | } 810 | #endregion 811 | 812 | 813 | public int Add (object value) 814 | { 815 | JsonData data = ToJsonData (value); 816 | 817 | json = null; 818 | 819 | return EnsureList ().Add (data); 820 | } 821 | 822 | public bool Remove(object obj) 823 | { 824 | json = null; 825 | if(IsObject) 826 | { 827 | JsonData value = null; 828 | if (inst_object.TryGetValue((string)obj, out value)) 829 | return inst_object.Remove((string)obj) && object_list.Remove(new KeyValuePair((string)obj, value)); 830 | else 831 | throw new KeyNotFoundException("The specified key was not found in the JsonData object."); 832 | } 833 | if(IsArray) 834 | { 835 | return inst_array.Remove(ToJsonData(obj)); 836 | } 837 | throw new InvalidOperationException ( 838 | "Instance of JsonData is not an object or a list."); 839 | } 840 | 841 | public void Clear () 842 | { 843 | if (IsObject) { 844 | ((IDictionary) this).Clear (); 845 | return; 846 | } 847 | 848 | if (IsArray) { 849 | ((IList) this).Clear (); 850 | return; 851 | } 852 | } 853 | 854 | public bool Equals (JsonData x) 855 | { 856 | if (x == null) 857 | return false; 858 | 859 | if (x.type != this.type) 860 | { 861 | // further check to see if this is a long to int comparison 862 | if ((x.type != JsonType.Int && x.type != JsonType.Long) 863 | || (this.type != JsonType.Int && this.type != JsonType.Long)) 864 | { 865 | return false; 866 | } 867 | } 868 | 869 | switch (this.type) { 870 | case JsonType.None: 871 | return true; 872 | 873 | case JsonType.Object: 874 | return this.inst_object.Equals (x.inst_object); 875 | 876 | case JsonType.Array: 877 | return this.inst_array.Equals (x.inst_array); 878 | 879 | case JsonType.String: 880 | return this.inst_string.Equals (x.inst_string); 881 | 882 | case JsonType.Int: 883 | { 884 | if (x.IsLong) 885 | { 886 | if (x.inst_long < Int32.MinValue || x.inst_long > Int32.MaxValue) 887 | return false; 888 | return this.inst_int.Equals((int)x.inst_long); 889 | } 890 | return this.inst_int.Equals(x.inst_int); 891 | } 892 | 893 | case JsonType.Long: 894 | { 895 | if (x.IsInt) 896 | { 897 | if (this.inst_long < Int32.MinValue || this.inst_long > Int32.MaxValue) 898 | return false; 899 | return x.inst_int.Equals((int)this.inst_long); 900 | } 901 | return this.inst_long.Equals(x.inst_long); 902 | } 903 | 904 | case JsonType.Double: 905 | return this.inst_double.Equals (x.inst_double); 906 | 907 | case JsonType.Boolean: 908 | return this.inst_boolean.Equals (x.inst_boolean); 909 | } 910 | 911 | return false; 912 | } 913 | 914 | public JsonType GetJsonType () 915 | { 916 | return type; 917 | } 918 | 919 | public void SetJsonType (JsonType type) 920 | { 921 | if (this.type == type) 922 | return; 923 | 924 | switch (type) { 925 | case JsonType.None: 926 | break; 927 | 928 | case JsonType.Object: 929 | inst_object = new Dictionary (); 930 | object_list = new List> (); 931 | break; 932 | 933 | case JsonType.Array: 934 | inst_array = new List (); 935 | break; 936 | 937 | case JsonType.String: 938 | inst_string = default (String); 939 | break; 940 | 941 | case JsonType.Int: 942 | inst_int = default (Int32); 943 | break; 944 | 945 | case JsonType.Long: 946 | inst_long = default (Int64); 947 | break; 948 | 949 | case JsonType.Double: 950 | inst_double = default (Double); 951 | break; 952 | 953 | case JsonType.Boolean: 954 | inst_boolean = default (Boolean); 955 | break; 956 | } 957 | 958 | this.type = type; 959 | } 960 | 961 | public string ToJson () 962 | { 963 | if (json != null) 964 | return json; 965 | 966 | StringWriter sw = new StringWriter (); 967 | JsonWriter writer = new JsonWriter (sw); 968 | writer.Validate = false; 969 | 970 | WriteJson (this, writer); 971 | json = sw.ToString (); 972 | 973 | return json; 974 | } 975 | 976 | public void ToJson (JsonWriter writer) 977 | { 978 | bool old_validate = writer.Validate; 979 | 980 | writer.Validate = false; 981 | 982 | WriteJson (this, writer); 983 | 984 | writer.Validate = old_validate; 985 | } 986 | 987 | public override string ToString () 988 | { 989 | switch (type) { 990 | case JsonType.Array: 991 | return "JsonData array"; 992 | 993 | case JsonType.Boolean: 994 | return inst_boolean.ToString (); 995 | 996 | case JsonType.Double: 997 | return inst_double.ToString (); 998 | 999 | case JsonType.Int: 1000 | return inst_int.ToString (); 1001 | 1002 | case JsonType.Long: 1003 | return inst_long.ToString (); 1004 | 1005 | case JsonType.Object: 1006 | return "JsonData object"; 1007 | 1008 | case JsonType.String: 1009 | return inst_string; 1010 | } 1011 | 1012 | return "Uninitialized JsonData"; 1013 | } 1014 | } 1015 | 1016 | 1017 | internal class OrderedDictionaryEnumerator : IDictionaryEnumerator 1018 | { 1019 | IEnumerator> list_enumerator; 1020 | 1021 | 1022 | public object Current { 1023 | get { return Entry; } 1024 | } 1025 | 1026 | public DictionaryEntry Entry { 1027 | get { 1028 | KeyValuePair curr = list_enumerator.Current; 1029 | return new DictionaryEntry (curr.Key, curr.Value); 1030 | } 1031 | } 1032 | 1033 | public object Key { 1034 | get { return list_enumerator.Current.Key; } 1035 | } 1036 | 1037 | public object Value { 1038 | get { return list_enumerator.Current.Value; } 1039 | } 1040 | 1041 | 1042 | public OrderedDictionaryEnumerator ( 1043 | IEnumerator> enumerator) 1044 | { 1045 | list_enumerator = enumerator; 1046 | } 1047 | 1048 | 1049 | public bool MoveNext () 1050 | { 1051 | return list_enumerator.MoveNext (); 1052 | } 1053 | 1054 | public void Reset () 1055 | { 1056 | list_enumerator.Reset (); 1057 | } 1058 | } 1059 | } 1060 | --------------------------------------------------------------------------------