[unity] Fixed a bug with threaded updates handling null SkeletonDataAssets when updated on main thread.

This commit is contained in:
Harald Csaszar 2025-10-27 12:45:51 +01:00
parent 7fa846bb95
commit f6445e69dd
2 changed files with 9 additions and 9 deletions

View File

@ -306,7 +306,7 @@ namespace Spine.Unity {
int skeletonEnd = skeletons.Count; int skeletonEnd = skeletons.Count;
int endIndexThreaded = Math.Min(skeletonEnd, rangePerThread * numAsyncThreads); int endIndexThreaded = Math.Min(skeletonEnd, rangePerThread * numAsyncThreads);
MainThreadBeforeUpdate(skeletons, endIndexThreaded); MainThreadBeforeUpdate(skeletons, skeletonEnd);
#if RUN_ALL_ON_MAIN_THREAD #if RUN_ALL_ON_MAIN_THREAD
for (int r = 0; r < skeletons.Count; ++r) { for (int r = 0; r < skeletons.Count; ++r) {
@ -320,7 +320,7 @@ namespace Spine.Unity {
UpdateAsyncSplitMainThreadCallbacks(skeletons, updateTiming, UpdateAsyncSplitMainThreadCallbacks(skeletons, updateTiming,
numAsyncThreads, rangePerThread, skeletonEnd, endIndexThreaded); numAsyncThreads, rangePerThread, skeletonEnd, endIndexThreaded);
#endif #endif
MainThreadAfterUpdate(skeletons, endIndexThreaded); MainThreadAfterUpdate(skeletons, skeletonEnd);
} }
protected void UpdateAsyncThreadedCallbacks (List<SkeletonAnimationBase> skeletons, UpdateTiming timing, protected void UpdateAsyncThreadedCallbacks (List<SkeletonAnimationBase> skeletons, UpdateTiming timing,
@ -435,14 +435,14 @@ namespace Spine.Unity {
} }
} }
protected void MainThreadBeforeUpdate (List<SkeletonAnimationBase> skeletons, int endIndexThreaded) { protected void MainThreadBeforeUpdate (List<SkeletonAnimationBase> skeletons, int skeletonEnd) {
for (int i = 0; i < endIndexThreaded; ++i) { for (int i = 0; i < skeletonEnd; ++i) {
skeletons[i].MainThreadBeforeUpdateInternal(); skeletons[i].MainThreadBeforeUpdateInternal();
} }
} }
protected void MainThreadAfterUpdate (List<SkeletonAnimationBase> skeletons, int endIndexThreaded) { protected void MainThreadAfterUpdate (List<SkeletonAnimationBase> skeletons, int skeletonEnd) {
for (int i = 0; i < endIndexThreaded; ++i) { for (int i = 0; i < skeletonEnd; ++i) {
skeletons[i].MainThreadAfterUpdateInternal(); skeletons[i].MainThreadAfterUpdateInternal();
} }
} }
@ -720,7 +720,7 @@ namespace Spine.Unity {
#endif #endif
for (int r = start; r < end; ++r) { for (int r = start; r < end; ++r) {
try { try {
var targetSkeletonAnimation = skeletonAnimations[r]; SkeletonAnimationBase targetSkeletonAnimation = skeletonAnimations[r];
if (!splitUpdateMethod[r].IsDone) { if (!splitUpdateMethod[r].IsDone) {
splitUpdateMethod[r] = targetSkeletonAnimation.UpdateInternalSplit(splitUpdateMethod[r], deltaTime, frameCount); splitUpdateMethod[r] = targetSkeletonAnimation.UpdateInternalSplit(splitUpdateMethod[r], deltaTime, frameCount);
} }
@ -741,7 +741,7 @@ namespace Spine.Unity {
for (int r = 0; r < endIndexThreaded; ++r) { for (int r = 0; r < endIndexThreaded; ++r) {
try { try {
var targetSkeletonAnimation = skeletons[r]; SkeletonAnimationBase targetSkeletonAnimation = skeletons[r];
if (splitUpdateMethod[r].IsInitialState) { if (splitUpdateMethod[r].IsInitialState) {
Debug.LogError("Internal threading logic error: skeletonAnimations never called UpdateInternal before!", skeletons[r]); Debug.LogError("Internal threading logic error: skeletonAnimations never called UpdateInternal before!", skeletons[r]);
} else { } else {

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity", "name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime", "displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.", "description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.",
"version": "4.3.24", "version": "4.3.25",
"unity": "2018.3", "unity": "2018.3",
"author": { "author": {
"name": "Esoteric Software", "name": "Esoteric Software",