Skip to content

Commit 9fc7051

Browse files
committed
- minor refactoring and some minor fixes
- runInBackground turned on by recording session. does turn it back off.
1 parent 0c0d6ee commit 9fc7051

File tree

8 files changed

+41
-25
lines changed

8 files changed

+41
-25
lines changed

source/FrameRecorder/Core/Editor/RecorderEditor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ public override void OnInspectorGUI()
136136
}
137137
}
138138

139-
protected void AddSourceSettings(RecorderInputSetting sourceSettings)
139+
protected void AddInputSettings(RecorderInputSetting inputSettings)
140140
{
141141
m_Inputs.InsertArrayElementAtIndex(m_Inputs.arraySize);
142142
var arryItem = m_Inputs.GetArrayElementAtIndex(m_Inputs.arraySize-1);
143-
arryItem.objectReferenceValue = sourceSettings;
143+
arryItem.objectReferenceValue = inputSettings;
144144

145-
m_InputEditors.Add( new InputEditorState(GetFieldDisplayState, sourceSettings) { visible = true} );
145+
m_InputEditors.Add( new InputEditorState(GetFieldDisplayState, inputSettings) { visible = true} );
146146

147147
serializedObject.ApplyModifiedProperties();
148148
}

source/FrameRecorder/Core/Editor/RecorderSelector.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public void Init( RecorderSettings settings, string startingCategory = "" )
3838
if (string.Compare(recInfo.category, startingCategory, StringComparison.InvariantCultureIgnoreCase) != 0)
3939
{
4040
// forced another category, flush existing settings obj.
41-
SelectRecorder(null);
41+
SetCategory(startingCategory);
42+
SelectRecorder( GetRecorderFromIndex(0) );
4243
}
4344
}
4445

@@ -50,8 +51,6 @@ public void Init( RecorderSettings settings, string startingCategory = "" )
5051
return;
5152
}
5253
}
53-
54-
SetCategory(string.Empty);
5554
}
5655

5756
int GetCategoryIndex()

source/FrameRecorder/Core/Editor/RecorderWindow.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public static void ShowAndPreselectCategory(string category)
2626
var window = GetWindow(typeof(RecorderWindow), false, "Recorder") as RecorderWindow;
2727

2828
if (RecordersInventory.recordersByCategory.ContainsKey(category))
29+
{
2930
window.m_StartingCategory = category;
31+
window.m_recorderSelector = null;
32+
}
3033
}
3134

3235
public void OnEnable()
@@ -44,7 +47,6 @@ protected void Update()
4447
}
4548
}
4649

47-
4850
Vector2 m_ScrollPos;
4951

5052
public void OnGUI()

source/FrameRecorder/Core/Engine/RecordingSession.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,18 @@ public float RecorderTime
3838
get { return (float)(m_CurrentFrameStartTS - settings.m_StartTime); }
3939
}
4040

41+
void AllowInBackgroundMode()
42+
{
43+
if (!Application.runInBackground)
44+
{
45+
Application.runInBackground = true;
46+
Debug.Log("Recording sessions is enabling Application.runInBackground!");
47+
}
48+
}
49+
4150
public bool SessionCreated()
4251
{
52+
AllowInBackgroundMode();
4353
m_RecordingStartTS = (Time.time / Time.timeScale);
4454
m_SessionStartTS = DateTime.Now;
4555
m_Recorder.SessionCreated(this);
@@ -49,6 +59,8 @@ public bool SessionCreated()
4959

5060
public bool BeginRecording()
5161
{
62+
AllowInBackgroundMode();
63+
5264
m_RecordingStartTS = (Time.time / Time.timeScale);
5365
m_Recorder.SignalInputsOfStage(ERecordingSessionStage.BeginRecording, this);
5466

@@ -93,7 +105,7 @@ public void RecordFrame()
93105
{
94106
if(settings.m_Verbose)
95107
Debug.Log( string.Format("Recording session info => dT: {0:F1}s, Target dT: {1:F1}s, Retarding: {2}ms, fps: {3:F1}", elapsed, target, sleep, frameCount / elapsed ));
96-
System.Threading.Thread.Sleep(sleep);
108+
System.Threading.Thread.Sleep( Math.Min(sleep,1000));
97109
}
98110
else if (sleep < -frameLen)
99111
m_InitialFrame--;
@@ -118,6 +130,8 @@ public void RecordFrame()
118130

119131
public void PrepareNewFrame()
120132
{
133+
AllowInBackgroundMode();
134+
121135
m_CurrentFrameStartTS = (Time.time / Time.timeScale) - m_RecordingStartTS;
122136
m_Recorder.SignalInputsOfStage(ERecordingSessionStage.NewFrameStarting, this);
123137
m_Recorder.PrepareNewFrame(this);

source/FrameRecorder/Inputs/Adam/Engine/AdamBeautyInput.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public override void NewFrameStarting(RecordingSession session)
169169
continue;
170170
}
171171

172-
if (!cam.enabled || !cam.gameObject.active || cam.targetDisplay != 0)
172+
if (!cam.enabled || !cam.gameObject.activeInHierarchy || cam.targetDisplay != 0)
173173
continue;
174174

175175
hookedCam = new HookedCamera() { camera = cam, textureBackup = cam.targetTexture };

source/FrameRecorder/Packager/Editor/FRPackagerPaths.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static string GetFrameRecorderRootPath()
1111
string path = Application.dataPath + AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(dummy)).Substring("Assets".Length);
1212

1313
path = path.Substring(path.IndexOf("Assets"));
14-
path = path.Replace("/Framework/FrameRecorder/Packager/Editor/FRPackagerPaths.cs", "");
14+
path = path.Replace("/Framework/Packager/Editor/FRPackagerPaths.cs", "");
1515
return path;
1616
}
1717
}

