diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs index 9c5fd1bf0..19712597c 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Modules/SkeletonRenderSeparator/Editor/SkeletonRenderSeparatorInspector.cs @@ -27,6 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER +#define NEW_PREFAB_SYSTEM +#endif + using UnityEngine; using UnityEditor; @@ -81,7 +85,18 @@ namespace Spine.Unity.Examples { // Restore mesh part for undo logic after undo of "Add Parts Renderer". // Triggers regeneration and assignment of the mesh filter's mesh. - if (component.GetComponent() && component.GetComponent().sharedMesh == null) { + + bool isMeshFilterAlwaysNull = false; + #if UNITY_EDITOR && NEW_PREFAB_SYSTEM + // Don't store mesh or material at the prefab, otherwise it will permanently reload + var prefabType = UnityEditor.PrefabUtility.GetPrefabAssetType(component); + if (UnityEditor.PrefabUtility.IsPartOfPrefabAsset(component) && + (prefabType == UnityEditor.PrefabAssetType.Regular || prefabType == UnityEditor.PrefabAssetType.Variant)) { + isMeshFilterAlwaysNull = true; + } + #endif + + if (!isMeshFilterAlwaysNull && component.GetComponent() && component.GetComponent().sharedMesh == null) { component.OnDisable(); component.OnEnable(); } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderSeparator/SkeletonRenderSeparator.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderSeparator/SkeletonRenderSeparator.cs index e3b88ccfc..673bd036f 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderSeparator/SkeletonRenderSeparator.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderSeparator/SkeletonRenderSeparator.cs @@ -191,8 +191,10 @@ namespace Spine.Unity { skeletonRenderer.LateUpdate(); - foreach (var s in partsRenderers) - s.ClearMesh(); + foreach (var partsRenderer in partsRenderers) { + if (partsRenderer != null) + partsRenderer.ClearMesh(); + } } MaterialPropertyBlock copiedBlock; @@ -221,6 +223,8 @@ namespace Spine.Unity { int rendererIndex = 0; var currentRenderer = partsRenderers[rendererIndex]; for (int si = 0, start = 0; si <= lastSubmeshInstruction; si++) { + if (currentRenderer == null) + continue; if (submeshInstructionsItems[si].forceSeparate || si == lastSubmeshInstruction) { // Apply properties var meshGenerator = currentRenderer.MeshGenerator; @@ -245,7 +249,9 @@ namespace Spine.Unity { // Clear extra renderers if they exist. for (; rendererIndex < rendererCount; rendererIndex++) { - partsRenderers[rendererIndex].ClearMesh(); + currentRenderer = partsRenderers[rendererIndex]; + if (currentRenderer != null) + partsRenderers[rendererIndex].ClearMesh(); } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs index 3e98eef8f..e75c00682 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -529,7 +529,7 @@ namespace Spine.Unity { separatorSlots.Add(slot); } #if UNITY_EDITOR - else + else if (!string.IsNullOrEmpty(separatorSlotNames[i])) { Debug.LogWarning(separatorSlotNames[i] + " is not a slot in " + skeletonDataAsset.skeletonJSON.name); }