- Home /
Question by
3B00DG4MER · Aug 02, 2016 at 12:00 PM ·
buttonscrollviewcontent
ScrollView runtime Instantiating button in the content
Hi guys, I tried to Instantiate a button into the content of a scrollview, after i ran the game the button goes massively wrong positioning and scaling, even though there is a Verticle Layout group to the content and i gave the button a Layout Element, I tried then to put the button manually and it works normal even in runtime
here's some screenshots :
Script Instantiating:
Manual Instantiate :
Script :
foreach (MatchDesc match in matchList.matches)
{
GameObject _roomListItemGO = Instantiate(roomListItemPrefab);
_roomListItemGO.transform.SetParent(roomListUI);
_roomListItemGO.GetComponentInChildren<Text>().text = match.name + " (" + match.currentSize + "/" + match.maxSize + ")";
_roomListItemGO.GetComponent<Button>().onClick.AddListener(delegate () { NetworkManager.singleton.matchMaker.JoinMatch(match.networkId, "", OnJoinInternetMatch); } );
}
Edit : The button works perfect on resolution of 1920 x 1080 and all other wide resolution but for the others not Even though i have a screen
screenshot-142.png
(285.2 kB)
screenshot-143.png
(194.0 kB)
Comment
Best Answer
Answer by 3B00DG4MER · Aug 02, 2016 at 03:01 PM
I fixed the problem, Canvas Scaler was the problem, i changed UI Scale mode to Constant pixel size