C# unity用户界面-旋转木马菜单
我试图使用unity使中心按钮比菜单选择中的其他按钮显得更大 这就是我制作按钮的方式 `C# unity用户界面-旋转木马菜单,c#,user-interface,unity3d,menu,carousel,C#,User Interface,Unity3d,Menu,Carousel,我试图使用unity使中心按钮比菜单选择中的其他按钮显得更大 这就是我制作按钮的方式 ` for(int i=0;i
for(int i=0;i
`
如何使中心按钮比其他按钮大?尝试使用组布局(垂直或水平)
您可以将“内容大小装配工”添加到组中,并更改中心按钮的大小(或比例,但大小更好)
您也可以使用滚动视图进行滚动,并根据按钮位置到滚动视图中心的距离计算按钮的大小,但我使用四元数。Slerp和菜单是无限的,因此任何位于中心的按钮都应该比其他按钮大。请帮助我提供任何链接或教程,因为我不熟悉UI。你能知道一个按钮和中间有多少个按钮吗?您可以使用此信息计算大小,如scale=maxScale/max(1,来自\u中心的金额)
for (int i = 0; i < noOfOptions; i++)
{
float j = Mathf.Ceil(noOfOptions / 2);
GameObject newButton =GameObject.Instantiate(buttonToSpawn,this.transform);
newButton.name = i.ToString() + "Button";
newButton.GetComponent<RectTransform>().anchoredPosition3D = startvector * distanceFromOrigin;
newButton.GetComponent<RectTransform>().localScale = new Vector3(2, 2, 2);
newButton.GetComponent<RectTransform>().localScale = new Vector3(2, 2, 2);
newButton.GetComponent<LookAtTest>().index = i;
//transform.eulerAngles = new Vector3(0, 0, 45);
GameObject ChildGameObject1 = buttonToSpawn.transform.GetChild(0).gameObject;
ChildGameObject1.GetComponent<Image>().sprite = sprites[i];
startvector = (Quaternion.Euler(0, angleOfDifference, 0) * (startvector)).normalized;
}
And rotating them in a circular menu :
public void RotateScroller()
{
print("Rotate");
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, slerpTime * Time.deltaTime);
if (Mathf.Abs(transform.rotation.eulerAngles.y - targetRotation.eulerAngles.y) < 0.1f)
canRotate = false;
}