- Home /
Question by
JohanHoltby · Mar 10, 2014 at 06:25 AM ·
c#guidrawtexture
How to get correct zooming in GUI.DrawTexture?
Hi! I'm trying to zoom a texture in the Editor GUI according to the position of the mouse when you "scroll" down or up with the mouse wheal. However I get a strange ofset which makes the texture float of when you scroll. Here is a demo code: http://pastebin.com/7tX1tbsj
Thanks for the help. I have worked on the problem for about 6 hours now.
Comment
Best Answer
Answer by JohanHoltby · Mar 11, 2014 at 12:46 PM
Line 96 and 97 should be:
textureDisplayOfset.x = textureDisplayOfset.x - (scaleFactor-1)*mouseTexturePos.x*textureDisplayScale; textureDisplayOfset.y = textureDisplayOfset.y - (scaleFactor-1)*mouseTexturePos.y*textureDisplayScale;
I did miss the scale factor.
Your answer
![](https://koobas.hobune.stream/wayback/20220613135848im_/https://answers.unity.com/themes/thub/images/avi.jpg)