Skip to content

Commit f372c90

Browse files
committed
feat: Replace built-int JSON serializer with newtonsoft
1 parent 1410605 commit f372c90

File tree

7 files changed

+61
-54
lines changed

7 files changed

+61
-54
lines changed

Diff for: Assets/JCSUnity/Scripts/SaveLoad/JCS_JSONData.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
using System.IO;
1010
using System.Text;
11-
using UnityEngine;
11+
using Newtonsoft.Json;
1212

1313
namespace JCSUnity
1414
{
@@ -25,11 +25,11 @@ public abstract class JCS_JSONData : JCS_AppData
2525
/* Functions */
2626

2727
/// <summary>
28-
/// Save the game data into xml file format.
28+
/// Save the applicatiion data into JSON file format.
2929
/// </summary>
3030
/// <typeparam name="T"> type of the data save. </typeparam>
3131
/// <param name="filePath"> where to save. </param>
32-
/// <param name="fileName"> name of the file u want to save. </param>
32+
/// <param name="fileName"> name of the file you want to save. </param>
3333
public override void Save<T>(string filePath, string fileName)
3434
{
3535
string fullFilePath = filePath + fileName;
@@ -38,11 +38,11 @@ public override void Save<T>(string filePath, string fileName)
3838
}
3939

4040
/// <summary>
41-
/// Save the game data into xml file format.
41+
/// Save the applicatiion data into JSON file format.
4242
/// </summary>
4343
/// <typeparam name="T"> type of the data save. </typeparam>
4444
/// <param name="filePath"> where to save. </param>
45-
/// <param name="fileName"> name of the file u want to save. </param>
45+
/// <param name="fileName"> name of the file you want to save. </param>
4646
public override void Save<T>(string fullFilePath)
4747
{
4848
string filePath = Path.GetDirectoryName(fullFilePath);
@@ -53,20 +53,20 @@ public override void Save<T>(string fullFilePath)
5353

5454
using (var stream = new FileStream(fullFilePath, FileMode.Create))
5555
{
56-
string json = JsonUtility.ToJson(this);
56+
string json = JsonConvert.SerializeObject(this);
5757
byte[] info = new UTF8Encoding(true).GetBytes(json);
5858
stream.Write(info, 0, info.Length);
5959
}
6060
}
6161

6262
/// <summary>
63-
/// Load the game data from a directory file path.
63+
/// Load the applicatiion data from a directory file path.
6464
/// </summary>
65-
/// <typeparam name="T"> type of the game data u want to load. </typeparam>
65+
/// <typeparam name="T"> type of the applicatiion data you want to load. </typeparam>
6666
/// <param name="filePath"> file directory, location, path. </param>
67-
/// <param name="fileName"> name of the file u want to load. </param>
67+
/// <param name="fileName"> name of the file you want to load. </param>
6868
/// <returns>
69-
/// Full game data. If the file does not exists returns
69+
/// Full applicatiion data. If the file does not exists returns
7070
/// null references.
7171
/// </returns>
7272
public static T LoadFromFile<T>(string filePath, string fileName)
@@ -77,12 +77,12 @@ public static T LoadFromFile<T>(string filePath, string fileName)
7777
}
7878

7979
/// <summary>
80-
/// Load the game data from a directory file path.
80+
/// Load the applicatiion data from a directory file path.
8181
/// </summary>
82-
/// <typeparam name="T"> type of the game data u want to load. </typeparam>
82+
/// <typeparam name="T"> type of the applicatiion data you want to load. </typeparam>
8383
/// <param name="fullFilePath"> file path to the file. </param>
8484
/// <returns>
85-
/// Full game data. If the file does not exists returns
85+
/// Full applicatiion data. If the file does not exists returns
8686
/// null references.
8787
/// </returns>
8888
public static T LoadFromFile<T>(string fullFilePath)
@@ -97,7 +97,7 @@ public static T LoadFromFile<T>(string fullFilePath)
9797
{
9898
contents = sr.ReadToEnd();
9999
}
100-
return JsonUtility.FromJson<T>(contents);
100+
return JsonConvert.DeserializeObject<T>(contents);
101101
}
102102
}
103103
}

Diff for: Assets/JCSUnity/Scripts/SaveLoad/JCS_XMLData.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public abstract class JCS_XMLData : JCS_AppData
2323
/* Functions */
2424

2525
/// <summary>
26-
/// Save the game data into xml file format.
26+
/// Save the applicatiion data into XML file format.
2727
/// </summary>
2828
/// <typeparam name="T"> type of the data save. </typeparam>
2929
/// <param name="filePath"> where to save. </param>
30-
/// <param name="fileName"> name of the file u want to save. </param>
30+
/// <param name="fileName"> name of the file you want to save. </param>
3131
public override void Save<T>(string filePath, string fileName)
3232
{
3333
string fullFilePath = filePath + fileName;
@@ -36,11 +36,11 @@ public override void Save<T>(string filePath, string fileName)
3636
}
3737

