- Home /
Question by
Neil Smith · Oct 16, 2013 at 11:19 AM ·
imageresizeimagesrescale
Resizing / Rescaling Image inside GUI.Window content.
I am trying to rescale an image within the content of a GUI.Window.
The code comes up with an error "Assets/TextAreaBox.js(14,43): BCE0051: Operator '*' cannot be used with a left hand side of type 'int' and a right hand side of type 'Object'.".
#pragma strict
private var BoxWidth = 350;
private var BoxHeight = 400;
var image_1 : Texture2D;
private var maxImageWidth = BoxWidth-50;
private var ImageRatio;
private var NewImageWidth_1 = image_1.width;
private var NewImageHeight_1 = image_1.height;
if(image_1.width > maxImageWidth){
ImageRatio = maxImageWidth / image_1.width;
NewImageWidth_1 = image_1.width * ImageRatio;
NewImageHeight_1 = image_1.height * ImageRatio;
}
Comment
Answer by mattssonon · Oct 16, 2013 at 11:31 AM
You never assign ImageRatio to anything. The error code is telling you that the compiler sees ImageRatio as an Object, since it hasn't been assigned to any other data type.
Your answer