- Home /
Scaling down dynamically created objects
I have a 2D game in which Aircraft and Missiles are instantiated at run time from prefabs. However when the game is resized(scaled down) although the background and other objects scale down the dynamically created objects dont scale down and look really out sized.
What is the best way to scale down such objects(dynamically created)
Is there a way to detect screen resizing?
Answer by Meltdown · Mar 03, 2012 at 10:47 AM
You can use the Screen.height and Screen.width properties to detect the screen size in Update().
If the user resizes, you can write a simple method to scale your objects proportionate to how the width and height of the screen have been resized.
Hi Thanks for the answer. That will work.But I will have to check in every update for screen resize. Is there an event like OnResize which I can use - will be more elegant and efficient
It's a very cheap call so you can use it. The Unity engine can handle much more than checking the screen size in Update :)