3838
/// <summary>
39-
/// Save the game data into xml file format.
39+
/// Save the applicatiion data into XML file format.
4040
/// </summary>
4141
/// <typeparam name="T"> type of the data save. </typeparam>
4242
/// <param name="filePath"> where to save. </param>
43-
/// <param name="fileName"> name of the file u want to save. </param>
43+
/// <param name="fileName"> name of the file you want to save. </param>
4444
public override void Save<T>(string fullFilePath)
4545
{
4646
string filePath = Path.GetDirectoryName(fullFilePath);
@@ -57,13 +57,13 @@ public override void Save<T>(string fullFilePath)
5757
}
5858

5959
/// <summary>
60-
/// Load the game data from a directory file path.
60+
/// Load the applicatiion data from a directory file path.
6161
/// </summary>
62-
/// <typeparam name="T"> type of the game data u want to load. </typeparam>
62+
/// <typeparam name="T"> type of the applicatiion data you want to load. </typeparam>
6363
/// <param name="filePath"> file directory, location, path. </param>
64-
/// <param name="fileName"> name of the file u want to load. </param>
64+
/// <param name="fileName"> name of the file you want to load. </param>
6565
/// <returns>
66-
/// Full game data. If the file does not exists returns
66+
/// Full applicatiion data. If the file does not exists returns
6767
/// null references.
6868
/// </returns>
6969
public static T LoadFromFile<T>(string filePath, string fileName)
@@ -74,12 +74,12 @@ public static T LoadFromFile<T>(string filePath, string fileName)
7474
}
7575

7676
/// <summary>
77-
/// Load the game data from a directory file path.
77+
/// Load the applicatiion data from a directory file path.
7878
/// </summary>
79-
/// <typeparam name="T"> type of the game data u want to load. </typeparam>
79+
/// <typeparam name="T"> type of the applicatiion data you want to load. </typeparam>
8080
/// <param name="fullFilePath"> file path to the file. </param>
8181
/// <returns>
82-
/// Full game data. If the file does not exists returns
82+
/// Full applicatiion data. If the file does not exists returns
8383
/// null references.
8484
/// </returns>
8585
public static T LoadFromFile<T>(string fullFilePath)

