- Изменено
Bounding box issue in Unity
Hi Esoteric
The error is this:
MissingReferenceException: The object of type 'PolygonCollider2D' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.GetComponent[T] () (at <d815b7efac424eeb8e053965cccb1f98>:0)
UnityEditor.PolygonCollider2DTool+<>c.<IsAvailable>b__9_0 (UnityEngine.Object x) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate, System.Boolean& found) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
System.Linq.Enumerable.FirstOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
UnityEditor.PolygonCollider2DTool.IsAvailable () (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.EditorGUILayout.EditorToolbar[T] (UnityEditor.EditorTools.EditorTool selected, System.Collections.Generic.IList`1[T] tools, UnityEditor.EditorTools.EditorTool& clicked) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.EditorGUILayout.EditorToolbar[T] (System.Collections.Generic.IList`1[T] tools) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.EditorToolGUI.DoContextualToolbarOverlay (UnityEngine.Object target, UnityEditor.SceneView sceneView) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEditor.SceneViewOverlay.WindowTrampoline (System.Int32 id) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
UnityEngine.GUILayout+LayoutedWindow.DoWindow (System.Int32 windowID) (at <817eebdd70f8402280b9cb11fff8b976>:0)
UnityEngine.GUI.CallWindowDelegate (UnityEngine.GUI+WindowFunction func, System.Int32 id, System.Int32 instanceID, UnityEngine.GUISkin _skin, System.Int32 forceRect, System.Single width, System.Single height, UnityEngine.GUIStyle style) (at <817eebdd70f8402280b9cb11fff8b976>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
I began getting this error 5 months ago - and I'm noticing it when working when bounding boxes in Unity.
Here is my bounding box (attached). I did post on S/O, but at the time, I hadn't noticed that it occurs in new projects after adding code that uses B/boxes and followers. Here was my original post: https://gamedev.stackexchange.com/questions/179385/odd-bug-as-unity-tries-to-access-a-collider2d
It's an editor only error, it seems. I'm hoping that it's something I'm doing wrong. I'm using Unity 2019.3.7f1 with runtime 3.8, with work created in Spine pro, 3.89.5.
Currently, I'm not accessing the collider in my code, just to rule that out. I'd only added the b/box in the editor when the error first popped.
EDIT To reproduce 100% time, just have the bounding box and polygoncollider2d game object selected in the Unity hierarchy window - then stop/end play. In a naive way, I tried commenting out the 10 accesses to PolygonColliders in BoundingBoxFollower.cs, but it's something breaking inside Unity editor seemingly, and I couldn't trap the bug. I did file a bug for this with them a while back. Let me know if you want me to reopen it.
Cheers!
We are sorry for the trouble and thanks for reporting! While we could not reproduce the exact same exception message, we were able to reproduce a similar/related exception.
We have released a bugfix for the issue which should also remove your exception message.
A new 3.8 unitypackage is available for download here as usual:
Spine Unity Download
The issue is tracked under this ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/1696
Please let us know if it fixes your error message as well. If it does not, could you please send us a minimal Unity project that still shows the exception, as a zip package to contact@esotericsoftware.com.