Skip to content

Commit 010cf9d

Browse files
committed
fix: ldtkc files will now read/write object references with a guid to deserialize properly and to not dirty source control unnessesarily
1 parent 4df48a5 commit 010cf9d

File tree

6 files changed

+63
-21
lines changed

6 files changed

+63
-21
lines changed

Assets/LDtkUnity/Editor/Utility/Artifacts/LDtkConfigData.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Text;
4+
using UnityEditor;
45
using UnityEngine;
56

67
namespace LDtkUnity.Editor
@@ -23,7 +24,7 @@ internal struct LDtkConfigData
2324
internal string WriteJson(string projectAssetPath)
2425
{
2526
string writePath = GetPath(projectAssetPath);
26-
string json = JsonUtility.ToJson(this, true);
27+
string json = EditorJsonUtility.ToJson(this, true);
2728
byte[] byteArray = Encoding.UTF8.GetBytes(json);
2829

2930
LDtkPathUtility.TryCreateDirectoryForFile(writePath);
@@ -41,7 +42,10 @@ internal static LDtkConfigData ReadJson(string assetPath)
4142

4243
byte[] bytes = File.ReadAllBytes(assetPath);
4344
string json = Encoding.UTF8.GetString(bytes);
44-
return JsonUtility.FromJson<LDtkConfigData>(json);
45+
46+
LDtkConfigData data = new LDtkConfigData();
47+
EditorJsonUtility.FromJsonOverwrite(json, data);
48+
return data;
4549
}
4650

4751
internal static string GetPath(string projectAssetPath)

Assets/LDtkUnity/Samples~/Samples/SeparateLevelFiles/SeparateLevelFiles_Config.ldtkc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
{
1414
"_key": "IntGrid_1",
1515
"_asset": {
16-
"instanceID": 22226
16+
"fileID": 11400000,
17+
"guid": "85c839224be7398449b593cedc9d81ca",
18+
"type": 2
1719
}
1820
}
1921
],

Assets/Tests/Misc/OtherTechTests/DependencyTest/TestIntGridValueDependency/TestIntGridValueDependency_Config.ldtkc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,25 @@
1313
{
1414
"_key": "IntGrid_1",
1515
"_asset": {
16-
"instanceID": 29410
16+
"fileID": 11400000,
17+
"guid": "019c844af99991d409a134bcc556b3b1",
18+
"type": 2
1719
}
1820
},
1921
{
2022
"_key": "IntGrid_2",
2123
"_asset": {
22-
"instanceID": 28118
24+
"fileID": 11400000,
25+
"guid": "aee5cec04e488604cb16a7da061946bc",
26+
"type": 2
2327
}
2428
},
2529
{
2630
"_key": "IntGrid_3",
2731
"_asset": {
28-
"instanceID": 24110
32+
"fileID": 11400000,
33+
"guid": "62504a226f3487f49af1e37703e72136",
34+
"type": 2
2935
}
3036
}
3137
],

Assets/Tests/Misc/OtherTechTests/LevelsVania/LevelsVania_Config.ldtkc

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
{
1414
"_key": "Collisions_1",
1515
"_asset": {
16-
"instanceID": 25948
16+
"fileID": 11400000,
17+
"guid": "608aedeab5fb3ac48959b083b4ecd7c1",
18+
"type": 2
1719
}
1820
},
1921
{
@@ -27,37 +29,49 @@
2729
{
2830
"_key": "Item",
2931
"_asset": {
30-
"instanceID": 30982
32+
"fileID": 6381717676898315408,
33+
"guid": "154ba3503afd20d4580ff3f817fd2177",
34+
"type": 3
3135
}
3236
},
3337
{
3438
"_key": "Player",
3539
"_asset": {
36-
"instanceID": 33704
40+
"fileID": 6381717676898315408,
41+
"guid": "2c40888790883084b832d4183474c09a",
42+
"type": 3
3743
}
3844
},
3945
{
4046
"_key": "Exit",
4147
"_asset": {
42-
"instanceID": 31998
48+
"fileID": 6381717676898315408,
49+
"guid": "109ac9123036bb24ca5866d7aa81f4b3",
50+
"type": 3
4351
}
4452
},
4553
{
4654
"_key": "SecretArea",
4755
"_asset": {
48-
"instanceID": 31288
56+
"fileID": 6381717676898315408,
57+
"guid": "455e2726c152eb946bab81090f7c0afa",
58+
"type": 3
4959
}
5060
},
5161
{
5262
"_key": "Teleport",
5363
"_asset": {
54-
"instanceID": 30554
64+
"fileID": 6381717676898315408,
65+
"guid": "9958dbc3bfc14c64ba545adf3467ed50",
66+
"type": 3
5567
}
5668
},
5769
{
5870
"_key": "Ladder",
5971
"_asset": {
60-
"instanceID": 30794
72+
"fileID": 6381717676898315408,
73+
"guid": "4bd923e45ce962547bb6ae2dd76a5984",
74+
"type": 3
6175
}
6276
}
6377
]

Assets/Tests/Misc/OtherTechTests/TestAllFieldsLevels/TestAllFieldsLevels_Config.ldtkc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,25 @@
1414
{
1515
"_key": "TestAllFields",
1616
"_asset": {
17-
"instanceID": 43784
17+
"fileID": 2518318380925621618,
18+
"guid": "3222c3d6e0104884eb44c4821f66e354",
19+
"type": 3
1820
}
1921
},
2022
{
2123
"_key": "NoFields",
2224
"_asset": {
23-
"instanceID": 43824
25+
"fileID": 2518318380925621618,
26+
"guid": "be7f9038a4c1bc04d9d62adff8d0cab8",
27+
"type": 3
2428
}
2529
},
2630
{
2731
"_key": "TestAllNullable",
2832
"_asset": {
29-
"instanceID": 43832
33+
"fileID": 2518318380925621618,
34+
"guid": "55ee5e096e24b4542bc1968b36e6c019",
35+
"type": 3
3036
}
3137
}
3238
]

Assets/Tests/Misc/OtherTechTests/Test_file_for_API_showing_all_featuresLevels/Test_file_for_API_showing_all_featuresLevels_Config.ldtkc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,41 @@
4545
{
4646
"_key": "EntityFieldsTest",
4747
"_asset": {
48-
"instanceID": 70644
48+
"fileID": 8271057754295682963,
49+
"guid": "8edc4af9ae4379948ac2d95a7603e233",
50+
"type": 3
4951
}
5052
},
5153
{
5254
"_key": "Labels",
5355
"_asset": {
54-
"instanceID": 70646
56+
"fileID": 8271057754295682963,
57+
"guid": "651dd273af932094fbe35791264dcfa4",
58+
"type": 3
5559
}
5660
},
5761
{
5862
"_key": "RectRegion",
5963
"_asset": {
60-
"instanceID": 70648
64+
"fileID": 8271057754295682963,
65+
"guid": "e355c9bebb8a0fe458316f819cb5df56",
66+
"type": 3
6167
}
6268
},
6369
{
6470
"_key": "CircleRegion",
6571
"_asset": {
66-
"instanceID": 70650
72+
"fileID": 8271057754295682963,
73+
"guid": "9a9f4260bc1dd5444a09370d4abf42f8",
74+
"type": 3
6775
}
6876
},
6977
{
7078
"_key": "EntityRefTest",
7179
"_asset": {
72-
"instanceID": 70650
80+
"fileID": 8271057754295682963,
81+
"guid": "9a9f4260bc1dd5444a09370d4abf42f8",
82+
"type": 3
7383
}
7484
}
7585
]

0 commit comments

Comments
 (0)