Search Unity

Unity editor disappears/crashes after refreshing a scrollview

Discussion in 'Editor & General Support' started by basti12354, Nov 16, 2018.

  1. basti12354

    basti12354

    Joined:
    Mar 4, 2016
    Posts:
    13
    Hey,

    I have done the official Scrollview tutorial (https://unity3d.com/de/learn/tutorials/topics/user-interface-ui/scroll-view). I am using the scrollviews in many screens of my game without any problems so far.
    At the moment I am developing a screen which has a big scrollview and four buttons. If I click on the buttons the scrollview should load different lists. This is already working, but there is a problem.

    Problem:
    • Scrollview has 50 entries/rows. --> Button-Click: Load List with 20 entries/rows --> PERFECT!
    • Scrollview has 25 entries/rows. --> Button-Click: Load List with 5 entries/rows --> PERFECT!
    • Scrollview has 50 entries/rows. --> Button-Click: Load List with for example 5 entries/rows --> Unity disappears!

    I think the problems lies in the function for removing rows. If I comment this out everything works fine.
    What I have done: set breakpoint to removeRow-Function -->After running through the removing of all of the 50 rows in this breakpoint loop and the adding function (of the new rows), Unity jumps to "Btn1.onClick.AddListener(delegate { HandleButton(1, this); });" After that Unity was disappearing too.

    Here is the code of the removing function:

    public void RemoveRows()
    {
    while (contentPanel.childCount > 0)
    {
    GameObject toRemove = transform.GetChild(0).gameObject;
    ButtonObjectPool.ReturnObject(toRemove);
    }
    }
     
    Last edited: Nov 17, 2018
  2. basti12354

    basti12354

    Joined:
    Mar 4, 2016
    Posts:
    13
    UPDATE: After hours of testing I reduced/disabled some of the GameObjects of each row object:

    Before: RowObject has 10 childs. All of these childs are UI-text objects. --> Unity is crashing
    After: RowObject has only 8 text childs --> Unity is not crashing any longer.


    Another thing I found out is that if I reduce the width of the UI text objects, each RowObject can have more childs without crashing unity.

    I have no idea whats going wrong and how to fix this.... At the moment I display fewer information (less text childs) , but this can't be the solution...
     
    Last edited: Nov 18, 2018