Hi,
Unity v5.1.3, platform Android.
How to determinate playerwindow resolution in script? that i set in editor window like WXGA,WVGA.
Screen.currentResolution return default resolution or resolution of my desktop screen.
Camera.main.pixelRect return resolution of playereditorwindow.
Thanks.
void SetScreenWidthAndHeightFromEditorGameViewViaReflection()
{
var gameView = GetMainGameView();
var prop = gameView.GetType().GetProperty("currentGameViewSize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var gvsize = prop.GetValue(gameView, new object[0]{});
var gvSizeType = gvsize.GetType();
debug_h = (int)gvSizeType.GetProperty("height", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0]{});
debug_w = (int)gvSizeType.GetProperty("width", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0]{});
}
UnityEditor.EditorWindow GetMainGameView()
{
System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor");
System.Reflection.MethodInfo GetMainGameView = T.GetMethod("GetMainGameView",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
System.Object Res = GetMainGameView.Invoke(null,null);
return (UnityEditor.EditorWindow)Res;
}