Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity Editor Exception, probably a bug in build 17

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by lilboylost, Sep 15, 2014.

  1. lilboylost

    lilboylost

    Joined:
    Feb 12, 2014
    Posts:
    265
    I get following error occasionally out of the blue. I am assuming this is a bug in Unity 4.6 beta, and will be fixed in final release. Thanks


    MissingReferenceException: The object of type 'ScrollRect' 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.get_transform ()
    UnityEngine.UI.ScrollRect.UnityEngine.UI.ICanvasElement.get_transform ()
    UnityEngine.UI.CanvasUpdateRegistry.SortLayoutList (ICanvasElement x, ICanvasElement y) (at /Applications/buildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/CanvasUpdateRegistry.cs:111)
    System.Array.qsort[ICanvasElement] (UnityEngine.UI.ICanvasElement[] array, Int32 low0, Int32 high0, System.Comparison`1 comparison) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1772)
    System.Array.Sort[ICanvasElement]
    (UnityEngine.UI.ICanvasElement[] array, Int32 length, System.Comparison`1 comparison) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1699)
    Rethrow as InvalidOperationException: Comparison threw an exception.
    System.Array.Sort[ICanvasElement] (UnityEngine.UI.ICanvasElement[] array, Int32 length, System.Comparison`1 comparison) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:1702)
    System.Collections.Generic.List`1[UnityEngine.UI.ICanvasElement].Sort (System.Comparison`1 comparison) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:579)
    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at /Applications/buildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/CanvasUpdateRegistry.cs:62)
    UnityEngine.Canvas.SendWillRenderCanvases ()
     
  2. mweldon

    mweldon

    Joined:
    Apr 19, 2010
    Posts:
    109
    I get this as well when running unit tests, which instantiate and close UI prefabs.
     
    lilboylost likes this.
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,143
    I'm assuming you've tried to search for this bug in the bug data base or at least have reported it through the bug reporter so we know about it?

    if not please do so then it can be fixed for final release.
     
  4. lilboylost

    lilboylost

    Joined:
    Feb 12, 2014
    Posts:
    265
    Submitted after your response. Thank you.
     
  5. DeterminateJacobian

    DeterminateJacobian

    Joined:
    Mar 23, 2014
    Posts:
    3
    I am also getting this issue. It occurs when I DestroyImmediate on a GameObject in Edit mode, if that GameObject has any child with the ScrollRect component.

    I'll take this chance to add that the documentation's vague suggestion that "it's not recommended to use DestroyImmediate" is extremely unhelpful.
     
  6. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    302
    Anyone have a solution for this issue? When I build to iOS i get about 4-6000 of these errors, but when i build to a PC platform I don't get this error at all
     
  7. Bezzy

    Bezzy

    Joined:
    Apr 1, 2009
    Posts:
    75
    I'm getting it too, in Unity 5.0.1

    It's happening when calling DestroyImmediate() or Destroy() on a game object in the scene, in the scope of a CustomInspector's OnInspectorGUI

    I was also using the PrefabUtility.ReplacePrefab, PrefabUtility.ReconnectToLastPrefab, PrefabUtility.RevertPrefabInstance, and EditorUtility.SetDirty functions. I don't know if that's at all relevant.