Unity 固定高度等比放大宽度
作者:互联网
imgae =transform.GetComponent<Image>(); imgae.preserveAspect = true; float imageH = imgae.transform.parent .GetComponent<RectTransform>().sizeDelta.y; float imageW = imageH * imgae.preferredWidth / imgae.preferredHeight; RectTransform rectFransF = transform.GetComponent<RectTransform>(); rectFransF.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, imageW);
标签:imageH,imgae,float,transform,Unity,宽度,GetComponent,imageW,放大 来源: https://www.cnblogs.com/zqiang0803/p/14707980.html