- Home /
Get game view window current width & height in script
Is there a way to get the game view window size in code?
I have looked through the documentation for UnityEditor, GetWindow, and exhausted everything I can think of through the arduous try-everything-in-intellisense discovery method, with no results yet.
When I check Screen.width the width of the current inspector window comes out, not the actual width of the game view. When I use Screen.currentResolution.width, I get the target build resolution, not the current view size.
Is this possible?
Thanks in advance
Answer by zombience · Oct 21, 2013 at 11:14 PM
Ah. Just discovered it after far too long looking for this:
string[] res = UnityStats.screenRes.Split('x');
Debug.Log(int.Parse(res[0]) + " " + int.Parse(res[1]));
Thats it. it'll do the trick.
Your answer
Follow this Question
Related Questions
Draw inspector for SerializedObject within EditorWindow? 1 Answer
Edit child in parent list [Custom Inspector] 1 Answer
Some public attributes not shown in inspector, default references 3 Answers
how to link variable as inspector field 1 Answer
EditorGUILayout.TextField text get's deleted instantly. 2 Answers