Search Unity

GridLayoutGroup error when re-populating

Discussion in 'UGUI & TextMesh Pro' started by npruehs, May 11, 2016.

  1. npruehs

    npruehs

    Joined:
    Jul 20, 2012
    Posts:
    67
    Hey guys,

    the first time I'm populating a GridLayoutGroup with game objects, everything's fine.

    However, at each subsequent try to add children to it after having it cleared, the following error is logged:

    Code (CSharp):
    1. MissingReferenceException: The object of type 'RectTransform' has been destroyed but you are still trying to access it.
    2. Your script should either check if it is null or you should not destroy the object.
    3. UnityEngine.DrivenRectTransformTracker.Add (UnityEngine.Object driver, UnityEngine.RectTransform rectTransform, DrivenTransformProperties drivenProperties) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/RectTransformBindings.gen.cs:64)
    4. UnityEngine.UI.GridLayoutGroup.SetCellsAlongAxis (Int32 axis) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Layout/GridLayoutGroup.cs:115)
    5. UnityEngine.UI.GridLayoutGroup.SetLayoutHorizontal () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Layout/GridLayoutGroup.cs:92)
    6. UnityEngine.UI.LayoutRebuilder.<Rebuild>m__9 (UnityEngine.Component e) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs:71)
    7. UnityEngine.UI.LayoutRebuilder.PerformLayoutControl (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs:103)
    8. UnityEngine.UI.LayoutRebuilder.PerformLayoutControl (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs:106)
    9. UnityEngine.UI.LayoutRebuilder.PerformLayoutControl (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs:106)
    10. UnityEngine.UI.LayoutRebuilder.PerformLayoutControl (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs:106)
    11. UnityEngine.UI.LayoutRebuilder.Rebuild (CanvasUpdate executing) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs:71)
    12. UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:122)
    13. UnityEngine.Canvas:SendWillRenderCanvases()
    14.  
    It might be worth noting that the game object with the layout group is disabled and enabled in between.

    We are using Unity 5.3.2p3.

    Anyone else experiencing these issues?
     
  2. lemmy101

    lemmy101

    Joined:
    Apr 10, 2014
    Posts:
    6
    I had this same issue with a vertical layout component.

    In case someone else has this issue (since this about the only google search result on it) I fixed it by removing a Content Size Fitter off the vertical layout component's parent.
     
    rgonsalv, alex_roboto and ebby_nia like this.
  3. daretsuki

    daretsuki

    Joined:
    Mar 22, 2018
    Posts:
    6
    Had exactly same problem :( Probably have to create my own Content Size Fitter :(
     
  4. die3lustigen4

    die3lustigen4

    Joined:
    Dec 3, 2017
    Posts:
    2
    For all feature Googlers, who find this post. For me it was an
    AspectRatioFitter
    . And it wasn't on the parent but on the anchestor 3 levels up.
    @daretsuki Mind to share your own fitter? ;)