- Home /
How to change aspect ratio of Game View from Unity Editor scripting API
I would like to change acpect ratio in GameView from Editor's script, because navigating in dropdown menu is annoying our designer. He often changes landscape and portrait view and he would like to have buttons to change aspect quickly. Ideally, it would be great to place such buttons right in Game View Toolbar (as I drew in red on screenshot below): But having buttons inside separate tool window would be nice too. The problem is that I can't find how to change aspect programmatically.
Answer by dasm30 · Mar 31, 2017 at 09:57 PM
Maybe this could help? http://answers.unity3d.com/questions/956123/add-and-select-game-view-resolution.html
Answer by Wappenull · Apr 10, 2021 at 12:14 PM
I'm making dasm30 link answer into keyboard shortcut version.
ALT+1 = 1280x720 (not added by default, you have to add it manually to work) ALT+2 = 1920x1080 ALT+3 = 2560x1440
It is global shortcut key, and will be shown in "Edit > Shortcuts" menu.
To change the resolution the key is taking, you must modify the hard code.
https://gist.github.com/wappenull/668a492c80f7b7fda0f7c7f42b3ae0b0
It is editor script, so save it somewhere right for editor script. e.g., Assets/Scripts/Editor
Your answer
Follow this Question
Related Questions
Want to get the location of the GameView Window 1 Answer
Create a custom fullscreen game view window 0 Answers
Change gameview ratio / resolution using a custom inspector? 1 Answer
Unity crashes when using ExecuteAlways on a UIBehaviour 0 Answers
What's the C# equivalent of @script ExecuteInEditMode() ? 2 Answers