0
我有一個UI圖像它的源圖像在運行時分配。這些圖像將具有各種尺寸,我需要將它們縮放以適應佈局元素的邊界,以便整個圖像可見。縮放UI圖像源圖像
我已經嘗試了很多方法,但是我似乎無法得到這個工作;任何人都可以請給我一些關於如何實現這一目標的指針?
預先非常感謝
NB:佈局經由佈局組組件,這些組件用於控制在所述矩形與其它潛在有用的佈局組分如長寬比鉗工和的內容衝突控制儀(如文檔提到的解決了這個問題)
public
function ContextImgImp() {
Debug.Log("Context Img Located at: " + texLocation);
var wwwDirectory = "file://" + texLocation; //this will probably need to change for other OS (PC = file:/ [I think?]) - **REVISE**
Debug.Log("Tex located at: " + wwwDirectory);
newImgTex = new Texture2D(512, 512, TextureFormat.DXT1, false);
while (true) {
var www: WWW = new WWW(wwwDirectory);
yield www;
Debug.Log("Done Downloading Texture");
www.LoadImageIntoTexture(newImgTex);
if (www.isDone) {
break; //if done downloading image break loop
}
}
var imgSprite = contImg.sprite;
var imgRect = imgSprite.rect;
var imgPivot = imgRectTrans.pivot;
var pixelScale = 100;
Debug.Log("Pixel Scale:" + pixelScale);
newImgSprite = Sprite.Create(newImgTex, imgRect, imgPivot, pixelScale);
contImg.sprite = newImgSprite;
//imgRectTrans.rect.size = Vector2(130,130);
//contImg.sprite.rect.size = Vector2(130,130);
//contImg.type = Image.Type.Simple;
//***HERE*** \t
if (assetFromFile) {
ImgNameSplit(); //only execute namesplit if from file
}
}