Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

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

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

  1. jsleek


    Oct 3, 2014
    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:

    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)
  2. iddqd


    Apr 14, 2012
  3. Hikiko66


    May 5, 2013
    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:
    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