Skip to content

Commit 3230fb6

Browse files
Dominique LerouxDominique Leroux
authored andcommitted
Fixes and improvements to the framework in preparation for the movie recorder.
Core/Editor/RecorderEditor.cs -------------------------------------------------------------------------------- Fixed input editor foldout functionality. Core/Editor/RecorderWindow.cs -------------------------------------------------------------------------------- Now recovering from errors happening when starting a recording session. Core/Engine/FrameRecorderGOControler.cs Core/Engine/RecordingSession.cs Core/Engine/Timeline/FrameRecorderClip.cs -------------------------------------------------------------------------------- Added visibility control to the frame recorder game object. Callers make it visible when verbose logging is enabled. Inputs/CBRenderTexture/Editor/CBRenderTextureInputSettingsEditor.cs -------------------------------------------------------------------------------- Renamed "Capture alpha" to "Preserve alpha", as agreed with Julien. Inputs/CBRenderTexture/Engine/CBRenderTextureInput.cs -------------------------------------------------------------------------------- Made settings public so MediaRecorder can inspect if alpha must be recorded. Inputs/CBRenderTexture/Shaders/CopyFrameBuffer.shader -------------------------------------------------------------------------------- Added missing pragma to enable/disable alpha capture. Recorders/ImageRecorder/Editor/ImageRecorderEditor.cs -------------------------------------------------------------------------------- Renamed "Video..." recorder category to "Video".
1 parent f0c198a commit 3230fb6

File tree

9 files changed

+37
-20
lines changed

9 files changed

+37
-20
lines changed

