unfortunately you cannot change the bounds of a sprite using code, you have to use the localscale.
I know where I want the sprite to be positioned(although I have to use centre not top/left) and it’s world width/height, but I cannot workout how to put this in the localscale I’ve been searching for several hours.
can anybody point me in the correct direction.
spriteGameObject.transform.localScale = (x, y, z); and change it depended on position (you can make it child and the main object will stay at the same size). And you can change pivot point, if you will not use center. Or you will make something other ?
If you know the current world size, and the size you want it to be, you can do this to get the scale to do that transformation.
targetSize.x / currentSize.x = x scale to be correct width
targetSize.y / currentSize.y = y scale to be correct height
1 Like
Actually I had to create some textures on the fly, but I wanted for testing purposes, a sprite with a default image on it, so I thought I might as well create the Texture2D’s and use them, they are plain black so far, but it helped to get the job done, and move on, I’ve been figuring out a mini map, I didn’t want to use another camera, or a UI element so I’ve rolled my own using a gameobject etc.
cheers guys for the post though I’m sure @LiterallyJeff will come in handy.