@@ -27,6 +27,17 @@ public static EditorWindow GetMainGameView()
27
27
return ( EditorWindow ) Res ;
28
28
}
29
29
30
+
31
+ void GetGameRenderSize ( out int width , out int height )
32
+ {
33
+ var gameView = GetMainGameView ( ) ;
34
+ var prop = gameView . GetType ( ) . GetProperty ( "currentGameViewSize" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) ;
35
+ var gvsize = prop . GetValue ( gameView , new object [ 0 ] { } ) ;
36
+ var gvSizeType = gvsize . GetType ( ) ;
37
+
38
+ height = ( int ) gvSizeType . GetProperty ( "height" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) . GetValue ( gvsize , new object [ 0 ] { } ) ;
39
+ width = ( int ) gvSizeType . GetProperty ( "width" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) . GetValue ( gvsize , new object [ 0 ] { } ) ;
40
+ }
30
41
#endif
31
42
32
43
CBRenderTextureInputSettings cbSettings
@@ -70,12 +81,10 @@ public override void BeginRecording(RecordingSession session)
70
81
{
71
82
case EImageSource . GameDisplay :
72
83
{
73
- int screenWidth = Screen . width ;
84
+ int screenWidth = Screen . width ;
74
85
int screenHeight = Screen . height ;
75
86
#if UNITY_EDITOR
76
- var window = GetMainGameView ( ) ;
77
- screenWidth = ( int ) window . position . width ; // magic number: guaranteed to not be universal
78
- screenHeight = ( int ) window . position . height - 17 ; // magic number: guaranteed to not be universal
87
+ GetGameRenderSize ( out screenWidth , out screenHeight ) ;
79
88
#endif
80
89
if ( cbSettings . m_RenderSize == EImageDimension . Manual )
81
90
{
0 commit comments