Skip to content

Commit d209fc5

Browse files
committed
Fixed issue with setting game view resolution
1 parent e58c1c1 commit d209fc5

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

source/FrameRecorder/Inputs/CBRenderTexture/Engine/GameViewSize.cs

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#if UNITY_EDITOR
22

33
using System;
4-
using System.Collections.Generic;
54
using System.Reflection;
65
using UnityEditor;
76

@@ -42,29 +41,8 @@ static object Group()
4241
return group;
4342
}
4443

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-
6544
public static object SetCustomSize(int width, int height)
6645
{
67-
// Find recorder size object
6846
var sizeObj = FindRecorderSizeObj();
6947
if (sizeObj != null)
7048
{
@@ -80,7 +58,7 @@ public static object SetCustomSize(int width, int height)
8058
}
8159

8260

83-
private static object FindRecorderSizeObj()
61+
static object FindRecorderSizeObj()
8462
{
8563
var group = Group();
8664

@@ -118,14 +96,11 @@ public static int IndexOf(object sizeObj)
11896

11997
static object NewSizeObj(int width, int height)
12098
{
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");
128101

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) });
129104
return sizeObj;
130105
}
131106

0 commit comments

Comments
 (0)