source/FrameRecorder/Core/Editor/RecorderEditor.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace UnityEditor.FrameRecorder
66
public abstract class RecorderEditor : Editor
77
{
88
protected SerializedProperty m_Inputs;
9+
bool[] m_ShowInputEditor;
910
SerializedProperty m_Verbose;
1011
SerializedProperty m_FrameRateMode;
1112
SerializedProperty m_FrameRate;
@@ -23,6 +24,9 @@ protected virtual void OnEnable()
2324
{
2425
var pf = new PropertyFinder<RecorderSettings>(serializedObject);
2526
m_Inputs = pf.Find(x => x.m_SourceSettings);
27+
m_ShowInputEditor = new bool[m_Inputs.arraySize];
28+
for (int i = 0; i < m_ShowInputEditor.Length; ++i)
29+
m_ShowInputEditor[i] = true;
2630
m_Verbose = pf.Find(x => x.m_Verbose);
2731
m_FrameRateMode = pf.Find(x => x.m_FrameRateMode);
2832
m_FrameRate = pf.Find(x => x.m_FrameRate);
@@ -118,12 +122,16 @@ protected virtual void OnInputGui()
118122
if (multiInputs)
119123
{
120124
EditorGUI.indentLevel++;
121-
EditorGUILayout.Foldout(true, "Input " + (i + 1));
125+
m_ShowInputEditor[i] =
126+
EditorGUILayout.Foldout(m_ShowInputEditor[i], "Input " + (i + 1));
122127
}
123128
var arrItem = m_Inputs.GetArrayElementAtIndex(i);
124-
var editor = Editor.CreateEditor( arrItem.objectReferenceValue );
125-
if( editor != null)
126-
editor.OnInspectorGUI();
129+
if (m_ShowInputEditor[i])
130+
{
131+
var editor = Editor.CreateEditor( arrItem.objectReferenceValue );
132+
if (editor)
133+
editor.OnInspectorGUI();
134+
}
127135

128136
if (multiInputs)
129137
EditorGUI.indentLevel--;

source/FrameRecorder/Core/Editor/RecorderWindow.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void DelayedStartRecording()
235235
void StartRecording(bool autoExitPlayMode)
236236
{
237237
var settings = (RecorderSettings)m_Editor.target;
238-
var go = FrameRecorderGOControler.HookupRecorder();
238+
var go = FrameRecorderGOControler.HookupRecorder(!settings.m_Verbose);
239239
var session = new RecordingSession()
240240
{
241241
m_Recorder = RecordersInventory.GenerateNewRecorder(m_recorderSelector.selectedRecorder, settings),
@@ -246,9 +246,13 @@ void StartRecording(bool autoExitPlayMode)
246246
component.session = session;
247247
component.autoExitPlayMode = autoExitPlayMode;
248248

249-
session.SessionCreated();
250-
session.BeginRecording();
251-
m_State = EState.Recording;
249+
if (session.SessionCreated() && session.BeginRecording())
250+
m_State = EState.Recording;
251+
else
252+
{
253+
m_State = EState.Idle;
254+
StopRecording();
255+
}
252256
}
253257

254258
void StopRecording()

source/FrameRecorder/Core/Engine/FrameRecorderGOControler.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@ public class FrameRecorderGOControler
1212
{
1313
const string k_HostGoName = "UnityEngine-Recorder-FrameRecorder";
1414

15-
static GameObject GetGameObject(bool createIfAbsent)
15+
static GameObject GetGameObject(bool createIfAbsent, bool hide)
1616
{
1717
var go = GameObject.Find(k_HostGoName);
1818
if (go == null && createIfAbsent)
1919
{
2020
go = new GameObject(k_HostGoName);
21+
if (hide)
22+
go.hideFlags = HideFlags.HideInHierarchy;
2123
}
24+
2225
return go;
2326
}
2427

25-
static GameObject GetRecordingSessionsRoot( bool createIfAbsent )
28+
static GameObject GetRecordingSessionsRoot(bool createIfAbsent, bool hideGameObjects)
2629
{
27-
var root = GetGameObject(createIfAbsent);
30+
var root = GetGameObject(createIfAbsent, hideGameObjects);
2831
if (root == null)
2932
return null;
33+
3034
var settingsTr = root.transform.Find("RecordingSessions");
3135
GameObject settingsGO;
3236
if (settingsTr == null)
@@ -40,9 +44,9 @@ static GameObject GetRecordingSessionsRoot( bool createIfAbsent )
4044
return settingsGO;
4145
}
4246

43-
public static GameObject HookupRecorder()
47+
public static GameObject HookupRecorder(bool hideGameObjects)
4448
{
45-
var ctrl = GetRecordingSessionsRoot(true);
49+
var ctrl = GetRecordingSessionsRoot(true, hideGameObjects);
4650

4751
var recorderGO = new GameObject();
4852

@@ -53,7 +57,7 @@ public static GameObject HookupRecorder()
5357

5458
public static GameObject FindRecorder(RecorderSettings settings)
5559
{
56-
var ctrl = GetRecordingSessionsRoot(false);
60+
var ctrl = GetRecordingSessionsRoot(false, false);
5761
if (ctrl == null)
5862
return null;
5963

source/FrameRecorder/Core/Engine/RecordingSession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public bool SessionCreated()
4848
public bool BeginRecording()
4949
{
5050
m_RecordingStartTS = (Time.time / Time.timeScale);
51+
m_Recorder.SignalInputsOfStage(ERecordingSessionStage.BeginRecording, this);
5152

5253
if (!m_Recorder.BeginRecording(this))
5354
return false;
5455
m_InitialFrame = Time.renderedFrameCount;
5556
m_FPSTimeStart = Time.unscaledTime;
5657

57-
m_Recorder.SignalInputsOfStage(ERecordingSessionStage.BeginRecording, this);
5858
return true;
5959
}
6060

source/FrameRecorder/Core/Engine/Timeline/FrameRecorderClip.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
3434
behaviour.session = new RecordingSession()
3535
{
3636
m_Recorder = RecordersInventory.GenerateNewRecorder(recorderType, m_Settings),
37-
m_RecorderGO = FrameRecorderGOControler.HookupRecorder(),
37+
m_RecorderGO = FrameRecorderGOControler.HookupRecorder(!m_Settings.m_Verbose),
3838
};
3939
}
4040
return playable;

source/FrameRecorder/Inputs/CBRenderTexture/Editor/CBRenderTextureInputSettingsEditor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public override void OnInspectorGUI()
6060
}
6161
}
6262

63-
EditorGUILayout.PropertyField(m_Transparency, new GUIContent("Capture alpha"));
63+
EditorGUILayout.PropertyField(m_Transparency, new GUIContent("Preserve alpha"));
6464
EditorGUILayout.PropertyField(m_FlipVertically, new GUIContent("Flip vertically"));
6565

6666
serializedObject.ApplyModifiedProperties();
@@ -72,4 +72,4 @@ public override void OnInspectorGUI()
7272

7373
}
7474
}
75-
}
75+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class CBRenderTextureInput : BaseRenderTextureInput
2020
Camera m_Camera;
2121
bool m_cameraChanged;
2222

23-
CBRenderTextureInputSettings cbSettings
23+
public CBRenderTextureInputSettings cbSettings
2424
{
2525
get { return (CBRenderTextureInputSettings)settings; }
2626
}

source/FrameRecorder/Inputs/CBRenderTexture/Shaders/CopyFrameBuffer.shader

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CGINCLUDE
44
#include "UnityCG.cginc"
55
#pragma multi_compile ___ UNITY_HDR_ON
66
#pragma multi_compile ___ OFFSCREEN
7+
#pragma multi_compile ___ TRANSPARENCY_ON
78

89
sampler2D _TmpFrameBuffer;
910
sampler2D _CameraGBufferTexture0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ImagRecorderEditor : RecorderEditor
1414

1515
string[] m_Candidates;
1616

17-
[MenuItem("Window/Recorder/Video...")]
17+
[MenuItem("Window/Recorder/Video")]
1818
static void ShowRecorderWindow()
1919
{
2020
RecorderWindow.ShowAndPreselectCategory("Video");

0 commit comments

Comments
 (0)