1
1
#if UNITY_EDITOR
2
2
3
3
using System ;
4
- using System . Collections . Generic ;
5
4
using System . Reflection ;
6
5
using UnityEditor ;
7
6
@@ -42,29 +41,8 @@ static object Group()
42
41
return group ;
43
42
}
44
43
45
- static int TotalCount ( )
46
- {
47
- var group = Group ( ) ;
48
- var totalCount = group . GetType ( ) . GetMethod ( "GetTotalCount" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) ;
49
- return ( int ) totalCount . Invoke ( group , null ) ;
50
- }
51
-
52
-
53
- static object GetGameViewSize ( object group , int index )
54
- {
55
- var obj = group . GetType ( ) . GetMethod ( "GetGameViewSize" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) ;
56
- return obj . Invoke ( group , new object [ ] { index } ) ;
57
- }
58
-
59
- static void SizeOf ( object gameViewSize , out int width , out int height )
60
- {
61
- width = ( int ) gameViewSize . GetType ( ) . GetProperty ( "width" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) . GetValue ( gameViewSize , new object [ 0 ] { } ) ;
62
- height = ( int ) gameViewSize . GetType ( ) . GetProperty ( "height" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) . GetValue ( gameViewSize , new object [ 0 ] { } ) ;
63
- }
64
-
65
44
public static object SetCustomSize ( int width , int height )
66
45
{
67
- // Find recorder size object
68
46
var sizeObj = FindRecorderSizeObj ( ) ;
69
47
if ( sizeObj != null )
70
48
{
@@ -80,7 +58,7 @@ public static object SetCustomSize(int width, int height)
80
58
}
81
59
82
60
83
- private static object FindRecorderSizeObj ( )
61
+ static object FindRecorderSizeObj ( )
84
62
{
85
63
var group = Group ( ) ;
86
64
@@ -118,14 +96,11 @@ public static int IndexOf(object sizeObj)
118
96
119
97
static object NewSizeObj ( int width , int height )
120
98
{
121
- var T = System . Type . GetType ( "UnityEditor.GameViewSize,UnityEditor" ) ;
122
- var sizeObj = Activator . CreateInstance ( T , new object [ ] { 1 , width , height , string . Format ( "FrameRecorder" , width , height ) } ) ;
123
-
124
- T . GetProperty ( "sizeType" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) . SetValue ( sizeObj , 1 , new object [ 0 ] { } ) ;
125
- T . GetProperty ( "width" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) . SetValue ( sizeObj , width , new object [ 0 ] { } ) ;
126
- T . GetProperty ( "height" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) . SetValue ( sizeObj , height , new object [ 0 ] { } ) ;
127
- T . GetProperty ( "baseText" , System . Reflection . BindingFlags . Public | System . Reflection . BindingFlags . Instance ) . SetValue ( sizeObj , "(Recording resolution)" , new object [ 0 ] { } ) ;
99
+ var T = Type . GetType ( "UnityEditor.GameViewSize,UnityEditor" ) ;
100
+ var TT = Type . GetType ( "UnityEditor.GameViewSizeType,UnityEditor" ) ;
128
101
102
+ var c = T . GetConstructor ( new Type [ ] { TT , typeof ( int ) , typeof ( int ) , typeof ( string ) } ) ;
103
+ var sizeObj = c . Invoke ( new object [ ] { 1 , width , height , string . Format ( "FrameRecorder" , width , height ) } ) ;
129
104
return sizeObj ;
130
105
}
131
106
0 commit comments