├── ProjectSettings ├── ProjectVersion.txt ├── ClusterInputManager.asset ├── NetworkManager.asset ├── TimeManager.asset ├── EditorBuildSettings.asset ├── VFXManager.asset ├── AudioManager.asset ├── TagManager.asset ├── EditorSettings.asset ├── PresetManager.asset ├── UnityConnectSettings.asset ├── DynamicsManager.asset ├── Physics2DSettings.asset ├── NavMeshAreas.asset ├── GraphicsSettings.asset ├── QualitySettings.asset ├── InputManager.asset └── ProjectSettings.asset ├── Assets ├── Editor.meta ├── Plugins.meta ├── Scenes.meta ├── Scenes │ ├── SampleScene.unity.meta │ └── SampleScene.unity ├── Scripts.meta ├── TrasnferData.meta ├── Plugins │ ├── LitJson.meta │ └── LitJson │ │ ├── JsonData.cs.meta │ │ ├── Lexer.cs.meta │ │ ├── Extensions.cs.meta │ │ ├── IJsonWrapper.cs.meta │ │ ├── JsonException.cs.meta │ │ ├── JsonMapper.cs.meta │ │ ├── JsonReader.cs.meta │ │ ├── JsonWriter.cs.meta │ │ ├── ParserToken.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 │ │ └── JsonMapper.cs ├── TrasnferData │ ├── TestScriptableObj.json.meta │ ├── TestScriptableObj.asset.meta │ ├── TestScriptableObj.asset │ └── TestScriptableObj.json ├── TestScriptableObj.asset.meta ├── Editor │ ├── Converter.cs.meta │ └── Converter.cs ├── Scripts │ ├── TestScriptableObj.cs.meta │ └── TestScriptableObj.cs └── TestScriptableObj.asset ├── README.md ├── LICENSE ├── .gitattributes └── .gitignore /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.3.4f1 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f0727d3532868cf469b65e31ab74ced9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b17694bf7af31ad448bca60e0d802fce 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f704ae4b4f98ae41a0bce26658850c1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/SampleScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99c9720ab356a0642a771bea13969a05 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 164d0b947d7461b40bf024dab00d8124 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /Assets/TrasnferData.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 169a64eac47dc554589e0f148c77a36c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Plugins/LitJson.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 400f12f699fb70247b9eb0af2288081c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TrasnferData/TestScriptableObj.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae13bbf3ecdc79e48ab75423bdefbf36 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/TestScriptableObj.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f17815f9b817604893f36057b4ba716 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TrasnferData/TestScriptableObj.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e2caa0060b639e44880e4d53070866b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /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.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Assets/Editor/Converter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6a95ee5704f5b74d8aa40e2b53e0050 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Scripts/TestScriptableObj.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9eb5f803c25dba4fbb86451cbb42d25 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /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 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 99c9720ab356a0642a771bea13969a05 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /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_RenderPipeSettingsPath: 10 | m_FixedTimeStep: 0.016666668 11 | m_MaxDeltaTime: 0.05 12 | -------------------------------------------------------------------------------- /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 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LitJson4Unity 2 | 适用于Unity的改进型LitJson库 3 | 4 | ### 简介 5 | 基于[原生的LitJson库](https://github.com/LitJSON/litjson)改造的适用于Unity的LitJson库。 6 | **`支持以下原生版本不支持的特性`**: 7 | * 支持float类型(最新原生版本已经支持) 8 | * 支持Unity内建类型(Vector2、Vector3、Rect、AnimationCure、Bounds、Color、Color32、Quaternion、RectOffset等) 9 | * 支持JsonIgnore Attritube,对某些字段跳过序列化 10 | * 支持对输出的Json内容格式化,更规整 11 | 12 | ### 使用方法 13 | 直接将 **`Plugins/LitJson目录下所有的cs脚本放到你的工程中即可`**。 14 | 15 | ### 博客教程 16 | * [【Unity游戏开发】跟着马三一起魔改LitJson](https://www.cnblogs.com/msxh/p/12541159.html) 17 | -------------------------------------------------------------------------------- /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 | - PostProcessing 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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 -------------------------------------------------------------------------------- /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: 7 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_SpritePackerMode: 0 12 | m_SpritePackerPaddingPower: 1 13 | m_EtcTextureCompressorBehavior: 1 14 | m_EtcTextureFastCompressor: 1 15 | m_EtcTextureNormalCompressor: 2 16 | m_EtcTextureBestCompressor: 4 17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 18 | m_ProjectGenerationRootNamespace: 19 | m_UserGeneratedProjectSuffix: 20 | m_CollabEditorSettings: 21 | inProgressEnabled: 1 22 | -------------------------------------------------------------------------------- /Assets/Scripts/TestScriptableObj.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using LitJson.Extensions; 5 | 6 | [CreateAssetMenu(fileName = "TestScriptableObj",menuName = "ColaFramework/TestScriptableObj")] 7 | public class TestScriptableObj:ScriptableObject 8 | { 9 | public int num1; 10 | 11 | public float num2; 12 | 13 | public Vector2 v2; 14 | 15 | public Vector3 v3; 16 | 17 | public Quaternion quaternion; 18 | 19 | public Color color1; 20 | 21 | public Color32 color2; 22 | 23 | public Bounds bounds; 24 | 25 | public Rect rect; 26 | 27 | public AnimationCurve animationCurve; 28 | 29 | [JsonIgnore] 30 | public string SerializeField; 31 | } 32 | -------------------------------------------------------------------------------- /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 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /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 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate 14 | m_Enabled: 0 15 | m_CaptureEditorExceptions: 1 16 | UnityPurchasingSettings: 17 | m_Enabled: 0 18 | m_TestMode: 0 19 | UnityAnalyticsSettings: 20 | m_Enabled: 0 21 | m_InitializeOnStartup: 1 22 | m_TestMode: 0 23 | m_TestEventUrl: 24 | m_TestConfigUrl: 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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 马三小伙儿 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /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: 7 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: 1 23 | m_ClothInterCollisionSettingsToggle: 0 24 | m_ContactPairsMode: 0 25 | m_BroadphaseType: 0 26 | m_WorldBounds: 27 | m_Center: {x: 0, y: 0, z: 0} 28 | m_Extent: {x: 250, y: 250, z: 250} 29 | m_WorldSubdivisions: 8 30 | -------------------------------------------------------------------------------- /Assets/Editor/Converter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | using LitJson; 6 | using System.IO; 7 | 8 | public class Converter 9 | { 10 | private static readonly string JsonPath = "Assets/TrasnferData/TestScriptableObj.json"; 11 | private static readonly string ScriptableObjectPath = "Assets/TestScriptableObj.asset"; 12 | private static readonly string TransScritptableObjectPath = "Assets/TrasnferData/TestScriptableObj.asset"; 13 | 14 | [MenuItem("ColaFramework/序列化为Json")] 15 | public static void Trans2Json() 16 | { 17 | var asset = AssetDatabase.LoadAssetAtPath(ScriptableObjectPath); 18 | var jsonContent = JsonMapper.ToJson(asset); 19 | using(var stream = new StreamWriter(JsonPath)) 20 | { 21 | stream.Write(jsonContent); 22 | } 23 | AssetDatabase.Refresh(); 24 | } 25 | 26 | [MenuItem("ColaFramework/反序列化为ScriptableObject")] 27 | public static void Trans2ScriptableObject() 28 | { 29 | if (!File.Exists(JsonPath)) return; 30 | using(var stream = new StreamReader(JsonPath)) 31 | { 32 | var jsonStr = stream.ReadToEnd(); 33 | var striptableObj = JsonMapper.ToObject(jsonStr); 34 | AssetDatabase.CreateAsset(striptableObj, TransScritptableObjectPath); 35 | AssetDatabase.Refresh(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/TrasnferData/TestScriptableObj.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: f9eb5f803c25dba4fbb86451cbb42d25, type: 3} 12 | m_Name: TestScriptableObj 13 | m_EditorClassIdentifier: 14 | num1: 100 15 | num2: 100.1 16 | v2: {x: 3.4, y: 5.6} 17 | v3: {x: 1.2, y: 3.4, z: 5.6} 18 | quaternion: {x: 0, y: 0, z: 0, w: 0} 19 | color1: {r: 0.9433962, g: 0.30704877, b: 0.30704877, a: 0} 20 | color2: 21 | serializedVersion: 2 22 | rgba: 15650350 23 | bounds: 24 | m_Center: {x: 1, y: 2, z: 3} 25 | m_Extent: {x: 4, y: 5, z: 6} 26 | rect: 27 | serializedVersion: 2 28 | x: 1 29 | y: 2 30 | width: 3 31 | height: 4 32 | animationCurve: 33 | serializedVersion: 2 34 | m_Curve: 35 | - serializedVersion: 3 36 | time: 0 37 | value: 0 38 | inSlope: 2 39 | outSlope: 2 40 | tangentMode: 0 41 | weightedMode: 0 42 | inWeight: 0 43 | outWeight: 0 44 | - serializedVersion: 3 45 | time: 1 46 | value: 1 47 | inSlope: 0 48 | outSlope: 0 49 | tangentMode: 0 50 | weightedMode: 0 51 | inWeight: 0 52 | outWeight: 0 53 | m_PreInfinity: 2 54 | m_PostInfinity: 2 55 | m_RotationOrder: 4 56 | SerializeField: 57 | -------------------------------------------------------------------------------- /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: 3 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_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_AutoSyncTransforms: 1 28 | m_AlwaysShowColliders: 0 29 | m_ShowColliderSleep: 1 30 | m_ShowColliderContacts: 0 31 | m_ShowColliderAABB: 0 32 | m_ContactArrowScale: 0.2 33 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 34 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 35 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 36 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 37 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 38 | -------------------------------------------------------------------------------- /Assets/TestScriptableObj.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: f9eb5f803c25dba4fbb86451cbb42d25, type: 3} 13 | m_Name: TestScriptableObj 14 | m_EditorClassIdentifier: 15 | num1: 100 16 | num2: 100.1 17 | v2: {x: 3.4, y: 5.6} 18 | v3: {x: 1.2, y: 3.4, z: 5.6} 19 | quaternion: {x: 0, y: 0, z: 0, w: 0} 20 | color1: {r: 0.9433962, g: 0.30704877, b: 0.30704877, a: 0} 21 | color2: 22 | serializedVersion: 2 23 | rgba: 15650350 24 | bounds: 25 | m_Center: {x: 1, y: 2, z: 3} 26 | m_Extent: {x: 4, y: 5, z: 6} 27 | rect: 28 | serializedVersion: 2 29 | x: 1 30 | y: 2 31 | width: 3 32 | height: 4 33 | animationCurve: 34 | serializedVersion: 2 35 | m_Curve: 36 | - serializedVersion: 3 37 | time: 0 38 | value: 0 39 | inSlope: 2 40 | outSlope: 2 41 | tangentMode: 0 42 | weightedMode: 0 43 | inWeight: 0 44 | outWeight: 0 45 | - serializedVersion: 3 46 | time: 1 47 | value: 1 48 | inSlope: 0 49 | outSlope: 0 50 | tangentMode: 0 51 | weightedMode: 0 52 | inWeight: 0 53 | outWeight: 0 54 | m_PreInfinity: 2 55 | m_PostInfinity: 2 56 | m_RotationOrder: 4 57 | SerializeField: "\u8FD9\u4E2A\u5B57\u6BB5\u4E0D\u4F1A\u88AB\u5E8F\u5217\u5316\u4E3AJson\u5185\u5BB9" 58 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/TrasnferData/TestScriptableObj.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "name" : "TestScriptableObj", 4 | "hideFlags" : 0, 5 | "num1" : 100, 6 | "num2" : 100.1, 7 | "v2" : { 8 | "x" : 3.40000009536743, 9 | "y" : 5.59999990463257 10 | }, 11 | "v3" : { 12 | "x" : 1.20000004768372, 13 | "y" : 3.40000009536743, 14 | "z" : 5.59999990463257 15 | }, 16 | "quaternion" : { 17 | "x" : 0.0, 18 | "y" : 0.0, 19 | "z" : 0.0, 20 | "w" : 0.0 21 | }, 22 | "color1" : { 23 | "r" : 0.943396210670471, 24 | "g" : 0.307048767805099, 25 | "b" : 0.307048767805099, 26 | "a" : 0.0 27 | }, 28 | "color2" : { 29 | "r" : 46, 30 | "g" : 206, 31 | "b" : 238, 32 | "a" : 0 33 | }, 34 | "bounds" : { 35 | "center" : { 36 | "x" : 1.0, 37 | "y" : 2.0, 38 | "z" : 3.0 39 | }, 40 | "size" : { 41 | "x" : 8.0, 42 | "y" : 10.0, 43 | "z" : 12.0 44 | } 45 | }, 46 | "rect" : { 47 | "x" : 1.0, 48 | "y" : 2.0, 49 | "width" : 3.0, 50 | "height" : 4.0 51 | }, 52 | "animationCurve" : { 53 | "keys" : [ 54 | { 55 | "time" : 0, 56 | "value" : 0, 57 | "inTangent" : 2, 58 | "outTangent" : 2, 59 | "inWeight" : 0, 60 | "outWeight" : 0, 61 | "weightedMode" : 0, 62 | "tangentMode" : 0 63 | }, 64 | { 65 | "time" : 1, 66 | "value" : 1, 67 | "inTangent" : 0, 68 | "outTangent" : 0, 69 | "inWeight" : 0, 70 | "outWeight" : 0, 71 | "weightedMode" : 0, 72 | "tangentMode" : 0 73 | } 74 | ], 75 | "length" : 2, 76 | "preWrapMode" : 8, 77 | "postWrapMode" : 8 78 | } 79 | } -------------------------------------------------------------------------------- /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: 12 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 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /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: 4 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 | particleRaycastBudget: 4 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 4 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | - serializedVersion: 2 38 | name: Low 39 | pixelLightCount: 0 40 | shadows: 0 41 | shadowResolution: 0 42 | shadowProjection: 1 43 | shadowCascades: 1 44 | shadowDistance: 20 45 | shadowNearPlaneOffset: 3 46 | shadowCascade2Split: 0.33333334 47 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 48 | shadowmaskMode: 0 49 | blendWeights: 2 50 | textureQuality: 0 51 | anisotropicTextures: 0 52 | antiAliasing: 0 53 | softParticles: 0 54 | softVegetation: 0 55 | realtimeReflectionProbes: 0 56 | billboardsFaceCameraPosition: 0 57 | vSyncCount: 0 58 | lodBias: 0.4 59 | maximumLODLevel: 0 60 | particleRaycastBudget: 16 61 | asyncUploadTimeSlice: 2 62 | asyncUploadBufferSize: 4 63 | resolutionScalingFixedDPIFactor: 1 64 | excludedTargetPlatforms: [] 65 | - serializedVersion: 2 66 | name: Medium 67 | pixelLightCount: 1 68 | shadows: 1 69 | shadowResolution: 0 70 | shadowProjection: 1 71 | shadowCascades: 1 72 | shadowDistance: 20 73 | shadowNearPlaneOffset: 3 74 | shadowCascade2Split: 0.33333334 75 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 76 | shadowmaskMode: 0 77 | blendWeights: 2 78 | textureQuality: 0 79 | anisotropicTextures: 1 80 | antiAliasing: 0 81 | softParticles: 0 82 | softVegetation: 0 83 | realtimeReflectionProbes: 0 84 | billboardsFaceCameraPosition: 0 85 | vSyncCount: 1 86 | lodBias: 0.7 87 | maximumLODLevel: 0 88 | particleRaycastBudget: 64 89 | asyncUploadTimeSlice: 2 90 | asyncUploadBufferSize: 4 91 | resolutionScalingFixedDPIFactor: 1 92 | excludedTargetPlatforms: [] 93 | - serializedVersion: 2 94 | name: High 95 | pixelLightCount: 2 96 | shadows: 2 97 | shadowResolution: 1 98 | shadowProjection: 1 99 | shadowCascades: 2 100 | shadowDistance: 40 101 | shadowNearPlaneOffset: 3 102 | shadowCascade2Split: 0.33333334 103 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 104 | shadowmaskMode: 1 105 | blendWeights: 2 106 | textureQuality: 0 107 | anisotropicTextures: 1 108 | antiAliasing: 2 109 | softParticles: 0 110 | softVegetation: 1 111 | realtimeReflectionProbes: 1 112 | billboardsFaceCameraPosition: 1 113 | vSyncCount: 1 114 | lodBias: 1 115 | maximumLODLevel: 0 116 | particleRaycastBudget: 256 117 | asyncUploadTimeSlice: 2 118 | asyncUploadBufferSize: 4 119 | resolutionScalingFixedDPIFactor: 1 120 | excludedTargetPlatforms: [] 121 | - serializedVersion: 2 122 | name: Very High 123 | pixelLightCount: 3 124 | shadows: 2 125 | shadowResolution: 2 126 | shadowProjection: 1 127 | shadowCascades: 2 128 | shadowDistance: 40 129 | shadowNearPlaneOffset: 3 130 | shadowCascade2Split: 0.33333334 131 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 132 | shadowmaskMode: 1 133 | blendWeights: 4 134 | textureQuality: 0 135 | anisotropicTextures: 1 136 | antiAliasing: 4 137 | softParticles: 1 138 | softVegetation: 1 139 | realtimeReflectionProbes: 1 140 | billboardsFaceCameraPosition: 1 141 | vSyncCount: 1 142 | lodBias: 1.5 143 | maximumLODLevel: 0 144 | particleRaycastBudget: 1024 145 | asyncUploadTimeSlice: 2 146 | asyncUploadBufferSize: 4 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Ultra 151 | pixelLightCount: 4 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 4 156 | shadowDistance: 150 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: 1 164 | antiAliasing: 4 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 2 171 | maximumLODLevel: 0 172 | particleRaycastBudget: 4096 173 | asyncUploadTimeSlice: 2 174 | asyncUploadBufferSize: 4 175 | resolutionScalingFixedDPIFactor: 1 176 | excludedTargetPlatforms: [] 177 | m_PerPlatformDefaultQuality: 178 | Android: 2 179 | Nintendo 3DS: 5 180 | Nintendo Switch: 5 181 | PS4: 5 182 | PSP2: 2 183 | Standalone: 5 184 | Tizen: 2 185 | WebGL: 3 186 | WiiU: 5 187 | Windows Store Apps: 5 188 | XboxOne: 5 189 | iPhone: 2 190 | tvOS: 2 191 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # Benchmark Results 46 | BenchmarkDotNet.Artifacts/ 47 | 48 | # .NET Core 49 | project.lock.json 50 | project.fragment.lock.json 51 | artifacts/ 52 | **/Properties/launchSettings.json 53 | 54 | *_i.c 55 | *_p.c 56 | *_i.h 57 | *.ilk 58 | *.obj 59 | *.pch 60 | *.pdb 61 | *.pgc 62 | *.pgd 63 | *.rsp 64 | *.sbr 65 | *.tlb 66 | *.tli 67 | *.tlh 68 | *.tmp 69 | *.tmp_proj 70 | *.log 71 | *.vspscc 72 | *.vssscc 73 | .builds 74 | *.pidb 75 | *.svclog 76 | *.scc 77 | 78 | # Chutzpah Test files 79 | _Chutzpah* 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opendb 86 | *.opensdf 87 | *.sdf 88 | *.cachefile 89 | *.VC.db 90 | *.VC.VC.opendb 91 | 92 | # Visual Studio profiler 93 | *.psess 94 | *.vsp 95 | *.vspx 96 | *.sap 97 | 98 | # TFS 2012 Local Workspace 99 | $tf/ 100 | 101 | # Guidance Automation Toolkit 102 | *.gpState 103 | 104 | # ReSharper is a .NET coding add-in 105 | _ReSharper*/ 106 | *.[Rr]e[Ss]harper 107 | *.DotSettings.user 108 | 109 | # JustCode is a .NET coding add-in 110 | .JustCode 111 | 112 | # TeamCity is a build add-in 113 | _TeamCity* 114 | 115 | # DotCover is a Code Coverage Tool 116 | *.dotCover 117 | 118 | # Visual Studio code coverage results 119 | *.coverage 120 | *.coveragexml 121 | 122 | # NCrunch 123 | _NCrunch_* 124 | .*crunch*.local.xml 125 | nCrunchTemp_* 126 | 127 | # MightyMoose 128 | *.mm.* 129 | AutoTest.Net/ 130 | 131 | # Web workbench (sass) 132 | .sass-cache/ 133 | 134 | # Installshield output folder 135 | [Ee]xpress/ 136 | 137 | # DocProject is a documentation generator add-in 138 | DocProject/buildhelp/ 139 | DocProject/Help/*.HxT 140 | DocProject/Help/*.HxC 141 | DocProject/Help/*.hhc 142 | DocProject/Help/*.hhk 143 | DocProject/Help/*.hhp 144 | DocProject/Help/Html2 145 | DocProject/Help/html 146 | 147 | # Click-Once directory 148 | publish/ 149 | 150 | # Publish Web Output 151 | *.[Pp]ublish.xml 152 | *.azurePubxml 153 | # TODO: Comment the next line if you want to checkin your web deploy settings 154 | # but database connection strings (with potential passwords) will be unencrypted 155 | *.pubxml 156 | *.publishproj 157 | 158 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 159 | # checkin your Azure Web App publish settings, but sensitive information contained 160 | # in these scripts will be unencrypted 161 | PublishScripts/ 162 | 163 | # NuGet Packages 164 | *.nupkg 165 | # The packages folder can be ignored because of Package Restore 166 | **/packages/* 167 | # except build/, which is used as an MSBuild target. 168 | !**/packages/build/ 169 | # Uncomment if necessary however generally it will be regenerated when needed 170 | #!**/packages/repositories.config 171 | # NuGet v3's project.json files produces more ignorable files 172 | *.nuget.props 173 | *.nuget.targets 174 | 175 | # Microsoft Azure Build Output 176 | csx/ 177 | *.build.csdef 178 | 179 | # Microsoft Azure Emulator 180 | ecf/ 181 | rcf/ 182 | 183 | # Windows Store app package directories and files 184 | AppPackages/ 185 | BundleArtifacts/ 186 | Package.StoreAssociation.xml 187 | _pkginfo.txt 188 | *.appx 189 | 190 | # Visual Studio cache files 191 | # files ending in .cache can be ignored 192 | *.[Cc]ache 193 | # but keep track of directories ending in .cache 194 | !*.[Cc]ache/ 195 | 196 | # Others 197 | ClientBin/ 198 | ~$* 199 | *~ 200 | *.dbmdl 201 | *.dbproj.schemaview 202 | *.jfm 203 | *.pfx 204 | *.publishsettings 205 | orleans.codegen.cs 206 | 207 | # Since there are multiple workflows, uncomment next line to ignore bower_components 208 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 209 | #bower_components/ 210 | 211 | # RIA/Silverlight projects 212 | Generated_Code/ 213 | 214 | # Backup & report files from converting an old project file 215 | # to a newer Visual Studio version. Backup files are not needed, 216 | # because we have git ;-) 217 | _UpgradeReport_Files/ 218 | Backup*/ 219 | UpgradeLog*.XML 220 | UpgradeLog*.htm 221 | 222 | # SQL Server files 223 | *.mdf 224 | *.ldf 225 | *.ndf 226 | 227 | # Business Intelligence projects 228 | *.rdl.data 229 | *.bim.layout 230 | *.bim_*.settings 231 | 232 | # Microsoft Fakes 233 | FakesAssemblies/ 234 | 235 | # GhostDoc plugin setting file 236 | *.GhostDoc.xml 237 | 238 | # Node.js Tools for Visual Studio 239 | .ntvs_analysis.dat 240 | node_modules/ 241 | 242 | # Typescript v1 declaration files 243 | typings/ 244 | 245 | # Visual Studio 6 build log 246 | *.plg 247 | 248 | # Visual Studio 6 workspace options file 249 | *.opt 250 | 251 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 252 | *.vbw 253 | 254 | # Visual Studio LightSwitch build output 255 | **/*.HTMLClient/GeneratedArtifacts 256 | **/*.DesktopClient/GeneratedArtifacts 257 | **/*.DesktopClient/ModelManifest.xml 258 | **/*.Server/GeneratedArtifacts 259 | **/*.Server/ModelManifest.xml 260 | _Pvt_Extensions 261 | 262 | # Paket dependency manager 263 | .paket/paket.exe 264 | paket-files/ 265 | 266 | # FAKE - F# Make 267 | .fake/ 268 | 269 | # JetBrains Rider 270 | .idea/ 271 | *.sln.iml 272 | 273 | # CodeRush 274 | .cr/ 275 | 276 | # Python Tools for Visual Studio (PTVS) 277 | __pycache__/ 278 | *.pyc 279 | 280 | # Cake - Uncomment if you are using it 281 | # tools/** 282 | # !tools/packages.config 283 | 284 | # Tabs Studio 285 | *.tss 286 | 287 | # Telerik's JustMock configuration file 288 | *.jmconfig 289 | 290 | # BizTalk build output 291 | *.btp.cs 292 | *.btm.cs 293 | *.odx.cs 294 | *.xsd.cs 295 | 296 | # Unity AutoBuild 297 | Library/ 298 | Temp/ 299 | /*.sln 300 | /*.csproj 301 | Sirenix/ 302 | Sirenix.meta -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Assets/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: 0} 41 | m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 0 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_TemporalCoherenceThreshold: 1 54 | m_EnvironmentLightingMode: 0 55 | m_EnableBakedLightmaps: 1 56 | m_EnableRealtimeLightmaps: 0 57 | m_LightmapEditorSettings: 58 | serializedVersion: 10 59 | m_Resolution: 2 60 | m_BakeResolution: 10 61 | m_AtlasSize: 512 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 1 65 | m_CompAOExponentDirect: 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: 256 79 | m_PVRBounces: 2 80 | m_PVRFilterTypeDirect: 0 81 | m_PVRFilterTypeIndirect: 0 82 | m_PVRFilterTypeAO: 0 83 | m_PVRFilteringMode: 1 84 | m_PVRCulling: 1 85 | m_PVRFilteringGaussRadiusDirect: 1 86 | m_PVRFilteringGaussRadiusIndirect: 5 87 | m_PVRFilteringGaussRadiusAO: 2 88 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 89 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 90 | m_PVRFilteringAtrousPositionSigmaAO: 1 91 | m_ShowResolutionOverlay: 1 92 | m_LightingDataAsset: {fileID: 0} 93 | m_UseShadowmask: 1 94 | --- !u!196 &4 95 | NavMeshSettings: 96 | serializedVersion: 2 97 | m_ObjectHideFlags: 0 98 | m_BuildSettings: 99 | serializedVersion: 2 100 | agentTypeID: 0 101 | agentRadius: 0.5 102 | agentHeight: 2 103 | agentSlope: 45 104 | agentClimb: 0.4 105 | ledgeDropHeight: 0 106 | maxJumpAcrossDistance: 0 107 | minRegionArea: 2 108 | manualCellSize: 0 109 | cellSize: 0.16666667 110 | manualTileSize: 0 111 | tileSize: 256 112 | accuratePlacement: 0 113 | debug: 114 | m_Flags: 0 115 | m_NavMeshData: {fileID: 0} 116 | --- !u!1 &170076733 117 | GameObject: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInternal: {fileID: 0} 121 | serializedVersion: 6 122 | m_Component: 123 | - component: {fileID: 170076735} 124 | - component: {fileID: 170076734} 125 | m_Layer: 0 126 | m_Name: Directional Light 127 | m_TagString: Untagged 128 | m_Icon: {fileID: 0} 129 | m_NavMeshLayer: 0 130 | m_StaticEditorFlags: 0 131 | m_IsActive: 1 132 | --- !u!108 &170076734 133 | Light: 134 | m_ObjectHideFlags: 0 135 | m_CorrespondingSourceObject: {fileID: 0} 136 | m_PrefabInternal: {fileID: 0} 137 | m_GameObject: {fileID: 170076733} 138 | m_Enabled: 1 139 | serializedVersion: 8 140 | m_Type: 1 141 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 142 | m_Intensity: 1 143 | m_Range: 10 144 | m_SpotAngle: 30 145 | m_CookieSize: 10 146 | m_Shadows: 147 | m_Type: 2 148 | m_Resolution: -1 149 | m_CustomResolution: -1 150 | m_Strength: 1 151 | m_Bias: 0.05 152 | m_NormalBias: 0.4 153 | m_NearPlane: 0.2 154 | m_Cookie: {fileID: 0} 155 | m_DrawHalo: 0 156 | m_Flare: {fileID: 0} 157 | m_RenderMode: 0 158 | m_CullingMask: 159 | serializedVersion: 2 160 | m_Bits: 4294967295 161 | m_Lightmapping: 1 162 | m_LightShadowCasterMode: 0 163 | m_AreaSize: {x: 1, y: 1} 164 | m_BounceIntensity: 1 165 | m_ColorTemperature: 6570 166 | m_UseColorTemperature: 0 167 | m_ShadowRadius: 0 168 | m_ShadowAngle: 0 169 | --- !u!4 &170076735 170 | Transform: 171 | m_ObjectHideFlags: 0 172 | m_CorrespondingSourceObject: {fileID: 0} 173 | m_PrefabInternal: {fileID: 0} 174 | m_GameObject: {fileID: 170076733} 175 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 176 | m_LocalPosition: {x: 0, y: 3, z: 0} 177 | m_LocalScale: {x: 1, y: 1, z: 1} 178 | m_Children: [] 179 | m_Father: {fileID: 0} 180 | m_RootOrder: 1 181 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 182 | --- !u!1 &534669902 183 | GameObject: 184 | m_ObjectHideFlags: 0 185 | m_CorrespondingSourceObject: {fileID: 0} 186 | m_PrefabInternal: {fileID: 0} 187 | serializedVersion: 6 188 | m_Component: 189 | - component: {fileID: 534669905} 190 | - component: {fileID: 534669904} 191 | - component: {fileID: 534669903} 192 | m_Layer: 0 193 | m_Name: Main Camera 194 | m_TagString: Untagged 195 | m_Icon: {fileID: 0} 196 | m_NavMeshLayer: 0 197 | m_StaticEditorFlags: 0 198 | m_IsActive: 1 199 | --- !u!81 &534669903 200 | AudioListener: 201 | m_ObjectHideFlags: 0 202 | m_CorrespondingSourceObject: {fileID: 0} 203 | m_PrefabInternal: {fileID: 0} 204 | m_GameObject: {fileID: 534669902} 205 | m_Enabled: 1 206 | --- !u!20 &534669904 207 | Camera: 208 | m_ObjectHideFlags: 0 209 | m_CorrespondingSourceObject: {fileID: 0} 210 | m_PrefabInternal: {fileID: 0} 211 | m_GameObject: {fileID: 534669902} 212 | m_Enabled: 1 213 | serializedVersion: 2 214 | m_ClearFlags: 1 215 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 216 | m_projectionMatrixMode: 1 217 | m_SensorSize: {x: 36, y: 24} 218 | m_LensShift: {x: 0, y: 0} 219 | m_FocalLength: 50 220 | m_NormalizedViewPortRect: 221 | serializedVersion: 2 222 | x: 0 223 | y: 0 224 | width: 1 225 | height: 1 226 | near clip plane: 0.3 227 | far clip plane: 1000 228 | field of view: 60 229 | orthographic: 0 230 | orthographic size: 5 231 | m_Depth: -1 232 | m_CullingMask: 233 | serializedVersion: 2 234 | m_Bits: 4294967295 235 | m_RenderingPath: -1 236 | m_TargetTexture: {fileID: 0} 237 | m_TargetDisplay: 0 238 | m_TargetEye: 3 239 | m_HDR: 1 240 | m_AllowMSAA: 1 241 | m_AllowDynamicResolution: 0 242 | m_ForceIntoRT: 0 243 | m_OcclusionCulling: 1 244 | m_StereoConvergence: 10 245 | m_StereoSeparation: 0.022 246 | --- !u!4 &534669905 247 | Transform: 248 | m_ObjectHideFlags: 0 249 | m_CorrespondingSourceObject: {fileID: 0} 250 | m_PrefabInternal: {fileID: 0} 251 | m_GameObject: {fileID: 534669902} 252 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 253 | m_LocalPosition: {x: 0, y: 1, z: -10} 254 | m_LocalScale: {x: 1, y: 1, z: 1} 255 | m_Children: [] 256 | m_Father: {fileID: 0} 257 | m_RootOrder: 0 258 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 259 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /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: 15 7 | productGUID: cf80927dc8714964db5c21ecf04e4361 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: LitJson4Unity 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 | iosAppInBackgroundBehavior: 0 56 | displayResolutionDialog: 1 57 | iosAllowHTTPDownload: 1 58 | allowedAutorotateToPortrait: 1 59 | allowedAutorotateToPortraitUpsideDown: 1 60 | allowedAutorotateToLandscapeRight: 1 61 | allowedAutorotateToLandscapeLeft: 1 62 | useOSAutorotation: 1 63 | use32BitDisplayBuffer: 1 64 | preserveFramebufferAlpha: 0 65 | disableDepthAndStencilBuffers: 0 66 | androidStartInFullscreen: 1 67 | androidRenderOutsideSafeArea: 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 | resizableWindow: 0 83 | useMacAppStoreValidation: 0 84 | macAppStoreCategory: public.app-category.games 85 | gpuSkinning: 1 86 | graphicsJobs: 0 87 | xboxPIXTextureCapture: 0 88 | xboxEnableAvatar: 0 89 | xboxEnableKinect: 0 90 | xboxEnableKinectAutoTracking: 0 91 | xboxEnableFitness: 0 92 | visibleInBackground: 1 93 | allowFullscreenSwitch: 1 94 | graphicsJobMode: 0 95 | fullscreenMode: 1 96 | xboxSpeechDB: 0 97 | xboxEnableHeadOrientation: 0 98 | xboxEnableGuest: 0 99 | xboxEnablePIXSampling: 0 100 | metalFramebufferOnly: 0 101 | xboxOneResolution: 0 102 | xboxOneSResolution: 0 103 | xboxOneXResolution: 3 104 | xboxOneMonoLoggingLevel: 0 105 | xboxOneLoggingLevel: 1 106 | xboxOneDisableEsram: 0 107 | xboxOnePresentImmediateThreshold: 0 108 | switchQueueCommandMemory: 0 109 | vulkanEnableSetSRGBWrite: 0 110 | m_SupportedAspectRatios: 111 | 4:3: 1 112 | 5:4: 1 113 | 16:10: 1 114 | 16:9: 1 115 | Others: 1 116 | bundleVersion: 0.1 117 | preloadedAssets: [] 118 | metroInputSource: 0 119 | wsaTransparentSwapchain: 0 120 | m_HolographicPauseOnTrackingLoss: 1 121 | xboxOneDisableKinectGpuReservation: 0 122 | xboxOneEnable7thCore: 0 123 | isWsaHolographicRemotingEnabled: 0 124 | vrSettings: 125 | cardboard: 126 | depthFormat: 0 127 | enableTransitionView: 0 128 | daydream: 129 | depthFormat: 0 130 | useSustainedPerformanceMode: 0 131 | enableVideoLayer: 0 132 | useProtectedVideoMemory: 0 133 | minimumSupportedHeadTracking: 0 134 | maximumSupportedHeadTracking: 1 135 | hololens: 136 | depthFormat: 1 137 | depthBufferSharingEnabled: 0 138 | oculus: 139 | sharedDepthBuffer: 0 140 | dashSupport: 0 141 | enable360StereoCapture: 0 142 | protectGraphicsMemory: 0 143 | enableFrameTimingStats: 0 144 | useHDRDisplay: 0 145 | m_ColorGamuts: 00000000 146 | targetPixelDensity: 30 147 | resolutionScalingMode: 0 148 | androidSupportedAspectRatio: 1 149 | androidMaxAspectRatio: 2.1 150 | applicationIdentifier: {} 151 | buildNumber: {} 152 | AndroidBundleVersionCode: 1 153 | AndroidMinSdkVersion: 16 154 | AndroidTargetSdkVersion: 0 155 | AndroidPreferredInstallLocation: 1 156 | aotOptions: 157 | stripEngineCode: 1 158 | iPhoneStrippingLevel: 0 159 | iPhoneScriptCallOptimization: 0 160 | ForceInternetPermission: 0 161 | ForceSDCardPermission: 0 162 | CreateWallpaper: 0 163 | APKExpansionFiles: 0 164 | keepLoadedShadersAlive: 0 165 | StripUnusedMeshComponents: 1 166 | VertexChannelCompressionMask: 4054 167 | iPhoneSdkVersion: 988 168 | iOSTargetOSVersionString: 9.0 169 | tvOSSdkVersion: 0 170 | tvOSRequireExtendedGameController: 0 171 | tvOSTargetOSVersionString: 9.0 172 | uIPrerenderedIcon: 0 173 | uIRequiresPersistentWiFi: 0 174 | uIRequiresFullScreen: 1 175 | uIStatusBarHidden: 1 176 | uIExitOnSuspend: 0 177 | uIStatusBarStyle: 0 178 | iPhoneSplashScreen: {fileID: 0} 179 | iPhoneHighResSplashScreen: {fileID: 0} 180 | iPhoneTallHighResSplashScreen: {fileID: 0} 181 | iPhone47inSplashScreen: {fileID: 0} 182 | iPhone55inPortraitSplashScreen: {fileID: 0} 183 | iPhone55inLandscapeSplashScreen: {fileID: 0} 184 | iPhone58inPortraitSplashScreen: {fileID: 0} 185 | iPhone58inLandscapeSplashScreen: {fileID: 0} 186 | iPadPortraitSplashScreen: {fileID: 0} 187 | iPadHighResPortraitSplashScreen: {fileID: 0} 188 | iPadLandscapeSplashScreen: {fileID: 0} 189 | iPadHighResLandscapeSplashScreen: {fileID: 0} 190 | appleTVSplashScreen: {fileID: 0} 191 | appleTVSplashScreen2x: {fileID: 0} 192 | tvOSSmallIconLayers: [] 193 | tvOSSmallIconLayers2x: [] 194 | tvOSLargeIconLayers: [] 195 | tvOSLargeIconLayers2x: [] 196 | tvOSTopShelfImageLayers: [] 197 | tvOSTopShelfImageLayers2x: [] 198 | tvOSTopShelfImageWideLayers: [] 199 | tvOSTopShelfImageWideLayers2x: [] 200 | iOSLaunchScreenType: 0 201 | iOSLaunchScreenPortrait: {fileID: 0} 202 | iOSLaunchScreenLandscape: {fileID: 0} 203 | iOSLaunchScreenBackgroundColor: 204 | serializedVersion: 2 205 | rgba: 0 206 | iOSLaunchScreenFillPct: 100 207 | iOSLaunchScreenSize: 100 208 | iOSLaunchScreenCustomXibPath: 209 | iOSLaunchScreeniPadType: 0 210 | iOSLaunchScreeniPadImage: {fileID: 0} 211 | iOSLaunchScreeniPadBackgroundColor: 212 | serializedVersion: 2 213 | rgba: 0 214 | iOSLaunchScreeniPadFillPct: 100 215 | iOSLaunchScreeniPadSize: 100 216 | iOSLaunchScreeniPadCustomXibPath: 217 | iOSUseLaunchScreenStoryboard: 0 218 | iOSLaunchScreenCustomStoryboardPath: 219 | iOSDeviceRequirements: [] 220 | iOSURLSchemes: [] 221 | iOSBackgroundModes: 0 222 | iOSMetalForceHardShadows: 0 223 | metalEditorSupport: 1 224 | metalAPIValidation: 1 225 | iOSRenderExtraFrameOnPause: 0 226 | appleDeveloperTeamID: 227 | iOSManualSigningProvisioningProfileID: 228 | tvOSManualSigningProvisioningProfileID: 229 | iOSManualSigningProvisioningProfileType: 0 230 | tvOSManualSigningProvisioningProfileType: 0 231 | appleEnableAutomaticSigning: 0 232 | iOSRequireARKit: 0 233 | appleEnableProMotion: 0 234 | clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea 235 | templatePackageId: com.unity.3d@1.0.2 236 | templateDefaultScene: Assets/Scenes/SampleScene.unity 237 | AndroidTargetArchitectures: 5 238 | AndroidSplashScreenScale: 0 239 | androidSplashScreen: {fileID: 0} 240 | AndroidKeystoreName: 241 | AndroidKeyaliasName: 242 | AndroidBuildApkPerCpuArchitecture: 0 243 | AndroidTVCompatibility: 1 244 | AndroidIsGame: 1 245 | AndroidEnableTango: 0 246 | androidEnableBanner: 1 247 | androidUseLowAccuracyLocation: 0 248 | m_AndroidBanners: 249 | - width: 320 250 | height: 180 251 | banner: {fileID: 0} 252 | androidGamepadSupportLevel: 0 253 | resolutionDialogBanner: {fileID: 0} 254 | m_BuildTargetIcons: [] 255 | m_BuildTargetPlatformIcons: [] 256 | m_BuildTargetBatching: 257 | - m_BuildTarget: Standalone 258 | m_StaticBatching: 1 259 | m_DynamicBatching: 0 260 | - m_BuildTarget: tvOS 261 | m_StaticBatching: 1 262 | m_DynamicBatching: 0 263 | - m_BuildTarget: Android 264 | m_StaticBatching: 1 265 | m_DynamicBatching: 0 266 | - m_BuildTarget: iPhone 267 | m_StaticBatching: 1 268 | m_DynamicBatching: 0 269 | - m_BuildTarget: WebGL 270 | m_StaticBatching: 0 271 | m_DynamicBatching: 0 272 | m_BuildTargetGraphicsAPIs: 273 | - m_BuildTarget: AndroidPlayer 274 | m_APIs: 0b00000015000000 275 | m_Automatic: 1 276 | - m_BuildTarget: iOSSupport 277 | m_APIs: 10000000 278 | m_Automatic: 1 279 | - m_BuildTarget: AppleTVSupport 280 | m_APIs: 10000000 281 | m_Automatic: 0 282 | - m_BuildTarget: WebGLSupport 283 | m_APIs: 0b000000 284 | m_Automatic: 1 285 | m_BuildTargetVRSettings: 286 | - m_BuildTarget: Standalone 287 | m_Enabled: 0 288 | m_Devices: 289 | - Oculus 290 | - OpenVR 291 | m_BuildTargetEnableVuforiaSettings: [] 292 | openGLRequireES31: 0 293 | openGLRequireES31AEP: 0 294 | m_TemplateCustomTags: {} 295 | mobileMTRendering: 296 | Android: 1 297 | iPhone: 1 298 | tvOS: 1 299 | m_BuildTargetGroupLightmapEncodingQuality: [] 300 | m_BuildTargetGroupLightmapSettings: [] 301 | playModeTestRunnerEnabled: 0 302 | runPlayModeTestAsEditModeTest: 0 303 | actionOnDotNetUnhandledException: 1 304 | enableInternalProfiler: 0 305 | logObjCUncaughtExceptions: 1 306 | enableCrashReportAPI: 0 307 | cameraUsageDescription: 308 | locationUsageDescription: 309 | microphoneUsageDescription: 310 | switchNetLibKey: 311 | switchSocketMemoryPoolSize: 6144 312 | switchSocketAllocatorPoolSize: 128 313 | switchSocketConcurrencyLimit: 14 314 | switchScreenResolutionBehavior: 2 315 | switchUseCPUProfiler: 0 316 | switchApplicationID: 0x01004b9000490000 317 | switchNSODependencies: 318 | switchTitleNames_0: 319 | switchTitleNames_1: 320 | switchTitleNames_2: 321 | switchTitleNames_3: 322 | switchTitleNames_4: 323 | switchTitleNames_5: 324 | switchTitleNames_6: 325 | switchTitleNames_7: 326 | switchTitleNames_8: 327 | switchTitleNames_9: 328 | switchTitleNames_10: 329 | switchTitleNames_11: 330 | switchTitleNames_12: 331 | switchTitleNames_13: 332 | switchTitleNames_14: 333 | switchPublisherNames_0: 334 | switchPublisherNames_1: 335 | switchPublisherNames_2: 336 | switchPublisherNames_3: 337 | switchPublisherNames_4: 338 | switchPublisherNames_5: 339 | switchPublisherNames_6: 340 | switchPublisherNames_7: 341 | switchPublisherNames_8: 342 | switchPublisherNames_9: 343 | switchPublisherNames_10: 344 | switchPublisherNames_11: 345 | switchPublisherNames_12: 346 | switchPublisherNames_13: 347 | switchPublisherNames_14: 348 | switchIcons_0: {fileID: 0} 349 | switchIcons_1: {fileID: 0} 350 | switchIcons_2: {fileID: 0} 351 | switchIcons_3: {fileID: 0} 352 | switchIcons_4: {fileID: 0} 353 | switchIcons_5: {fileID: 0} 354 | switchIcons_6: {fileID: 0} 355 | switchIcons_7: {fileID: 0} 356 | switchIcons_8: {fileID: 0} 357 | switchIcons_9: {fileID: 0} 358 | switchIcons_10: {fileID: 0} 359 | switchIcons_11: {fileID: 0} 360 | switchIcons_12: {fileID: 0} 361 | switchIcons_13: {fileID: 0} 362 | switchIcons_14: {fileID: 0} 363 | switchSmallIcons_0: {fileID: 0} 364 | switchSmallIcons_1: {fileID: 0} 365 | switchSmallIcons_2: {fileID: 0} 366 | switchSmallIcons_3: {fileID: 0} 367 | switchSmallIcons_4: {fileID: 0} 368 | switchSmallIcons_5: {fileID: 0} 369 | switchSmallIcons_6: {fileID: 0} 370 | switchSmallIcons_7: {fileID: 0} 371 | switchSmallIcons_8: {fileID: 0} 372 | switchSmallIcons_9: {fileID: 0} 373 | switchSmallIcons_10: {fileID: 0} 374 | switchSmallIcons_11: {fileID: 0} 375 | switchSmallIcons_12: {fileID: 0} 376 | switchSmallIcons_13: {fileID: 0} 377 | switchSmallIcons_14: {fileID: 0} 378 | switchManualHTML: 379 | switchAccessibleURLs: 380 | switchLegalInformation: 381 | switchMainThreadStackSize: 1048576 382 | switchPresenceGroupId: 383 | switchLogoHandling: 0 384 | switchReleaseVersion: 0 385 | switchDisplayVersion: 1.0.0 386 | switchStartupUserAccount: 0 387 | switchTouchScreenUsage: 0 388 | switchSupportedLanguagesMask: 0 389 | switchLogoType: 0 390 | switchApplicationErrorCodeCategory: 391 | switchUserAccountSaveDataSize: 0 392 | switchUserAccountSaveDataJournalSize: 0 393 | switchApplicationAttribute: 0 394 | switchCardSpecSize: -1 395 | switchCardSpecClock: -1 396 | switchRatingsMask: 0 397 | switchRatingsInt_0: 0 398 | switchRatingsInt_1: 0 399 | switchRatingsInt_2: 0 400 | switchRatingsInt_3: 0 401 | switchRatingsInt_4: 0 402 | switchRatingsInt_5: 0 403 | switchRatingsInt_6: 0 404 | switchRatingsInt_7: 0 405 | switchRatingsInt_8: 0 406 | switchRatingsInt_9: 0 407 | switchRatingsInt_10: 0 408 | switchRatingsInt_11: 0 409 | switchLocalCommunicationIds_0: 410 | switchLocalCommunicationIds_1: 411 | switchLocalCommunicationIds_2: 412 | switchLocalCommunicationIds_3: 413 | switchLocalCommunicationIds_4: 414 | switchLocalCommunicationIds_5: 415 | switchLocalCommunicationIds_6: 416 | switchLocalCommunicationIds_7: 417 | switchParentalControl: 0 418 | switchAllowsScreenshot: 1 419 | switchAllowsVideoCapturing: 1 420 | switchAllowsRuntimeAddOnContentInstall: 0 421 | switchDataLossConfirmation: 0 422 | switchUserAccountLockEnabled: 0 423 | switchSupportedNpadStyles: 3 424 | switchNativeFsCacheSize: 32 425 | switchIsHoldTypeHorizontal: 0 426 | switchSupportedNpadCount: 8 427 | switchSocketConfigEnabled: 0 428 | switchTcpInitialSendBufferSize: 32 429 | switchTcpInitialReceiveBufferSize: 64 430 | switchTcpAutoSendBufferSizeMax: 256 431 | switchTcpAutoReceiveBufferSizeMax: 256 432 | switchUdpSendBufferSize: 9 433 | switchUdpReceiveBufferSize: 42 434 | switchSocketBufferEfficiency: 4 435 | switchSocketInitializeEnabled: 1 436 | switchNetworkInterfaceManagerInitializeEnabled: 1 437 | switchPlayerConnectionEnabled: 1 438 | ps4NPAgeRating: 12 439 | ps4NPTitleSecret: 440 | ps4NPTrophyPackPath: 441 | ps4ParentalLevel: 11 442 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 443 | ps4Category: 0 444 | ps4MasterVersion: 01.00 445 | ps4AppVersion: 01.00 446 | ps4AppType: 0 447 | ps4ParamSfxPath: 448 | ps4VideoOutPixelFormat: 0 449 | ps4VideoOutInitialWidth: 1920 450 | ps4VideoOutBaseModeInitialWidth: 1920 451 | ps4VideoOutReprojectionRate: 60 452 | ps4PronunciationXMLPath: 453 | ps4PronunciationSIGPath: 454 | ps4BackgroundImagePath: 455 | ps4StartupImagePath: 456 | ps4StartupImagesFolder: 457 | ps4IconImagesFolder: 458 | ps4SaveDataImagePath: 459 | ps4SdkOverride: 460 | ps4BGMPath: 461 | ps4ShareFilePath: 462 | ps4ShareOverlayImagePath: 463 | ps4PrivacyGuardImagePath: 464 | ps4NPtitleDatPath: 465 | ps4RemotePlayKeyAssignment: -1 466 | ps4RemotePlayKeyMappingDir: 467 | ps4PlayTogetherPlayerCount: 0 468 | ps4EnterButtonAssignment: 1 469 | ps4ApplicationParam1: 0 470 | ps4ApplicationParam2: 0 471 | ps4ApplicationParam3: 0 472 | ps4ApplicationParam4: 0 473 | ps4DownloadDataSize: 0 474 | ps4GarlicHeapSize: 2048 475 | ps4ProGarlicHeapSize: 2560 476 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ 477 | ps4pnSessions: 1 478 | ps4pnPresence: 1 479 | ps4pnFriends: 1 480 | ps4pnGameCustomData: 1 481 | playerPrefsSupport: 0 482 | enableApplicationExit: 0 483 | resetTempFolder: 1 484 | restrictedAudioUsageRights: 0 485 | ps4UseResolutionFallback: 0 486 | ps4ReprojectionSupport: 0 487 | ps4UseAudio3dBackend: 0 488 | ps4SocialScreenEnabled: 0 489 | ps4ScriptOptimizationLevel: 0 490 | ps4Audio3dVirtualSpeakerCount: 14 491 | ps4attribCpuUsage: 0 492 | ps4PatchPkgPath: 493 | ps4PatchLatestPkgPath: 494 | ps4PatchChangeinfoPath: 495 | ps4PatchDayOne: 0 496 | ps4attribUserManagement: 0 497 | ps4attribMoveSupport: 0 498 | ps4attrib3DSupport: 0 499 | ps4attribShareSupport: 0 500 | ps4attribExclusiveVR: 0 501 | ps4disableAutoHideSplash: 0 502 | ps4videoRecordingFeaturesUsed: 0 503 | ps4contentSearchFeaturesUsed: 0 504 | ps4attribEyeToEyeDistanceSettingVR: 0 505 | ps4IncludedModules: [] 506 | monoEnv: 507 | splashScreenBackgroundSourceLandscape: {fileID: 0} 508 | splashScreenBackgroundSourcePortrait: {fileID: 0} 509 | spritePackerPolicy: 510 | webGLMemorySize: 256 511 | webGLExceptionSupport: 1 512 | webGLNameFilesAsHashes: 0 513 | webGLDataCaching: 1 514 | webGLDebugSymbols: 0 515 | webGLEmscriptenArgs: 516 | webGLModulesDirectory: 517 | webGLTemplate: APPLICATION:Default 518 | webGLAnalyzeBuildSize: 0 519 | webGLUseEmbeddedResources: 0 520 | webGLCompressionFormat: 1 521 | webGLLinkerTarget: 1 522 | webGLThreadsSupport: 0 523 | scriptingDefineSymbols: {} 524 | platformArchitecture: {} 525 | scriptingBackend: 526 | Standalone: 1 527 | il2cppCompilerConfiguration: {} 528 | managedStrippingLevel: {} 529 | incrementalIl2cppBuild: {} 530 | allowUnsafeCode: 0 531 | additionalIl2CppArgs: 532 | scriptingRuntimeVersion: 1 533 | apiCompatibilityLevelPerPlatform: 534 | Standalone: 3 535 | m_RenderingPath: 1 536 | m_MobileRenderingPath: 1 537 | metroPackageName: Template_3D 538 | metroPackageVersion: 539 | metroCertificatePath: 540 | metroCertificatePassword: 541 | metroCertificateSubject: 542 | metroCertificateIssuer: 543 | metroCertificateNotAfter: 0000000000000000 544 | metroApplicationDescription: Template_3D 545 | wsaImages: {} 546 | metroTileShortName: 547 | metroTileShowName: 0 548 | metroMediumTileShowName: 0 549 | metroLargeTileShowName: 0 550 | metroWideTileShowName: 0 551 | metroSupportStreamingInstall: 0 552 | metroLastRequiredScene: 0 553 | metroDefaultTileSize: 1 554 | metroTileForegroundText: 2 555 | metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} 556 | metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, 557 | a: 1} 558 | metroSplashScreenUseBackgroundColor: 0 559 | platformCapabilities: {} 560 | metroTargetDeviceFamilies: {} 561 | metroFTAName: 562 | metroFTAFileTypes: [] 563 | metroProtocolName: 564 | metroCompilationOverrides: 1 565 | XboxOneProductId: 566 | XboxOneUpdateKey: 567 | XboxOneSandboxId: 568 | XboxOneContentId: 569 | XboxOneTitleId: 570 | XboxOneSCId: 571 | XboxOneGameOsOverridePath: 572 | XboxOnePackagingOverridePath: 573 | XboxOneAppManifestOverridePath: 574 | XboxOneVersion: 1.0.0.0 575 | XboxOnePackageEncryption: 0 576 | XboxOnePackageUpdateGranularity: 2 577 | XboxOneDescription: 578 | XboxOneLanguage: 579 | - enus 580 | XboxOneCapability: [] 581 | XboxOneGameRating: {} 582 | XboxOneIsContentPackage: 0 583 | XboxOneEnableGPUVariability: 0 584 | XboxOneSockets: {} 585 | XboxOneSplashScreen: {fileID: 0} 586 | XboxOneAllowedProductIds: [] 587 | XboxOnePersistentLocalStorageSize: 0 588 | XboxOneXTitleMemory: 8 589 | xboxOneScriptCompiler: 0 590 | XboxOneOverrideIdentityName: 591 | vrEditorSettings: 592 | daydream: 593 | daydreamIconForeground: {fileID: 0} 594 | daydreamIconBackground: {fileID: 0} 595 | cloudServicesEnabled: 596 | UNet: 1 597 | luminIcon: 598 | m_Name: 599 | m_ModelFolderPath: 600 | m_PortalFolderPath: 601 | luminCert: 602 | m_CertPath: 603 | m_PrivateKeyPath: 604 | luminIsChannelApp: 0 605 | luminVersion: 606 | m_VersionCode: 1 607 | m_VersionName: 608 | facebookSdkVersion: 7.9.4 609 | facebookAppId: 610 | facebookCookies: 1 611 | facebookLogging: 1 612 | facebookStatus: 1 613 | facebookXfbml: 0 614 | facebookFrictionlessRequests: 1 615 | apiCompatibilityLevel: 3 616 | cloudProjectId: 617 | framebufferDepthMemorylessMode: 0 618 | projectName: 619 | organizationId: 620 | cloudEnabled: 0 621 | enableNativePlatformBackendsForNewInputSystem: 0 622 | disableOldInputManagerSupport: 0 623 | legacyClampBlendShapeWeights: 1 624 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/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 | -------------------------------------------------------------------------------- /Assets/Plugins/LitJson/JsonMapper.cs: -------------------------------------------------------------------------------- 1 | #region Header 2 | /** 3 | * JsonMapper.cs 4 | * JSON to .Net object and object to JSON conversions. 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; 14 | using System.Collections.Generic; 15 | using System.Globalization; 16 | using System.IO; 17 | using System.Reflection; 18 | using LitJson.Extensions; 19 | 20 | 21 | namespace LitJson 22 | { 23 | internal struct PropertyMetadata 24 | { 25 | public MemberInfo Info; 26 | public bool IsField; 27 | public Type Type; 28 | } 29 | 30 | 31 | internal struct ArrayMetadata 32 | { 33 | private Type element_type; 34 | private bool is_array; 35 | private bool is_list; 36 | 37 | 38 | public Type ElementType 39 | { 40 | get 41 | { 42 | if (element_type == null) 43 | return typeof(JsonData); 44 | 45 | return element_type; 46 | } 47 | 48 | set { element_type = value; } 49 | } 50 | 51 | public bool IsArray 52 | { 53 | get { return is_array; } 54 | set { is_array = value; } 55 | } 56 | 57 | public bool IsList 58 | { 59 | get { return is_list; } 60 | set { is_list = value; } 61 | } 62 | } 63 | 64 | 65 | internal struct ObjectMetadata 66 | { 67 | private Type element_type; 68 | private bool is_dictionary; 69 | 70 | private IDictionary properties; 71 | 72 | 73 | public Type ElementType 74 | { 75 | get 76 | { 77 | if (element_type == null) 78 | return typeof(JsonData); 79 | 80 | return element_type; 81 | } 82 | 83 | set { element_type = value; } 84 | } 85 | 86 | public bool IsDictionary 87 | { 88 | get { return is_dictionary; } 89 | set { is_dictionary = value; } 90 | } 91 | 92 | public IDictionary Properties 93 | { 94 | get { return properties; } 95 | set { properties = value; } 96 | } 97 | } 98 | 99 | 100 | internal delegate void ExporterFunc(object obj, JsonWriter writer); 101 | public delegate void ExporterFunc(T obj, JsonWriter writer); 102 | 103 | internal delegate object ImporterFunc(object input); 104 | public delegate TValue ImporterFunc(TJson input); 105 | 106 | public delegate IJsonWrapper WrapperFactory(); 107 | 108 | 109 | public class JsonMapper 110 | { 111 | #region Fields 112 | private static readonly int max_nesting_depth; 113 | 114 | private static readonly IFormatProvider datetime_format; 115 | 116 | private static readonly IDictionary base_exporters_table; 117 | private static readonly IDictionary custom_exporters_table; 118 | 119 | private static readonly IDictionary> base_importers_table; 121 | private static readonly IDictionary> custom_importers_table; 123 | 124 | private static readonly IDictionary array_metadata; 125 | private static readonly object array_metadata_lock = new Object(); 126 | 127 | private static readonly IDictionary> conv_ops; 129 | private static readonly object conv_ops_lock = new Object(); 130 | 131 | private static readonly IDictionary object_metadata; 132 | private static readonly object object_metadata_lock = new Object(); 133 | 134 | private static readonly IDictionary> type_properties; 136 | private static readonly object type_properties_lock = new Object(); 137 | 138 | private static readonly JsonWriter static_writer; 139 | private static readonly object static_writer_lock = new Object(); 140 | #endregion 141 | 142 | 143 | #region Constructors 144 | static JsonMapper() 145 | { 146 | max_nesting_depth = 100; 147 | 148 | array_metadata = new Dictionary(); 149 | conv_ops = new Dictionary>(); 150 | object_metadata = new Dictionary(); 151 | type_properties = new Dictionary>(); 153 | 154 | static_writer = new JsonWriter(); 155 | 156 | datetime_format = DateTimeFormatInfo.InvariantInfo; 157 | 158 | base_exporters_table = new Dictionary(); 159 | custom_exporters_table = new Dictionary(); 160 | 161 | base_importers_table = new Dictionary>(); 163 | custom_importers_table = new Dictionary>(); 165 | 166 | RegisterBaseExporters(); 167 | RegisterBaseImporters(); 168 | } 169 | #endregion 170 | 171 | 172 | #region Private Methods 173 | private static void AddArrayMetadata(Type type) 174 | { 175 | if (array_metadata.ContainsKey(type)) 176 | return; 177 | 178 | ArrayMetadata data = new ArrayMetadata(); 179 | 180 | data.IsArray = type.IsArray; 181 | 182 | if (type.GetInterface("System.Collections.IList") != null) 183 | data.IsList = true; 184 | 185 | foreach (PropertyInfo p_info in type.GetProperties()) 186 | { 187 | if (p_info.Name != "Item") 188 | continue; 189 | 190 | ParameterInfo[] parameters = p_info.GetIndexParameters(); 191 | 192 | if (parameters.Length != 1) 193 | continue; 194 | 195 | if (parameters[0].ParameterType == typeof(int)) 196 | data.ElementType = p_info.PropertyType; 197 | } 198 | 199 | lock (array_metadata_lock) 200 | { 201 | try 202 | { 203 | array_metadata.Add(type, data); 204 | } 205 | catch (ArgumentException) 206 | { 207 | return; 208 | } 209 | } 210 | } 211 | 212 | private static void AddObjectMetadata(Type type) 213 | { 214 | if (object_metadata.ContainsKey(type)) 215 | return; 216 | 217 | ObjectMetadata data = new ObjectMetadata(); 218 | 219 | if (type.GetInterface("System.Collections.IDictionary") != null) 220 | data.IsDictionary = true; 221 | 222 | data.Properties = new Dictionary(); 223 | 224 | foreach (PropertyInfo p_info in type.GetProperties()) 225 | { 226 | if (p_info.Name == "Item") 227 | { 228 | ParameterInfo[] parameters = p_info.GetIndexParameters(); 229 | 230 | if (parameters.Length != 1) 231 | continue; 232 | 233 | if (parameters[0].ParameterType == typeof(string)) 234 | data.ElementType = p_info.PropertyType; 235 | 236 | continue; 237 | } 238 | 239 | PropertyMetadata p_data = new PropertyMetadata(); 240 | p_data.Info = p_info; 241 | p_data.Type = p_info.PropertyType; 242 | 243 | data.Properties.Add(p_info.Name, p_data); 244 | } 245 | 246 | foreach (FieldInfo f_info in type.GetFields()) 247 | { 248 | PropertyMetadata p_data = new PropertyMetadata(); 249 | p_data.Info = f_info; 250 | p_data.IsField = true; 251 | p_data.Type = f_info.FieldType; 252 | 253 | data.Properties.Add(f_info.Name, p_data); 254 | } 255 | 256 | lock (object_metadata_lock) 257 | { 258 | try 259 | { 260 | object_metadata.Add(type, data); 261 | } 262 | catch (ArgumentException) 263 | { 264 | return; 265 | } 266 | } 267 | } 268 | 269 | private static void AddTypeProperties(Type type) 270 | { 271 | if (type_properties.ContainsKey(type)) 272 | return; 273 | 274 | IList props = new List(); 275 | 276 | foreach (PropertyInfo p_info in type.GetProperties()) 277 | { 278 | if (p_info.Name == "Item") 279 | continue; 280 | 281 | PropertyMetadata p_data = new PropertyMetadata(); 282 | p_data.Info = p_info; 283 | p_data.IsField = false; 284 | props.Add(p_data); 285 | } 286 | 287 | foreach (FieldInfo f_info in type.GetFields()) 288 | { 289 | PropertyMetadata p_data = new PropertyMetadata(); 290 | p_data.Info = f_info; 291 | p_data.IsField = true; 292 | 293 | props.Add(p_data); 294 | } 295 | 296 | lock (type_properties_lock) 297 | { 298 | try 299 | { 300 | type_properties.Add(type, props); 301 | } 302 | catch (ArgumentException) 303 | { 304 | return; 305 | } 306 | } 307 | } 308 | 309 | private static MethodInfo GetConvOp(Type t1, Type t2) 310 | { 311 | lock (conv_ops_lock) 312 | { 313 | if (!conv_ops.ContainsKey(t1)) 314 | conv_ops.Add(t1, new Dictionary()); 315 | } 316 | 317 | if (conv_ops[t1].ContainsKey(t2)) 318 | return conv_ops[t1][t2]; 319 | 320 | MethodInfo op = t1.GetMethod( 321 | "op_Implicit", new Type[] { t2 }); 322 | 323 | lock (conv_ops_lock) 324 | { 325 | try 326 | { 327 | conv_ops[t1].Add(t2, op); 328 | } 329 | catch (ArgumentException) 330 | { 331 | return conv_ops[t1][t2]; 332 | } 333 | } 334 | 335 | return op; 336 | } 337 | 338 | private static object ReadValue(Type inst_type, JsonReader reader) 339 | { 340 | reader.Read(); 341 | 342 | if (reader.Token == JsonToken.ArrayEnd) 343 | return null; 344 | 345 | Type underlying_type = Nullable.GetUnderlyingType(inst_type); 346 | Type value_type = underlying_type ?? inst_type; 347 | 348 | if (reader.Token == JsonToken.Null) 349 | { 350 | #if NETSTANDARD1_5 351 | if (inst_type.IsClass() || underlying_type != null) { 352 | return null; 353 | } 354 | #else 355 | if (inst_type.IsClass || underlying_type != null) 356 | { 357 | return null; 358 | } 359 | #endif 360 | 361 | throw new JsonException(String.Format( 362 | "Can't assign null to an instance of type {0}", 363 | inst_type)); 364 | } 365 | 366 | if (reader.Token == JsonToken.Double || 367 | reader.Token == JsonToken.Int || 368 | reader.Token == JsonToken.Long || 369 | reader.Token == JsonToken.String || 370 | reader.Token == JsonToken.Boolean) 371 | { 372 | 373 | Type json_type = reader.Value.GetType(); 374 | 375 | if (value_type.IsAssignableFrom(json_type)) 376 | return reader.Value; 377 | 378 | // If there's a custom importer that fits, use it 379 | if (custom_importers_table.ContainsKey(json_type) && 380 | custom_importers_table[json_type].ContainsKey( 381 | value_type)) 382 | { 383 | 384 | ImporterFunc importer = 385 | custom_importers_table[json_type][value_type]; 386 | 387 | return importer(reader.Value); 388 | } 389 | 390 | // Maybe there's a base importer that works 391 | if (base_importers_table.ContainsKey(json_type) && 392 | base_importers_table[json_type].ContainsKey( 393 | value_type)) 394 | { 395 | 396 | ImporterFunc importer = 397 | base_importers_table[json_type][value_type]; 398 | 399 | return importer(reader.Value); 400 | } 401 | 402 | // Maybe it's an enum 403 | #if NETSTANDARD1_5 404 | if (value_type.IsEnum()) 405 | return Enum.ToObject (value_type, reader.Value); 406 | #else 407 | if (value_type.IsEnum) 408 | return Enum.ToObject(value_type, reader.Value); 409 | #endif 410 | // Try using an implicit conversion operator 411 | MethodInfo conv_op = GetConvOp(value_type, json_type); 412 | 413 | if (conv_op != null) 414 | return conv_op.Invoke(null, 415 | new object[] { reader.Value }); 416 | 417 | // No luck 418 | throw new JsonException(String.Format( 419 | "Can't assign value '{0}' (type {1}) to type {2}", 420 | reader.Value, json_type, inst_type)); 421 | } 422 | 423 | object instance = null; 424 | 425 | if (reader.Token == JsonToken.ArrayStart) 426 | { 427 | 428 | AddArrayMetadata(inst_type); 429 | ArrayMetadata t_data = array_metadata[inst_type]; 430 | 431 | if (!t_data.IsArray && !t_data.IsList) 432 | throw new JsonException(String.Format( 433 | "Type {0} can't act as an array", 434 | inst_type)); 435 | 436 | IList list; 437 | Type elem_type; 438 | 439 | if (!t_data.IsArray) 440 | { 441 | list = (IList)Activator.CreateInstance(inst_type); 442 | elem_type = t_data.ElementType; 443 | } 444 | else 445 | { 446 | list = new ArrayList(); 447 | elem_type = inst_type.GetElementType(); 448 | } 449 | 450 | while (true) 451 | { 452 | object item = ReadValue(elem_type, reader); 453 | if (item == null && reader.Token == JsonToken.ArrayEnd) 454 | break; 455 | 456 | list.Add(item); 457 | } 458 | 459 | if (t_data.IsArray) 460 | { 461 | int n = list.Count; 462 | instance = Array.CreateInstance(elem_type, n); 463 | 464 | for (int i = 0; i < n; i++) 465 | ((Array)instance).SetValue(list[i], i); 466 | } 467 | else 468 | instance = list; 469 | 470 | } 471 | else if (reader.Token == JsonToken.ObjectStart) 472 | { 473 | AddObjectMetadata(value_type); 474 | ObjectMetadata t_data = object_metadata[value_type]; 475 | 476 | instance = Activator.CreateInstance(value_type); 477 | 478 | while (true) 479 | { 480 | reader.Read(); 481 | 482 | if (reader.Token == JsonToken.ObjectEnd) 483 | break; 484 | 485 | string property = (string)reader.Value; 486 | 487 | if (t_data.Properties.ContainsKey(property)) 488 | { 489 | PropertyMetadata prop_data = 490 | t_data.Properties[property]; 491 | 492 | if (prop_data.IsField) 493 | { 494 | ((FieldInfo)prop_data.Info).SetValue( 495 | instance, ReadValue(prop_data.Type, reader)); 496 | } 497 | else 498 | { 499 | PropertyInfo p_info = 500 | (PropertyInfo)prop_data.Info; 501 | 502 | if (p_info.CanWrite) 503 | p_info.SetValue( 504 | instance, 505 | ReadValue(prop_data.Type, reader), 506 | null); 507 | else 508 | ReadValue(prop_data.Type, reader); 509 | } 510 | 511 | } 512 | else 513 | { 514 | if (!t_data.IsDictionary) 515 | { 516 | 517 | if (!reader.SkipNonMembers) 518 | { 519 | throw new JsonException(String.Format( 520 | "The type {0} doesn't have the " + 521 | "property '{1}'", 522 | inst_type, property)); 523 | } 524 | else 525 | { 526 | ReadSkip(reader); 527 | continue; 528 | } 529 | } 530 | 531 | ((IDictionary)instance).Add( 532 | property, ReadValue( 533 | t_data.ElementType, reader)); 534 | } 535 | 536 | } 537 | 538 | } 539 | 540 | return instance; 541 | } 542 | 543 | private static IJsonWrapper ReadValue(WrapperFactory factory, 544 | JsonReader reader) 545 | { 546 | reader.Read(); 547 | 548 | if (reader.Token == JsonToken.ArrayEnd || 549 | reader.Token == JsonToken.Null) 550 | return null; 551 | 552 | IJsonWrapper instance = factory(); 553 | 554 | if (reader.Token == JsonToken.String) 555 | { 556 | instance.SetString((string)reader.Value); 557 | return instance; 558 | } 559 | 560 | if (reader.Token == JsonToken.Double) 561 | { 562 | instance.SetDouble((double)reader.Value); 563 | return instance; 564 | } 565 | 566 | if (reader.Token == JsonToken.Int) 567 | { 568 | instance.SetInt((int)reader.Value); 569 | return instance; 570 | } 571 | 572 | if (reader.Token == JsonToken.Long) 573 | { 574 | instance.SetLong((long)reader.Value); 575 | return instance; 576 | } 577 | 578 | if (reader.Token == JsonToken.Boolean) 579 | { 580 | instance.SetBoolean((bool)reader.Value); 581 | return instance; 582 | } 583 | 584 | if (reader.Token == JsonToken.ArrayStart) 585 | { 586 | instance.SetJsonType(JsonType.Array); 587 | 588 | while (true) 589 | { 590 | IJsonWrapper item = ReadValue(factory, reader); 591 | if (item == null && reader.Token == JsonToken.ArrayEnd) 592 | break; 593 | 594 | ((IList)instance).Add(item); 595 | } 596 | } 597 | else if (reader.Token == JsonToken.ObjectStart) 598 | { 599 | instance.SetJsonType(JsonType.Object); 600 | 601 | while (true) 602 | { 603 | reader.Read(); 604 | 605 | if (reader.Token == JsonToken.ObjectEnd) 606 | break; 607 | 608 | string property = (string)reader.Value; 609 | 610 | ((IDictionary)instance)[property] = ReadValue( 611 | factory, reader); 612 | } 613 | 614 | } 615 | 616 | return instance; 617 | } 618 | 619 | private static void ReadSkip(JsonReader reader) 620 | { 621 | ToWrapper( 622 | delegate { return new JsonMockWrapper(); }, reader); 623 | } 624 | 625 | private static void RegisterBaseExporters() 626 | { 627 | base_exporters_table[typeof(byte)] = 628 | delegate (object obj, JsonWriter writer) 629 | { 630 | writer.Write(Convert.ToInt32((byte)obj)); 631 | }; 632 | 633 | base_exporters_table[typeof(char)] = 634 | delegate (object obj, JsonWriter writer) 635 | { 636 | writer.Write(Convert.ToString((char)obj)); 637 | }; 638 | 639 | base_exporters_table[typeof(DateTime)] = 640 | delegate (object obj, JsonWriter writer) 641 | { 642 | writer.Write(Convert.ToString((DateTime)obj, 643 | datetime_format)); 644 | }; 645 | 646 | base_exporters_table[typeof(decimal)] = 647 | delegate (object obj, JsonWriter writer) 648 | { 649 | writer.Write((decimal)obj); 650 | }; 651 | 652 | base_exporters_table[typeof(sbyte)] = 653 | delegate (object obj, JsonWriter writer) 654 | { 655 | writer.Write(Convert.ToInt32((sbyte)obj)); 656 | }; 657 | 658 | base_exporters_table[typeof(short)] = 659 | delegate (object obj, JsonWriter writer) 660 | { 661 | writer.Write(Convert.ToInt32((short)obj)); 662 | }; 663 | 664 | base_exporters_table[typeof(ushort)] = 665 | delegate (object obj, JsonWriter writer) 666 | { 667 | writer.Write(Convert.ToInt32((ushort)obj)); 668 | }; 669 | 670 | base_exporters_table[typeof(uint)] = 671 | delegate (object obj, JsonWriter writer) 672 | { 673 | writer.Write(Convert.ToUInt64((uint)obj)); 674 | }; 675 | 676 | base_exporters_table[typeof(ulong)] = 677 | delegate (object obj, JsonWriter writer) 678 | { 679 | writer.Write((ulong)obj); 680 | }; 681 | 682 | base_exporters_table[typeof(DateTimeOffset)] = 683 | delegate (object obj, JsonWriter writer) 684 | { 685 | writer.Write(((DateTimeOffset)obj).ToString("yyyy-MM-ddTHH:mm:ss.fffffffzzz", datetime_format)); 686 | }; 687 | } 688 | 689 | private static void RegisterBaseImporters() 690 | { 691 | ImporterFunc importer; 692 | 693 | importer = delegate (object input) 694 | { 695 | return Convert.ToByte((int)input); 696 | }; 697 | RegisterImporter(base_importers_table, typeof(int), 698 | typeof(byte), importer); 699 | 700 | importer = delegate (object input) 701 | { 702 | return Convert.ToUInt64((int)input); 703 | }; 704 | RegisterImporter(base_importers_table, typeof(int), 705 | typeof(ulong), importer); 706 | 707 | importer = delegate (object input) 708 | { 709 | return Convert.ToInt64((int)input); 710 | }; 711 | RegisterImporter(base_importers_table, typeof(int), 712 | typeof(long), importer); 713 | 714 | importer = delegate (object input) 715 | { 716 | return Convert.ToSByte((int)input); 717 | }; 718 | RegisterImporter(base_importers_table, typeof(int), 719 | typeof(sbyte), importer); 720 | 721 | importer = delegate (object input) 722 | { 723 | return Convert.ToInt16((int)input); 724 | }; 725 | RegisterImporter(base_importers_table, typeof(int), 726 | typeof(short), importer); 727 | 728 | importer = delegate (object input) 729 | { 730 | return Convert.ToUInt16((int)input); 731 | }; 732 | RegisterImporter(base_importers_table, typeof(int), 733 | typeof(ushort), importer); 734 | 735 | importer = delegate (object input) 736 | { 737 | return Convert.ToUInt32((int)input); 738 | }; 739 | RegisterImporter(base_importers_table, typeof(int), 740 | typeof(uint), importer); 741 | 742 | importer = delegate (object input) 743 | { 744 | return Convert.ToSingle((int)input); 745 | }; 746 | RegisterImporter(base_importers_table, typeof(int), 747 | typeof(float), importer); 748 | 749 | importer = delegate (object input) 750 | { 751 | return Convert.ToDouble((int)input); 752 | }; 753 | RegisterImporter(base_importers_table, typeof(int), 754 | typeof(double), importer); 755 | 756 | importer = delegate (object input) 757 | { 758 | return Convert.ToDecimal((double)input); 759 | }; 760 | RegisterImporter(base_importers_table, typeof(double), 761 | typeof(decimal), importer); 762 | 763 | importer = delegate (object input) 764 | { 765 | return Convert.ToSingle((double)input); 766 | }; 767 | RegisterImporter(base_importers_table, typeof(double), 768 | typeof(float), importer); 769 | 770 | importer = delegate (object input) 771 | { 772 | return Convert.ToUInt32((long)input); 773 | }; 774 | RegisterImporter(base_importers_table, typeof(long), 775 | typeof(uint), importer); 776 | 777 | importer = delegate (object input) 778 | { 779 | return Convert.ToChar((string)input); 780 | }; 781 | RegisterImporter(base_importers_table, typeof(string), 782 | typeof(char), importer); 783 | 784 | importer = delegate (object input) 785 | { 786 | return Convert.ToDateTime((string)input, datetime_format); 787 | }; 788 | RegisterImporter(base_importers_table, typeof(string), 789 | typeof(DateTime), importer); 790 | 791 | importer = delegate (object input) 792 | { 793 | return DateTimeOffset.Parse((string)input, datetime_format); 794 | }; 795 | RegisterImporter(base_importers_table, typeof(string), 796 | typeof(DateTimeOffset), importer); 797 | } 798 | 799 | private static void RegisterImporter( 800 | IDictionary> table, 801 | Type json_type, Type value_type, ImporterFunc importer) 802 | { 803 | if (!table.ContainsKey(json_type)) 804 | table.Add(json_type, new Dictionary()); 805 | 806 | table[json_type][value_type] = importer; 807 | } 808 | 809 | private static void WriteValue(object obj, JsonWriter writer, 810 | bool writer_is_private, 811 | int depth) 812 | { 813 | if (depth > max_nesting_depth) 814 | throw new JsonException( 815 | String.Format("Max allowed object depth reached while " + 816 | "trying to export from type {0}", 817 | obj.GetType())); 818 | 819 | if (obj == null) 820 | { 821 | writer.Write(null); 822 | return; 823 | } 824 | 825 | if (obj is IJsonWrapper) 826 | { 827 | if (writer_is_private) 828 | writer.TextWriter.Write(((IJsonWrapper)obj).ToJson()); 829 | else 830 | ((IJsonWrapper)obj).ToJson(writer); 831 | 832 | return; 833 | } 834 | 835 | if (obj is String) 836 | { 837 | writer.Write((string)obj); 838 | return; 839 | } 840 | 841 | if (obj is Double) 842 | { 843 | writer.Write((double)obj); 844 | return; 845 | } 846 | 847 | if (obj is Single) 848 | { 849 | writer.Write((float)obj); 850 | return; 851 | } 852 | 853 | if (obj is Int32) 854 | { 855 | writer.Write((int)obj); 856 | return; 857 | } 858 | 859 | if (obj is Boolean) 860 | { 861 | writer.Write((bool)obj); 862 | return; 863 | } 864 | 865 | if (obj is Int64) 866 | { 867 | writer.Write((long)obj); 868 | return; 869 | } 870 | 871 | if (obj is Array) 872 | { 873 | writer.WriteArrayStart(); 874 | 875 | foreach (object elem in (Array)obj) 876 | WriteValue(elem, writer, writer_is_private, depth + 1); 877 | 878 | writer.WriteArrayEnd(); 879 | 880 | return; 881 | } 882 | 883 | if (obj is IList) 884 | { 885 | writer.WriteArrayStart(); 886 | foreach (object elem in (IList)obj) 887 | WriteValue(elem, writer, writer_is_private, depth + 1); 888 | writer.WriteArrayEnd(); 889 | 890 | return; 891 | } 892 | 893 | #if UNITY_2018_3_OR_NEWER 894 | if (obj is IDictionary dictionary) { 895 | #else 896 | if (obj is IDictionary) 897 | { 898 | var dictionary = obj as IDictionary; 899 | #endif 900 | writer.WriteObjectStart(); 901 | foreach (DictionaryEntry entry in dictionary) 902 | { 903 | #if UNITY_2018_3_OR_NEWER 904 | var propertyName = entry.Key is string key ? 905 | key 906 | : Convert.ToString(entry.Key, CultureInfo.InvariantCulture); 907 | #else 908 | var propertyName = entry.Key is string ? (entry.Key as string) : Convert.ToString(entry.Key, CultureInfo.InvariantCulture); 909 | #endif 910 | writer.WritePropertyName(propertyName); 911 | WriteValue(entry.Value, writer, writer_is_private, 912 | depth + 1); 913 | } 914 | writer.WriteObjectEnd(); 915 | 916 | return; 917 | } 918 | 919 | Type obj_type = obj.GetType(); 920 | 921 | // See if there's a custom exporter for the object 922 | if (custom_exporters_table.ContainsKey(obj_type)) 923 | { 924 | ExporterFunc exporter = custom_exporters_table[obj_type]; 925 | exporter(obj, writer); 926 | 927 | return; 928 | } 929 | 930 | // If not, maybe there's a base exporter 931 | if (base_exporters_table.ContainsKey(obj_type)) 932 | { 933 | ExporterFunc exporter = base_exporters_table[obj_type]; 934 | exporter(obj, writer); 935 | 936 | return; 937 | } 938 | 939 | // Last option, let's see if it's an enum 940 | if (obj is Enum) 941 | { 942 | Type e_type = Enum.GetUnderlyingType(obj_type); 943 | 944 | if (e_type == typeof(long) 945 | || e_type == typeof(uint) 946 | || e_type == typeof(ulong)) 947 | writer.Write((ulong)obj); 948 | else 949 | writer.Write((int)obj); 950 | 951 | return; 952 | } 953 | 954 | // Okay, so it looks like the input should be exported as an 955 | // object 956 | AddTypeProperties(obj_type); 957 | IList props = type_properties[obj_type]; 958 | 959 | writer.WriteObjectStart(); 960 | foreach (PropertyMetadata p_data in props) 961 | { 962 | var skipAttributesList = p_data.Info.GetCustomAttributes(typeof(JsonIgnore), true); 963 | var skipAttributes = skipAttributesList as ICollection; 964 | if (skipAttributes.Count > 0) 965 | { 966 | continue; 967 | } 968 | if (p_data.IsField) 969 | { 970 | writer.WritePropertyName(p_data.Info.Name); 971 | WriteValue(((FieldInfo)p_data.Info).GetValue(obj), 972 | writer, writer_is_private, depth + 1); 973 | } 974 | else 975 | { 976 | PropertyInfo p_info = (PropertyInfo)p_data.Info; 977 | 978 | if (p_info.CanRead) 979 | { 980 | writer.WritePropertyName(p_data.Info.Name); 981 | WriteValue(p_info.GetValue(obj, null), 982 | writer, writer_is_private, depth + 1); 983 | } 984 | } 985 | } 986 | writer.WriteObjectEnd(); 987 | } 988 | #endregion 989 | 990 | 991 | public static string ToJson(object obj, bool prettyPrint = true) 992 | { 993 | lock (static_writer_lock) 994 | { 995 | static_writer.PrettyPrint = prettyPrint; 996 | 997 | static_writer.Reset(); 998 | 999 | WriteValue(obj, static_writer, true, 0); 1000 | 1001 | return static_writer.ToString(); 1002 | } 1003 | } 1004 | 1005 | public static void ToJson(object obj, JsonWriter writer) 1006 | { 1007 | WriteValue(obj, writer, false, 0); 1008 | } 1009 | 1010 | public static JsonData ToObject(JsonReader reader) 1011 | { 1012 | return (JsonData)ToWrapper( 1013 | delegate { return new JsonData(); }, reader); 1014 | } 1015 | 1016 | public static JsonData ToObject(TextReader reader) 1017 | { 1018 | JsonReader json_reader = new JsonReader(reader); 1019 | 1020 | return (JsonData)ToWrapper( 1021 | delegate { return new JsonData(); }, json_reader); 1022 | } 1023 | 1024 | public static JsonData ToObject(string json) 1025 | { 1026 | return (JsonData)ToWrapper( 1027 | delegate { return new JsonData(); }, json); 1028 | } 1029 | 1030 | public static T ToObject(JsonReader reader) 1031 | { 1032 | return (T)ReadValue(typeof(T), reader); 1033 | } 1034 | 1035 | public static T ToObject(TextReader reader) 1036 | { 1037 | JsonReader json_reader = new JsonReader(reader); 1038 | 1039 | return (T)ReadValue(typeof(T), json_reader); 1040 | } 1041 | 1042 | public static T ToObject(string json) 1043 | { 1044 | JsonReader reader = new JsonReader(json); 1045 | 1046 | return (T)ReadValue(typeof(T), reader); 1047 | } 1048 | 1049 | public static object ToObject(string json, Type ConvertType) 1050 | { 1051 | JsonReader reader = new JsonReader(json); 1052 | 1053 | return ReadValue(ConvertType, reader); 1054 | } 1055 | 1056 | public static IJsonWrapper ToWrapper(WrapperFactory factory, 1057 | JsonReader reader) 1058 | { 1059 | return ReadValue(factory, reader); 1060 | } 1061 | 1062 | public static IJsonWrapper ToWrapper(WrapperFactory factory, 1063 | string json) 1064 | { 1065 | JsonReader reader = new JsonReader(json); 1066 | 1067 | return ReadValue(factory, reader); 1068 | } 1069 | 1070 | public static void RegisterExporter(ExporterFunc exporter) 1071 | { 1072 | ExporterFunc exporter_wrapper = 1073 | delegate (object obj, JsonWriter writer) 1074 | { 1075 | exporter((T)obj, writer); 1076 | }; 1077 | 1078 | custom_exporters_table[typeof(T)] = exporter_wrapper; 1079 | } 1080 | 1081 | public static void RegisterImporter( 1082 | ImporterFunc importer) 1083 | { 1084 | ImporterFunc importer_wrapper = 1085 | delegate (object input) 1086 | { 1087 | return importer((TJson)input); 1088 | }; 1089 | 1090 | RegisterImporter(custom_importers_table, typeof(TJson), 1091 | typeof(TValue), importer_wrapper); 1092 | } 1093 | 1094 | public static void UnregisterExporters() 1095 | { 1096 | custom_exporters_table.Clear(); 1097 | } 1098 | 1099 | public static void UnregisterImporters() 1100 | { 1101 | custom_importers_table.Clear(); 1102 | } 1103 | } 1104 | } 1105 | --------------------------------------------------------------------------------