【发布时间】:2016-09-04 13:37:08
【问题描述】:
我是 unity3d 的初学者,我正在努力使 Ui 锚最小最大位置与移动时的按钮位置相同,我的目标是尝试实现如下图所示。
正如您所看到的,当按钮移动锚时 min max 没有跟随它,我应该以什么方式使用 C# 解决这个问题?目前我使用以下脚本移动按钮:
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);
}
提前致谢!
【问题讨论】: