Hi,
I’m having some trouble getting a scrollbox to work. I’ve looked at lots of tutorials and videos and as far as I can tell I’ve got everything setup correctly - however, it’s just not working.
Players need to be able to add character to their team which appears in a scrollable window on the left.
I’ve got:
Panel with a Scrollrect attached to it:
Child of that, a panel (called player1side) that’s set to re-size based upon the contents.

In code, a button adds a prefab (panel consisting of a textbox and an image)
public void AddToPlayer1()
{
characterPanel = GameObject.Instantiate (characterPanel, new Vector3(0,0), new Quaternion(0,0,0,0)) as GameObject;
characterPanel.name = "pnl" + characters[selectedCharacter].characterName;
characterPanel.GetComponent<RectTransform>().position=new Vector3(0, 279-(player1.Count * 50));
characterPanel.GetComponentInChildren<Text>().text = characters[selectedCharacter].characterName;
characterPanel.GetComponentInChildren<RawImage>().texture = characters[selectedCharacter].image;
characterPanel.transform.SetParent(player1Side.transform, false);
}
So there’s two main things that aren’t working as planned.
Regardless of what setting I give to the scrollable panel, the character panels are placed at 279 on the Y axis. I set the scrollable panel to 0 from the top and bottom but when I click play it’s changed itself to 279. (hence why I’ve had to offset the placement of the characters by 279). Why is doing that? What do I need to get the character panels to appear at the top?
Secondly…It’s not scrolling correctly. See:
There is also a scrollbar linked to the scrollpanel.
I’ve got a working a scrollpanel at the bottom of the page - but I’ve copied its specifcations but I can’t replicate it.
Thanks for your time.
