Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

MissingReferenceException: The object of type 'ScrollRect' has been destroyed...

Discussion in 'Unity 5 Pre-order Beta' started by jsleek, Oct 30, 2014.

  1. jsleek

    jsleek

    Joined:
    Oct 3, 2014
    Posts:
    61
    This error happens when you have a Game Object with a Scroll Rect attached to it, and it has a child Game Object with either a Content Size Fitter script, or a Horizontal Layout Group script, or both, attached to it and enabled. The error repeats infinitely (going to 999+ in the console) even when the project has stopped running.

    I had a working dynamic scroll view in 4.6, but for some reason 5.0 doesn't like it when you combine Scroll Rect with a child that has Content Size Fitter/ Horizontal Layout Group.

    Here's the thread from when i had it working in 4.6:
    http://forum.unity3d.com/threads/solved-adding-multiple-images-to-a-scroll-rect.272053/

    D
    oes anyone know how to fix this? Or is this a bug?

    Full Error message:

    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.UI.ScrollRect.UnityEngine.UI.ICanvasElement.get_transform ()
    UnityEngine.UI.CanvasUpdateRegistry.SortLayoutList (ICanvasElement x, ICanvasElement y) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/guisystem/UI/Core/CanvasUpdateRegistry.cs:125)
    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 /Users/builduser/buildslave/unity/build/Extensions/guisystem/guisystem/UI/Core/CanvasUpdateRegistry.cs:64)
    UnityEditor.Undo:Internal_CallWillFlushUndoRecord()
     
  2. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    500
  3. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    Thousands of errors. I was hoping that this would be resolved in the new beta because I thought the old one might have been on a bugged older version of the GUI, but it has not helped. Even once you have exited play mode, the errors continue to pile up.

    I did find this thread in the 4.6 beta forum:
    http://forum.unity3d.com/threads/panel-with-horizontal-layout-group-under-scrollrect.270651/
    It seems to be related to this, but not quite the same, because they were only having problems when they were building etc. I haven't tried to build my 4.6 project, but in the editor everything worked, just like the OP says.
     
    Last edited: Nov 4, 2014