- Home /
Stretch Worldspace to Screen Resolution
So oddly enough, I can't find a question on this, so I can't find an answer. It seems quite simple however.
I need my world to scale with the user's resolution. I have an orthographic camera, but changing the resolution instead allows the player to see more of the gameworld. I want a simple boundary that the camera simply stretches to. Is there an option I am missing somewhere? The solution to this seems like it should be nearly script-free.
O$$anonymous$$, thank you all for your attempts to help me. I would prefer no black edges on my camera space however. Additionally, I will not scale gameobjects. This will mess up several things right off the bat. Take for instance rigidbodies, scripted overlapped circles, particle systems, etc. So much doesn't change when you scale a gameobject.
The link I sent last doesn't scale game objects but the rendered image of the texture supposedly. So I'd try to learn more from the people in there or search on my own on how that can be done. From what I understand they use the rendertexture in a kind of post processing way.
I know exactly what they are doing. I will not re-size anything instanced. If it applies to the whole project - no if the ONLY way the solution works is on the entire scene rendering, then it is the proper solution. If the solution can be controlled to a per-instance method, then it is incorrect.
Check out this https://youtu.be/r$$anonymous$$CLWt1DuqI?t=2190. Notice before he makes the correction for an ipad, aka as it is on the iphone (640x1136), there is a significant amount of space above the building. It is a lot of grey matter in his scene, but in $$anonymous$$e, it is very important that this area remains as is. Once he scales down to the ipad, you can see the width adjusts to the value he wants, however there is far less grey matter, important objects that get lost.
Now, as far as rendered image of the texture, there are two problems with this: 1) If you are referring to render to texture methods, this requires a pro-license. I'd like this solution to be accessible by all users. 2)This method would work, for pro-users that is, only if they did not use multiple cameras overlapping with different render-depths, which is a common feature in many 2D games that have parallax utility or any other background/foreground.
Answer by JadeTheFlame · Oct 31, 2015 at 06:17 AM
I just want to say thank you especially @npatch, through our conversing, I have realized it is as simple as one of your comments implies. Render to texture has been made free for all. The trick is to use multiple cameras and render them to the same target texture, and then stretch that texture to the camera when the user changes by reading the screen dimensions. You simply have to keep the texture resolution high to not lose data. Thank you.
Answer by npatch · Oct 27, 2015 at 01:25 PM
You probably used the wrong words in your search. Scaling 2d sprites by screen res
or
How To Resize Sprite GameObjects To Fit Different Resolutions?
Not sure but you could also try using the Canvas since it has a Canvas Resize script for such cases. You can set it to work with Full HD res and then scale down for better results instead of trying to scale up which is worse.
Answer by starikcetin · Oct 27, 2015 at 05:19 PM
The only proper way i know to do this is to add black parts on sides of screen.
1- You should choose a safe aspect ration (that is, usually 3:2 on android when you only use landscape)
2- Detect the floaded areas by stretching this aspect ratio to fit one side to corresponding side of screen.
3- Simply make that areas black.
So even user's monitor gets bigger or aspect ratio changes, users will see the same thing with different sizes.
Thing is he wants resizing of everything and that's a difficult subject,which is why there's no easy answer. Even Unity's UI resizes every ui element with screen size on runtime.
You see that's a solution that I considered. But that seems kind of lazy doesn't it? Honestly, do any of us want to release a game with black bars on the side? You're the first to actually get what my request is about, I'll give you props for that.
Yes, this method destroys the game feeling. I'm currently looking for another solution too, for my own game. $$anonymous$$ay be we can request a "stretching the output render" option from unity itself, like any other game does to deal with aspect ratios.
I think you are correct. If you submit something to the devs let me know, I will fully support it.
Answer by Ashkan_gc · Oct 27, 2015 at 05:31 PM
If you don't want to resize all elements then the only thing coming to my mind is changing orthographic size. basically the size is half of the height which will be visible so size of 4 means 4 meters will be visible. if you want it to change based on the ratio of the width and height of the screen, you can have a script which changes it, so you don't show the same amount of content in all ratios but the height will be proportional to your width/height ratio. I don't know if it is desirable in your case or not however.
Nope, I can change the size of the camera all day long so that the height or the width fit a certain area. Either way, one gets cut out. If I change the height, the width never stays constant, and vice versa. What I need, if you like examples, is for that screen with a height of 4 and a width of 6, render the exact same objects in veiw when the aspect ratio changes from 4:6 to 4:5. If you need me to be even $$anonymous$$ORE specific. Lets say there is an object on the left of my screen and one at the right of my screen. I need both of them in the camera. Now the user changes his resolution, and because the height remains the same, but the width changes, the user cannot see either object. I need the worldspace to STRETCH, or I need a SPECIAL CA$$anonymous$$ERA.
Your answer
Follow this Question
Related Questions
How to handle mobile resolutions without a headache? 0 Answers
How can i access all the GameObjects in the scene? 1 Answer
Edit multiple assets at the same time? 2 Answers
problem with building my game 1 Answer
UI scaling issues 2 Answers