- Home /
How to set anchors min max depending on the position of a gameobject?
i am a beginner in unity3d and i am struggling to make the Ui anchor min max same position as the gameobject position, my goal is try to achieve like the pictures below.


as you can see when the button moves the anchors min max does not follow with it, in what way should i solve this using C#? and i cannot using layout group because maximizing the screen will ruin the layout, at the moment i move my button with the following script:
public GameObject SaleButtonPrefab;
//To loop all the list
for(int i = 0; i < playerList.Count; i++)
{
//Instantiate the button prefab and make a parent
GameObject nu = Instantiate(SaleButtonPrefab) as GameObject;
nu.transform.SetParent(ParentButton.transform, false);
//To set the position
nu.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, (i*-301) - 0);
}
Thanks in advance c:
Comment
Your answer