android - How to set scale to object image in unity 3D by Code? -
i'm new unity 3d developer create button c# code , set image button image show small. how resize scale image ?
if image
component, use assign new vector3
image.recttransform.localscale
. suggest use vector3
instead of vector2
can use 1 z value. code below scale x , y 4 leave z 1.
public image myimage; void start() { myimage.recttransform.localscale = new vector3(4, 4, 1); }
for texture2d
use method below.
public texture2d myimage; void start() { myimage.resize(4, 4); myimage.apply(); }
for sprite
public sprite myimage; void start() { myimage.texture.resize(4,4); myimage.texture.apply(); }
for spriterenderer
public spriterenderer myimage; void start() { myimage.transform.localscale = new vector3(4, 4, 1); }
for gui.button
float x = 300; float y = 300; float width = 150; float height = 150; void ongui() { if (gui.button(new rect(x, y,width, height), new guicontent(icon))) { } //scale width width = 400; //scale height height = 400; }
Comments
Post a Comment