source/FrameRecorder/Packager/Private/Editor/FRPackager.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ static void GeneratePackage()
2121
string[] files = new string[]
2222
{
2323
Path.Combine(rootPath, "Framework.meta"),
24-
Path.Combine(rootPath, "Framework/FrameRecorder.meta"),
25-
Path.Combine(rootPath, "Framework/FrameRecorder/Core"),
26-
Path.Combine(rootPath, "Framework/FrameRecorder/Inputs"),
27-
Path.Combine(rootPath, "Framework/FrameRecorder/Recorders"),
28-
Path.Combine(rootPath, "Framework/FrameRecorder/Packager/Editor"),
24+
Path.Combine(rootPath, "Framework/Core"),
25+
Path.Combine(rootPath, "Framework/Inputs"),
26+
Path.Combine(rootPath, "Framework/Recorders"),
27+
Path.Combine(rootPath, "Framework/Packager/Editor"),
2928
};
3029
var destFile = k_PackageName + ".unitypackage";
3130
AssetDatabase.ExportPackage(files, destFile, ExportPackageOptions.Recurse);
@@ -37,20 +36,22 @@ static void GeneratePackageFull()
3736
{
3837
var rootPath = FRPackagerPaths.GetFrameRecorderRootPath();
3938
var type = System.Type.GetType("UnityEditor.FrameRecorder.MovieRecorderPackager");
40-
var method = type.GetMethod("GeneratePackage");
41-
method.Invoke(null, null);
42-
AssetDatabase.Refresh();
39+
if (type != null)
40+
{
41+
var method = type.GetMethod("GeneratePackage");
42+
method.Invoke(null, null);
43+
AssetDatabase.Refresh();
44+
}
4345

4446
var files = new []
4547
{
4648
Path.Combine(rootPath, "Framework.meta" ),
47-
Path.Combine(rootPath, "Framework/FrameRecorder.meta" ),
48-
Path.Combine(rootPath, "Framework/FrameRecorder/Core" ),
49-
Path.Combine(rootPath, "Framework/FrameRecorder/Inputs" ),
50-
Path.Combine(rootPath, "Framework/FrameRecorder/Recorders" ),
51-
Path.Combine(rootPath, "Framework/FrameRecorder/Packager/Editor" ),
49+
Path.Combine(rootPath, "Framework/Core" ),
50+
Path.Combine(rootPath, "Framework/Inputs" ),
51+
Path.Combine(rootPath, "Framework/Recorders" ),
52+
Path.Combine(rootPath, "Framework/Packager/Editor" ),
5253
Path.Combine(rootPath, "Extensions/UTJ" ),
53-
Path.Combine(rootPath, "Extensions/FrameCapturerRecorder" ),
54+
Path.Combine(rootPath, "Extensions/FCIntegration" ),
5455
Path.Combine(rootPath, "Extensions/MovieRecorder/Packaging" ),
5556
};
5657
var destFile = k_PackageName + "(full).unitypackage";

source/FrameRecorder/Recorders/ImageRecorder/Editor/ImageRecorderEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class ImageRecorderEditor : RecorderEditor
1111
SerializedProperty m_OutputFormat;
1212
RTInputSelector m_RTInputSelector;
1313

14-
[MenuItem("Window/Recorder/Video")]
14+
[MenuItem("Tools/Recorder/Video")]
1515
static void ShowRecorderWindow()
1616
{
1717
RecorderWindow.ShowAndPreselectCategory("Video");

0 commit comments

Comments
 (0)