Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity Editor Exception, probably a bug in build 17

Discussion in 'UGUI & TextMesh Pro' started by mog-mog-mog, Sep 15, 2014.

  1. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    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.
     
    mog-mog-mog likes this.
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    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. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    Submitted after your response. Thank you.
     
  5. Deleted User

    Deleted User

    Guest

    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:
    328
    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.