Insanely huge initial commit

This commit is contained in:
2026-02-21 17:04:05 -08:00
parent 9cdd36191a
commit 613d75914a
22525 changed files with 4035207 additions and 0 deletions

View File

@@ -0,0 +1,416 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &4
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 0
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 1024
m_ReflectionCompression: 2
m_MixedBakeMode: 1
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 512
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 0
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 0
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 4890085278179872738, guid: 81af15b37c2dfd74a9fabf4dbb8a2827, type: 2}
--- !u!196 &5
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &344286693
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 344286696}
- component: {fileID: 344286695}
- component: {fileID: 344286694}
m_Layer: 0
m_Name: Instructions Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!102 &344286694
TextMesh:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 344286693}
m_Text: 'Nothing to see in this view.
When pressing Play, four example scripts
are executed.
Check their output from the console.
But mostly, see
the scripts themselves.
Additionally, you can see the debug window by choosing
Window
-> Total JSON -> JSON Runtime Debug
from Unity Editor menu.'
m_OffsetZ: 0
m_CharacterSize: 1
m_LineSpacing: 1
m_Anchor: 4
m_Alignment: 1
m_TabSize: 4
m_FontSize: 0
m_FontStyle: 0
m_RichText: 0
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Color:
serializedVersion: 2
rgba: 4294967295
--- !u!23 &344286695
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 344286693}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!4 &344286696
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 344286693}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &479633131
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 479633135}
- component: {fileID: 479633134}
- component: {fileID: 479633133}
- component: {fileID: 479633132}
- component: {fileID: 479633136}
m_Layer: 0
m_Name: Attached Test Scripts
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &479633132
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 479633131}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 439d32b99b1777e4cb58c141cf204a68, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &479633133
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 479633131}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d60680956f97c1a4c805c7d4dd9d5940, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &479633134
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 479633131}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45d8aa6e61f134c4d81a855552302b1e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &479633135
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 479633131}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &479633136
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 479633131}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bccfa1f2b4b94074fad5e9bfd88c9430, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1377886929
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1377886934}
- component: {fileID: 1377886933}
- component: {fileID: 1377886931}
- component: {fileID: 1377886930}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1377886930
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1377886929}
m_Enabled: 1
--- !u!124 &1377886931
Behaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1377886929}
m_Enabled: 1
--- !u!20 &1377886933
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1377886929}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0.019607844}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 5
far clip plane: 15
field of view: 60
orthographic: 1
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1377886934
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1377886929}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@@ -0,0 +1,6 @@
fileFormatVersion: 2
guid: 85192120bb531ee4a887658f2f04b6f9
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: An_Example_SceneSettings
serializedVersion: 4
m_GIWorkflowMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 0
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_LightmapCompression: 3
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 0
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 1
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 1024
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVREnvironmentSampleCount: 512
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentMIS: 0
m_PVRFilteringMode: 0
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 81af15b37c2dfd74a9fabf4dbb8a2827
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4890085278179872738
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,131 @@
// Example - Create and modify JSON
using UnityEngine;
using System.Collections.Generic;
using Leguar.TotalJSON;
namespace Leguar.TotalJSON.Examples {
public class CreateAndModifyJSON : MonoBehaviour {
void Start() {
Debug.Log("---> Running CreateAndModifyJSON.Test1()");
Test1();
Debug.Log("---> Running CreateAndModifyJSON.Test2()");
Test2();
}
private void Test1() {
// Create empty JSON object "{}"
JSON jsonObject = new JSON();
// Add this JSON object to debug
// After this call, you can see content of this JSON object in Unity Editor, by choosing "Window -> Total JSON -> JSON Runtime Debug" from Unity menu
// For debug/development purposes it is very handy to see contents of JSON objects while application is running in editor
jsonObject.DebugInEditor("CreateAndModify Test JSON");
Debug.Log("Note! You can see the content of selected JSON objects while application is running by choosing \"Window -> Total JSON -> JSON Runtime Debug\" from Unity menu");
// Add basic things
jsonObject.Add("text","Hello World!");
jsonObject.Add("number",42);
jsonObject.Add("truth",true);
jsonObject.Add("nullText",null);
jsonObject.Add("numberArray",new int[]{1,2,4,8});
// Print out
Debug.Log(jsonObject.CreateString()); // {"text":"Hello World!","number":42,"truth":true,"nullText":null,"numberArray":[1,2,4,8]}
// Do some changes
jsonObject.Remove("number");
jsonObject.Replace("truth",false);
// Loop through all the keys and print out debug info of all values
Debug.Log("Info of all the values:");
foreach (string key in jsonObject.Keys) {
Debug.Log(key+": "+jsonObject[key]);
}
// Loop through all the keys and print out all values in JSON formatted strings
Debug.Log("Content of all the values:");
foreach (string key in jsonObject.Keys) {
Debug.Log(key+" -> "+jsonObject[key].CreateString());
}
// Get and print out some values
Debug.Log("Print outs of some values:");
Debug.Log(jsonObject.GetString("text")); // "Hello World!"
Debug.Log(jsonObject.ContainsKey("number")); // false
Debug.Log(jsonObject.GetBool("truth")); // false
Debug.Log(jsonObject.GetString("nullText")); // Null
// Do some changes to array
JArray jsonArray = jsonObject.GetJArray("numberArray"); // Contains ints 1,2,4,8
jsonArray.Add(16); // 1,2,4,8,16
jsonArray.RemoveAt(1); // 1,4,8,16
jsonArray.InsertAt(3,0); // 1,4,8,0,16
jsonArray.ReplaceAt(2,-1); // 1,4,-1,0,16
// Print out some array values
Debug.Log("Array length: "+jsonArray.Length); // 5
Debug.Log("Fifth element as int: "+jsonArray.GetInt(4)); // 16
// Since all values in array are numbers (JNumber) and they all fit to c# int values, array can be also copied to system int array
int[] systemIntArray = jsonArray.AsIntArray();
// Print out values
Debug.Log("Second element as int: "+systemIntArray[1]); // 4
}
private void Test2() {
// Create new JSON object from dictionary
Dictionary<string,object> dict = new Dictionary<string,object>();
dict.Add("one",1);
dict.Add("two",2f);
JSON jsonFromDict = new JSON(dict);
// Create new JSON array from list
List<string> list = new List<string>();
list.Add("ABC");
list.Add("XYZ");
list.Add("ijk");
JArray jArrayFromList = new JArray(list);
// Create number that would be outside c# supported integers, by creating new JSON number from string
JNumber bigInteger = new JNumber("184467440737095516150");
// Add them all to one JSON
JSON json = new JSON();
json.Add("fromDict",jsonFromDict);
json.Add("fromList",jArrayFromList);
json.Add("bigInteger",bigInteger);
// Print out in pretty form
Debug.Log("Human readable output:\n" + json.CreateString(new CreateStringSettings() { HumanReadable=true }));
/*
Prints out:
{
"fromDict": {
"one": 1,
"two": 2.0
},
"fromList": [
"ABC",
"XYZ",
"ijk"
],
"bigInteger": 184467440737095516150
}
*/
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 45d8aa6e61f134c4d81a855552302b1e
timeCreated: 1565518243
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 11
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3cb709ed5db03f2479449dc02935cd74
folderAsset: yes
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
// Example - Serialize and Deserialize - ExamplePlayerObject - ExamplePlayerItemObject
// This class is part of "SerializeAndDeserialize.cs" example code
using Leguar.TotalJSON;
namespace Leguar.TotalJSON.Examples {
public struct ExamplePlayerItemObject { // No particular reason for this to be 'struct' instead of 'class', just for the sake of different example
public string name;
public int uses;
public override string ToString() {
return "[ExamplePlayerItemObject: name = \""+name+"\", uses = "+uses+"]";
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: d9d112bdceb035647b1323e28992f074
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,112 @@
// Example - Serialize and Deserialize - ExamplePlayerObject
// This class is part of "SerializeAndDeserialize.cs" example code
using System;
using UnityEngine;
using System.Collections.Generic;
using Leguar.TotalJSON;
namespace Leguar.TotalJSON.Examples {
public class ExamplePlayerObject {
public string name;
public Vector3 position;
public Color playerColor;
private int sessionTime; // This field will not get serialized since it is 'private'
[SerializeField]
private int score; // This private field will be serialized since it is marked with [SerializeField]
[NonSerialized]
public int debugScore; // This public field will not be serialized since it is marked with [NonSerialized]
public float[] levelTimes;
public List<ExamplePlayerItemObject> playerBackPack;
public enum CharClass {
Fighter,
Mage,
Thief
}
public CharClass charClass;
public Dictionary<string,int> mapStates;
public bool? alignment; // Nullable boolean value to allow also "not set" state
public void SetTestValues() {
name = "Test player";
position = new Vector3(1f, 2f, 3f);
playerColor = new Color(0f, 1f, 0.1f, 0.9f);
sessionTime = 55555;
score = 42000;
debugScore = score;
levelTimes = new float[] { 31.41f, 42.0f, 12.3f };
playerBackPack = new List<ExamplePlayerItemObject>();
playerBackPack.Add(new ExamplePlayerItemObject() { name="axe", uses=99 });
playerBackPack.Add(new ExamplePlayerItemObject() { name="coin", uses=1 });
charClass = CharClass.Mage;
mapStates=new Dictionary<string, int>();
mapStates.Add("cave", 78);
mapStates.Add("lake", 42);
alignment = null;
}
public override string ToString() {
string str = "[ExamplePlayerObject: name = \""+name+"\", position = "+position+", playerColor = "+playerColor+", sessionTime = "+sessionTime+", score = "+score+", debugScore = "+debugScore+", levelTimes = ";
if (levelTimes!=null) {
str += '{';
for (int n = 0; n<levelTimes.Length; n++) {
str += levelTimes[n];
if (n<levelTimes.Length-1) {
str += ",";
}
}
str += '}';
} else {
str += "null";
}
str += ", playerBackPack = ";
if (playerBackPack!=null) {
str += '{';
for (int n = 0; n<playerBackPack.Count; n++) {
str += playerBackPack[n].ToString();
if (n<playerBackPack.Count-1) {
str += ',';
}
}
str += '}';
} else {
str += "null";
}
str += ", charClass = "+charClass+", mapStates = ";
if (mapStates!=null) {
str += '{';
bool first = true;
foreach (string key in mapStates.Keys) {
if (!first) {
str += ", ";
}
str += key+"="+mapStates[key];
first=false;
}
str += '}';
} else {
str += "null";
}
str += ", alignment = " + alignment + "]";
return str;
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e8144ad3b5c903e48ae14310f239aed3
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,163 @@
// Example - Parse and handle JSON
using UnityEngine;
using Leguar.TotalJSON;
namespace Leguar.TotalJSON.Examples {
public class ParseAndHandleJSON : MonoBehaviour {
void Start() {
// Parsing Facebook user data
Debug.Log("---> Running ParseAndHandleJSON.ReadFBUserData()");
string dataFromFB = ReadFBUserData();
Debug.Log("---> Running ParseAndHandleJSON.ParseFBUserData()");
ParseFBUserData(dataFromFB);
// Parsing Google Play Store receipt data
Debug.Log("---> Running ParseAndHandleJSON.ReadGPSReceiptData()");
string dataFromGPS = ReadGPSReceiptData();
Debug.Log("---> Running ParseAndHandleJSON.ParseGPSReceiptData()");
ParseGPSReceiptData(dataFromGPS);
}
// Returns example JSON string that is in same format than real data received from Facebook would be when receiving player account info
private string ReadFBUserData() {
string dataFromFB = @"
{
""id"":""123456789012345"",
""name"":""Mumble Happyfeet"",
""first_name"":""Mumble"",
""last_name"":""Happyfeet"",
""picture"":{
""data"":{
""height"":50,
""width"":50,
""is_silhouette"":false,
""url"":""https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=123456789012345&height=50&width=50&ext=1234567890&hash=AbCdeFghijkLmnop""
}
},
""email"":""not.exist@leguar.com"",
""gender"":""male"",
""birthday"":""02/02/1979"",
""location"":{
""location"":{
""city"":""Helsinki"",
""country"":""Finland"",
""latitude"":60.1708,
""longitude"":24.9375
},
""id"":""109876543210987""
},
""currency"":{
""currency_offset"":100,
""usd_exchange"":1.1534292,
""usd_exchange_inverse"":0.8669799585,
""user_currency"":""EUR""
}
}";
return dataFromFB;
}
private void ParseFBUserData(string jsonDataFromFbAsString) {
// Parse string data received from FB to JSON
// Second (optional) parameter is ID for debug purposes. If anything fails in JSON parsing, this debug id is added to exception message.
// This will greatly help tracking problems in projects where lots of JSON objects are handled and stack trace is not necessary available (like in production builds).
// This same debug id will be attached also to resulting JSON object so that if any exceptions happens afterwards (for example when reading values from JSON),
// thos eexceptions will have this ID printed out also.
JSON fbUserJSON = JSON.ParseString(jsonDataFromFbAsString,"FBUserJSON");
// Set JSON protected (read only) so no accidental changes are made to it
// In this example this is of course somewhat pointless since JSON is only used locally in this method and not passed forward to anywhere
// But very handy if this JSON is paased forward and you want to make sure no other code accidentally changes anything
fbUserJSON.SetProtected();
// Add this JSON object to runtime debug in Unity Editor
// After this call, you can see content of this JSON object in Unity Editor, by choosing "Window -> Total JSON -> JSON Runtime Debug" from Unity menu
fbUserJSON.DebugInEditor("FB User JSON");
// Get user basic info
string userId = fbUserJSON.GetString("id");
string name = fbUserJSON.GetString("name");
// Get user picture info
JSON userPictureData = fbUserJSON.GetJSON("picture").GetJSON("data");
bool isPictureSilhouette = userPictureData.GetBool("is_silhouette");
string pictureUrl = userPictureData.GetString("url");
// Get country
string country;
try {
// This code just assumes data contains location information, which it in real life doesn't necessary do
country = fbUserJSON.GetJSON("location").GetJSON("location").GetString("country");
}
catch (JSONKeyNotFoundException) { // The lazy way to handle possibly missing information
country = "Unknown";
}
// Get currency USD exchange
decimal? usdExchange = null;
if (fbUserJSON.ContainsKey("currency")) {
JSON userCurrency = fbUserJSON.GetJSON("currency");
usdExchange = userCurrency.GetJNumber("usd_exchange").AsDecimal();
}
// Print out what we got
Debug.Log("userId = "+userId);
Debug.Log("name = "+name);
Debug.Log("isPictureSilhouette = "+isPictureSilhouette);
Debug.Log("pictureUrl = "+pictureUrl);
Debug.Log("country = "+country);
Debug.Log("usdExchange = "+usdExchange);
}
// Returns example JSON string that is in same format than real data received from Google Play store would be when receiving purchase receipt
private string ReadGPSReceiptData() {
// Note that receipt really contains JSON that added inside other JSON's as strings, causing lots of escaping.
// Then the string is escaped once more here (using TotalJSON Validator included to this package) to make it compatible for adding it to c# source code.
string dataFromGPS="{\"Store\":\"GooglePlay\",\"TransactionID\":\"XYZ.1337-4242-1234-12345\",\"Payload\":\"{\\\"json\\\":\\\"{\\\\\\\"orderId\\\\\\\":\\\\\\\"XYZ.1337-4242-1234-12345\\\\\\\",\\\\\\\"packageName\\\\\\\":\\\\\\\"com.example.test\\\\\\\",\\\\\\\"productId\\\\\\\":\\\\\\\"niceProduct\\\\\\\",\\\\\\\"purchaseTime\\\\\\\":1504030209999,\\\\\\\"purchaseState\\\\\\\":0,\\\\\\\"purchaseToken\\\\\\\":\\\\\\\"abcdefghijklmno.AA-B1Cd--AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO\\\\\\\"}\\\",\\\"signature\\\":\\\"abcdefghijklmnopqrstuvwxyz\\\\/0123456789abcdefghijklmnopqrstuvwxyz+ETCetc==\\\"}\"}";
return dataFromGPS;
// Actual data without this last round of escaping here, looks like this:
// {"Store":"GooglePlay","TransactionID":"XYZ.1337-4242-1234-12345","Payload":"{\"json\":\"{\\\"orderId\\\":\\\"XYZ.1337-4242-1234-12345\\\",\\\"packageName\\\":\\\"com.example.test\\\",\\\"productId\\\":\\\"niceProduct\\\",\\\"purchaseTime\\\":1504030209999,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"abcdefghijklmno.AA-B1Cd--AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO\\\"}\",\"signature\":\"abcdefghijklmnopqrstuvwxyz\\/0123456789abcdefghijklmnopqrstuvwxyz+ETCetc==\"}"}
}
private void ParseGPSReceiptData(string jsonDataFromGpsAsString) {
// Parse string to JSON object
JSON jsonReceipt = JSON.ParseString(jsonDataFromGpsAsString);
Debug.Log("Store: "+jsonReceipt.GetString("Store"));
Debug.Log("TransactionID: "+jsonReceipt.GetString("TransactionID"));
// Parse payload to JSON object as it is saved as string to previous JSON object
JSON payloadAsJSON = JSON.ParseString(jsonReceipt.GetString("Payload"));
string signature = payloadAsJSON.GetString("signature");
Debug.Log("Signature: "+signature);
// One more round of parsing, as receipt is saved as string in previous JSON object
string receiptAsString = payloadAsJSON.GetString("json");
// In some cases there's no need to parse this string to JSON as some purchase validating backend exactly needs this receipt-json as string
// Just for sake of additional parsing example
JSON receiptAsJSON = JSON.ParseString(receiptAsString);
Debug.Log("packageName: "+receiptAsJSON.GetString("packageName"));
Debug.Log("purchaseTime: "+receiptAsJSON.GetJNumber("purchaseTime").AsLong());
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d60680956f97c1a4c805c7d4dd9d5940
timeCreated: 1565518243
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 12
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
// Example - Save and load JSON to/from text file
using UnityEngine;
using System.IO;
using Leguar.TotalJSON;
namespace Leguar.TotalJSON.Examples {
public class SaveAndLoadFile : MonoBehaviour {
// Note: Since this is just an example, file is saved to TotalJSON Examples folder!
// (Normally files should be saved to for example Application.persistentDataPath, depending on platform and what data is saved)
private const string FILE_PATH = "Assets/TotalJSON/Examples/Test_SaveFile.json";
void Start() {
Debug.Log("---> Running SaveAndLoadFile.Test()");
Test();
}
private void Test() {
// Create JSON object for testing
JSON originalObject = new JSON();
originalObject.Add("name", "Test Person");
originalObject.Add("age", 42);
// Save to text file
saveJsonObjectToTextFile(originalObject);
// Load from text file
JSON loadedObject = loadTextFileToJsonObject();
// Check that objects are equal
Debug.Log("Loaded object equals original object: "+loadedObject.Equals(originalObject));
}
private void saveJsonObjectToTextFile(JSON jsonObject) {
string jsonAsString = jsonObject.CreateString(); // Could also use "CreatePrettyString()" to make more human readable result, it is still valid JSON to read and parse by computer
StreamWriter writer = new StreamWriter(FILE_PATH);
writer.WriteLine(jsonAsString);
writer.Close();
}
private JSON loadTextFileToJsonObject() {
StreamReader reader = new StreamReader(FILE_PATH);
string jsonAsString = reader.ReadToEnd();
reader.Close();
JSON jsonObject = JSON.ParseString(jsonAsString);
return jsonObject;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bccfa1f2b4b94074fad5e9bfd88c9430
timeCreated: 1567109215
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 14
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,96 @@
// Example - Serialize and Deserialize
using UnityEngine;
using Leguar.TotalJSON;
namespace Leguar.TotalJSON.Examples {
public class SerializeAndDeserialize : MonoBehaviour {
void Start() {
Debug.Log("---> Running SerializeAndDeserialize.SerializePlayerObjectToString()");
string jsonString = SerializePlayerObjectToString();
Debug.Log("---> Running SerializeAndDeserialize.DeserializeStringToPlayerObject()");
DeserializeStringToPlayerObject(jsonString);
Debug.Log("---> Running SerializeAndDeserialize.SerAndDeserUnityStructs()");
SerAndDeserUnityStructs();
}
private string SerializePlayerObjectToString() {
// Create example player (c# object)
ExamplePlayerObject examplePlayer = new ExamplePlayerObject();
examplePlayer.SetTestValues();
// Print out current player data
Debug.Log("Original player: "+examplePlayer);
// Serialize ExamplePlayerObject to JSON object
JSON json = JSON.Serialize(examplePlayer);
// Output JSON
string jsonString = json.CreateString();
Debug.Log("Player as JSON for storing/transferring: " + jsonString);
// Content of 'jsonString' will be:
// {"name":"Test player","position":{"x":1.0,"y":2.0,"z":3.0},
// "playerColor":{"r":0.0,"g":1.0,"b":0.1,"a":0.9},"score":42000,
// "levelTimes":[31.41,42.0,12.3],"playerBackPack":[{"name":"axe","uses":99},{"name":"coin","uses":1}],
// "charClass":{"value__":1},"mapStates":{"cave":78,"lake":42},"alignment":null}
return jsonString;
}
private void DeserializeStringToPlayerObject(string jsonString) {
// Create JSON object from string
JSON json = JSON.ParseString(jsonString);
// Re-create ExamplePlayerObject from JSON
ExamplePlayerObject restoredPlayer = json.Deserialize<ExamplePlayerObject>();
// Print out
Debug.Log("Restored player: "+restoredPlayer);
}
private void SerAndDeserUnityStructs() {
// Create some basic Unity structs
Vector3 v3 = new Vector3(3f,14f,15f);
Quaternion q = new Quaternion(3f,3f,3f,4f);
Color32 c32 = new Color32(128,255,0,192);
Color c = new Color(0.5f,1f,0f,0.75f);
// Serialize them to JSON and store under one JSON object
JSON jsonObject = new JSON();
jsonObject.Add("v3",JSON.Serialize(v3));
jsonObject.Add("q",JSON.Serialize(q));
jsonObject.Add("c32",JSON.Serialize(c32));
jsonObject.Add("c",JSON.Serialize(c));
// Print out
Debug.Log("Structs stored to JSON: "+jsonObject.CreateString());
// Recreate (deserialize) structs from JSON
Vector3 vector3recreated = jsonObject.GetJSON("v3").Deserialize<Vector3>();
Quaternion quaternionRecreated = jsonObject.GetJSON("q").Deserialize<Quaternion>();
Color32 color32recreated = jsonObject.GetJSON("c32").Deserialize<Color32>();
Color colorRecreated = jsonObject.GetJSON("c").Deserialize<Color>();
// Print out
Debug.Log("Vector3 recreated: "+vector3recreated);
Debug.Log("Quaternion recreated: "+quaternionRecreated);
Debug.Log("Color32 recreated: "+color32recreated);
Debug.Log("Color recreated: "+colorRecreated);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 439d32b99b1777e4cb58c141cf204a68
timeCreated: 1565518243
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 13
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: