Search Unity

Scene change breaks Scrollview (buttons added via script)

Discussion in 'UGUI & TextMesh Pro' started by MarkPeskir, Aug 19, 2017.

  1. MarkPeskir

    MarkPeskir

    Joined:
    Aug 19, 2017
    Posts:
    6
    The video below describes the problem I'm facing. Everything works great...until it doesn't.



    PaintGM script:
    void Start ()
    {
    DrawColor = new Color(1f, 1f, 1f);
    PaintGM.ToolType = "Pencil";
    PaintGM.ICanDrawNow = true;

    for (int i = 0; i < NumberOfPencils; i++)
    {
    GameObject thisPencil = Instantiate<GameObject>(basePencil);
    thisPencil.transform.SetParent(PencilPanel.transform);
    thisPencil.GetComponent<Pencil>().PencilColor = GetNextColor(i);
    thisPencil.GetComponent<Image>().color = GetNextColor(i);
    }

    GameObject thisEraser = Instantiate(baseEraser);
    thisEraser.transform.SetParent(PencilPanel.transform);
    }


    PencilPanel is the content panel inside of the scrollview.
    basePencil and baseEraser point to the prefab UI Buttons shown at the beginning of the video.
    basePencil and baseEraser both have LayoutElements in them, both using no customized layout settings (no checkboxes are checked).

    Thanks in advance,
    Mark