Skip to content

Commit 3f363fe

Browse files
author
Miguel Cartier
committed
feat: move the version file folder to the Configs/Resources folder
1 parent 4559f41 commit 3f363fe

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

Editor/VersionEditorUtils.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ namespace GameLovers.Services.Editor
1212
public static class VersionEditorUtils
1313
{
1414
private const int ShortenedCommitLength = 8;
15+
private const string AssetsPath = "Assets";
16+
private const string FilePath = "Configs/Resources";
1517

1618
/// <summary>
1719
/// Set the internal version before building the app.
@@ -110,10 +112,7 @@ private static VersionServices.VersionData GenerateInternalVersionSuffix(bool is
110112
/// </summary>
111113
private static void SaveVersionData(string serializedData)
112114
{
113-
const string assets = "Assets";
114-
const string resources = "Build/Resources";
115-
116-
var absDirPath = Path.Combine(Application.dataPath, resources);
115+
var absDirPath = Path.Combine(Application.dataPath, FilePath);
117116
if (!Directory.Exists(absDirPath))
118117
{
119118
Directory.CreateDirectory(absDirPath);
@@ -125,7 +124,7 @@ private static void SaveVersionData(string serializedData)
125124
if (File.Exists(Path.ChangeExtension(absFilePath, assetExtension)))
126125
{
127126
AssetDatabase.DeleteAsset(
128-
Path.Combine(assets, resources,
127+
Path.Combine(AssetsPath, FilePath,
129128
Path.ChangeExtension(VersionServices.VersionDataFilename, assetExtension)));
130129
}
131130

@@ -134,7 +133,7 @@ private static void SaveVersionData(string serializedData)
134133
File.WriteAllText(Path.ChangeExtension(absFilePath, textExtension), serializedData);
135134

136135
AssetDatabase.ImportAsset(
137-
Path.Combine(assets, resources,
136+
Path.Combine(AssetsPath, FilePath,
138137
Path.ChangeExtension(VersionServices.VersionDataFilename, textExtension)));
139138
}
140139
}

Runtime/TickService.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,16 @@ private void OnFixedUpdate()
301301
return;
302302
}
303303

304-
var arrayCopy = _onFixedUpdateList.ToArray();
305-
306-
for (int i = 0; i < arrayCopy.Length; i++)
304+
// Iterate backwards to allow safe mutation during iteration
305+
for (int i = _onFixedUpdateList.Count - 1; i >= 0; i--)
307306
{
308-
arrayCopy[i].Action(Time.fixedTime);
307+
// Skip if the item was removed by a previous action
308+
if (i >= _onFixedUpdateList.Count)
309+
{
310+
continue;
311+
}
312+
313+
_onFixedUpdateList[i].Action(Time.fixedTime);
309314
}
310315
}
311316

@@ -326,11 +331,16 @@ private void Update(List<TickData> list)
326331
return;
327332
}
328333

329-
var arrayCopy = list.ToArray();
330-
331-
for (int i = 0; i < arrayCopy.Length; i++)
334+
// Iterate backwards to allow safe mutation during iteration
335+
for (int i = list.Count - 1; i >= 0; i--)
332336
{
333-
var tickData = arrayCopy[i];
337+
// Skip if the item was removed by a previous action
338+
if (i >= list.Count)
339+
{
340+
continue;
341+
}
342+
343+
var tickData = list[i];
334344
var time = tickData.RealTime ? Time.realtimeSinceStartup : Time.time;
335345

336346
if (time < tickData.LastTickTime + tickData.DeltaTime)
@@ -339,19 +349,15 @@ private void Update(List<TickData> list)
339349
}
340350

341351
var deltaTime = time - tickData.LastTickTime;
342-
var countBefore = list.Count;
343352

344353
tickData.Action(deltaTime);
345354

346-
// Check if the update was not unsubscribed in the call
347-
var index = i - (arrayCopy.Length - countBefore);
348-
if (list.Count > index && tickData == list[index])
355+
// Check if the item still exists and wasn't unsubscribed
356+
if (i < list.Count && list[i] == tickData)
349357
{
350358
var overFlow = tickData.DeltaTime == 0 ? 0 : deltaTime % tickData.DeltaTime;
351-
352359
tickData.LastTickTime = tickData.TimeOverflowToNextTick ? time - overFlow : time;
353-
354-
list[index] = tickData;
360+
list[i] = tickData;
355361
}
356362
}
357363
}

0 commit comments

Comments
 (0)