Skip to content

Commit 222bc26

Browse files
committed
Temporarily suppress exceptions arising from double-loading addressables
1 parent 047905b commit 222bc26

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Runtime/Core/Assets/PatchingManager.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ public static void ImportSinglePatch(FileInfo fileInfo)
142142
public static void ImportAssetPatch(TextAsset asset, string modId)
143143
{
144144
Universe.LoadPatchAsset(asset, modId);
145-
CurrentPatchHashes.Patches.Add(asset.name, Hash.FromString(asset.text));
145+
// TODO: Actually fix the double-loading of addressables rather than just changing Add to TryAdd
146+
CurrentPatchHashes.Patches.TryAdd($"{modId}/{asset.name}", Hash.FromString(asset.text));
146147
}
147148

148149
public static void RegisterPatches()
@@ -292,8 +293,15 @@ public static void CreateNewAssets(Action resolve, Action<string> reject)
292293
Logging.LogDebug($"Generated an asset with the label {label}, and name {name}:\n{text}");
293294

294295
if (!_createdAssets.ContainsKey(label))
296+
{
295297
_createdAssets[label] = new List<(string name, string text)>();
296-
_createdAssets[label].Add((name, text));
298+
}
299+
300+
if (!_createdAssets[label].Any(x => x.name == name))
301+
{
302+
_createdAssets[label].Add((name, text));
303+
}
304+
297305
}
298306
catch (Exception e)
299307
{

Runtime/Parts/Patchers/PartModuleLoadPatcher.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ internal static void ApplyOnGameObject(ref GameObject gameObject, PartData partD
4040

4141
// Debug.Log($"ApplyOnGameObject - {partData.partName} adding {behaviourType.FullName}");
4242
var instance = obj.AddComponent(behaviourType);
43-
Logging.LogInfo($"Attempting to setup serialized fields on {partData.partName} of type {behaviourType}");
43+
Logging.LogInfo(
44+
$"Attempting to setup serialized fields on {partData.partName} of type {behaviourType}");
4445
foreach (var field in behaviourType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
4546
.Concat(behaviourType.GetFields(BindingFlags.Public | BindingFlags.Instance)))
4647
{
@@ -70,7 +71,14 @@ internal static void ApplyOnGameObject(ref GameObject gameObject, PartData partD
7071
if (partData.serializedPartModules.All(x => x.BehaviourType != t))
7172
{
7273
// Debug.Log($"ApplyOnGameObject - {partData.partName} removing {component.GetType().FullName}");
73-
Object.Destroy(component);
74+
if (Application.isEditor)
75+
{
76+
Object.DestroyImmediate(component);
77+
}
78+
else
79+
{
80+
Object.Destroy(component);
81+
}
7482
}
7583
}
7684

0 commit comments

Comments
 (0)