Diff for: Packages/manifest.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"dependencies": {
3-
"com.unity.ai.navigation": "2.0.4",
3+
"com.unity.ai.navigation": "2.0.5",
44
"com.unity.collab-proxy": "2.5.2",
5-
"com.unity.ide.rider": "3.0.31",
5+
"com.unity.ide.rider": "3.0.34",
66
"com.unity.ide.visualstudio": "2.0.22",
77
"com.unity.multiplayer.center": "1.0.0",
8+
"com.unity.nuget.newtonsoft-json": "3.2.1",
89
"com.unity.test-framework": "1.4.5",
910
"com.unity.timeline": "1.8.7",
1011
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.10",
1112
"com.unity.ugui": "2.0.0",
12-
"com.unity.visualscripting": "1.9.4",
13+
"com.unity.visualscripting": "1.9.5",
1314
"com.unity.modules.accessibility": "1.0.0",
1415
"com.unity.modules.ai": "1.0.0",
1516
"com.unity.modules.androidjni": "1.0.0",

Diff for: Packages/packages-lock.json

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dependencies": {
33
"com.unity.ai.navigation": {
4-
"version": "2.0.4",
4+
"version": "2.0.5",
55
"depth": 0,
66
"source": "registry",
77
"dependencies": {
@@ -24,7 +24,7 @@
2424
"url": "https://packages.unity.com"
2525
},
2626
"com.unity.ide.rider": {
27-
"version": "3.0.31",
27+
"version": "3.0.34",
2828
"depth": 0,
2929
"source": "registry",
3030
"dependencies": {
@@ -49,6 +49,13 @@
4949
"com.unity.modules.uielements": "1.0.0"
5050
}
5151
},
52+
"com.unity.nuget.newtonsoft-json": {
53+
"version": "3.2.1",
54+
"depth": 0,
55+
"source": "registry",
56+
"dependencies": {},
57+
"url": "https://packages.unity.com"
58+
},
5259
"com.unity.sysroot": {
5360
"version": "2.0.10",
5461
"depth": 1,
@@ -108,7 +115,7 @@
108115
}
109116
},
110117
"com.unity.visualscripting": {
111-
"version": "1.9.4",
118+
"version": "1.9.5",
112119
"depth": 0,
113120
"source": "registry",
114121
"dependencies": {

Diff for: ProjectSettings/PackageManagerSettings.asset

+7-15
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,25 @@ MonoBehaviour:
1313
m_Name:
1414
m_EditorClassIdentifier:
1515
m_EnablePreReleasePackages: 0
16-
m_EnablePackageDependencies: 0
1716
m_AdvancedSettingsExpanded: 1
1817
m_ScopedRegistriesSettingsExpanded: 1
1918
m_SeeAllPackageVersions: 0
19+
m_DismissPreviewPackagesInUse: 0
2020
oneTimeWarningShown: 0
21+
oneTimeDeprecatedPopUpShown: 0
2122
m_Registries:
2223
- m_Id: main
2324
m_Name:
2425
m_Url: https://packages.unity.com
2526
m_Scopes: []
2627
m_IsDefault: 1
2728
m_Capabilities: 7
29+
m_ConfigSource: 0
2830
m_UserSelectedRegistryName:
2931
m_UserAddingNewScopedRegistry: 0
3032
m_RegistryInfoDraft:
31-
m_ErrorMessage:
32-
m_Original:
33-
m_Id:
34-
m_Name:
35-
m_Url:
36-
m_Scopes: []
37-
m_IsDefault: 0
38-
m_Capabilities: 0
3933
m_Modified: 0
40-
m_Name:
41-
m_Url:
42-
m_Scopes:
43-
-
44-
m_SelectedScopeIndex: 0
45-
m_LoadAssets: 0
34+
m_ErrorMessage:
35+
m_UserModificationsInstanceId: -866
36+
m_OriginalInstanceId: -868
37+
m_LoadAssets: -1

Diff for: ProjectSettings/ProjectSettings.asset

+12-6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ PlayerSettings:
4949
m_StereoRenderingPath: 0
5050
m_ActiveColorSpace: 0
5151
unsupportedMSAAFallback: 0
52+
m_SpriteBatchMaxVertexCount: 65535
5253
m_SpriteBatchVertexThreshold: 300
5354
m_MTRendering: 1
5455
mipStripping: 0
@@ -77,12 +78,11 @@ PlayerSettings:
7778
androidMinimumWindowHeight: 300
7879
androidFullscreenMode: 1
7980
androidAutoRotationBehavior: 1
80-
androidApplicationEntry: 1
8181
androidPredictiveBackSupport: 0
82+
androidApplicationEntry: 1
8283
defaultIsNativeResolution: 1
8384
macRetinaSupport: 1
8485
runInBackground: 1
85-
captureSingleScreen: 1
8686
muteOtherAudioSources: 0
8787
Prepare IOS For Recording: 0
8888
Force IOS Speakers When Recording: 0
@@ -488,7 +488,10 @@ PlayerSettings:
488488
m_Height: 1024
489489
m_Kind: 4
490490
m_SubKind: App Store
491-
m_BuildTargetBatching: []
491+
m_BuildTargetBatching:
492+
- m_BuildTarget: Standalone
493+
m_StaticBatching: 1
494+
m_DynamicBatching: 1
492495
m_BuildTargetShaderSettings: []
493496
m_BuildTargetGraphicsJobs:
494497
- m_BuildTarget: MacStandaloneSupport
@@ -597,7 +600,7 @@ PlayerSettings:
597600
m_BuildTargetGroupLightmapEncodingQuality:
598601
- serializedVersion: 2
599602
m_BuildTarget: Standalone
600-
m_EncodingQuality: 1
603+
m_EncodingQuality: 2
601604
- serializedVersion: 2
602605
m_BuildTarget: XboxOne
603606
m_EncodingQuality: 1
@@ -611,6 +614,7 @@ PlayerSettings:
611614
playModeTestRunnerEnabled: 0
612615
runPlayModeTestAsEditModeTest: 0
613616
actionOnDotNetUnhandledException: 1
617+
editorGfxJobOverride: 1
614618
enableInternalProfiler: 0
615619
logObjCUncaughtExceptions: 1
616620
enableCrashReportAPI: 0
@@ -903,8 +907,8 @@ PlayerSettings:
903907
gcWBarrierValidation: 0
904908
apiCompatibilityLevelPerPlatform:
905909
Android: 3
906-
Standalone: 3
907-
editorAssembliesCompatibilityLevel: 1
910+
Standalone: 6
911+
editorAssembliesCompatibilityLevel: 2
908912
m_RenderingPath: 1
909913
m_MobileRenderingPath: 1
910914
metroPackageName: JCSUnityFramework
@@ -1006,3 +1010,5 @@ PlayerSettings:
10061010
platformRequiresReadableAssets: 0
10071011
virtualTexturingSupportEnabled: 0
10081012
insecureHttpOption: 0
1013+
androidVulkanDenyFilterList: []
1014+
androidVulkanAllowFilterList: []

Diff for: README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ directory at the root of the project directory.
5959

6060
## 📌 Dependencies
6161

62-
These are libraries `JCSUnity` uses. Consider the usage, some plugins
63-
aren't necessary depend on the game your are making.
62+
These are libraries `JCSUnity` uses. Consider the usage, some plugins aren't necessary
63+
depend on the game your are making.
6464

65+
- [Newtonsoft Json](https://www.newtonsoft.com/json) - Popular high-performance JSON framework for .NET.
6566
- [MyBox](https://github.com/Deadcows/MyBox) - is a set of attributes, tools and extensions for Unity
6667
- [Tweener](https://github.com/PeterVuorela/Tweener) - Simpler and light weight tweener library.
6768
- [In-game Debug Console](https://assetstore.unity.com/packages/tools/gui/in-game-debug-console-68068) - Easier debugging after built.

0 commit comments

Comments
 (0)