- Home /
noob q: restricting gameplay to a 2d area not full-window
I've searched for days for an answer or a tutorial but Unity seems intent on using the whole window for its' gameplay.
What I want to achieve is similar to old, 80's style games where the gameplay takes up part of the screen, and the rest has UI. I appreciate that it was done to improve performance in most cases, but in my case I have gameplay reasons.
In this image, the black area is where I want the game part to play out, and the red area will have UI components throughout.
Some of the sprites will be able to be moved partially or wholly outside of the game area, and I need to clip them or cull them completely, so that nothing shows outside the white border line.
Ideally, I wanted the gameplay area to be a node within which I could embed the player, background, enemies, and bullets.
What's the recommended solution for such a thing?
Answer by jayghost1983 · Apr 19, 2020 at 01:32 PM
You can make your UI panels cover the areas you don't want to be showing to the player. I am making a "use computer" system with a similar approach, except the "computer monitor" is the black square. I just use a UI panel system. That won't necessarily work for you if you're using a camera to view the game world (scene). But, attaching UI panels to your camera and ensuring the offset for the following target keeps the player character in the center of the play area screen should work fine.
Answer by IanWellock · Apr 19, 2020 at 03:31 PM
Damn, I was hoping there was an official solution that wasn't just "draw over the bits you don't want to show". :-(
It seems awfully wasteful to have to process that data when it's not going to be shown anyway.
Thanks for the advice, @jayghost1983, I appreciate the clarification.
Your answer
Follow this Question
Related Questions
Restricting rotation among 2D object 0 Answers
2D Animation does not start 1 Answer
Restrictions on gameobject 2D rotation? 1 Answer
Player restrictions 2 Answers