Skip to content

Commit

Permalink
add start/end events to GLTFRecorderComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Feb 7, 2022
1 parent 0ced23e commit e9a12e3
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
using UnityGLTF.Timeline;
#if UNITY_EDITOR
using UnityEditor.ShortcutManagement;
Expand All @@ -18,6 +19,9 @@ public class GLTFRecorderComponent : MonoBehaviour
public bool IsRecording => recorder?.IsRecording ?? false;
private GLTFRecorder recorder;

public UnityEvent recordingStarted;
public UnityEvent<string> recordingEnded;

#if UNITY_EDITOR
[Shortcut("gltf-recording-toggle", KeyCode.F11, displayName = "Start/Stop GLTF Recording")]
private static void ToggleRecording()
Expand Down Expand Up @@ -60,6 +64,7 @@ public void StartRecording()

recorder = new GLTFRecorder(exportRoot);
recorder.StartRecording(Time.timeAsDouble);
recordingStarted?.Invoke();

StartCoroutine(_UpdateRecording());
}
Expand All @@ -75,6 +80,7 @@ public void StopRecording()
{
var filename = outputFile.Replace("<Timestamp>", System.DateTime.Now.ToString("yyyyMMdd-HHmmss"));
recorder.EndRecording(filename);
recordingEnded?.Invoke(filename);
}

private IEnumerator _UpdateRecording()
Expand Down

0 comments on commit e9a12e3

Please sign in to comment.