Skip to content

Commit

Permalink
UnityRecorder にも UnityFilter 追加
Browse files Browse the repository at this point in the history
  • Loading branch information
nasshu2916 committed Nov 28, 2024
1 parent 5997c63 commit f08a32b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ protected override void EndRecording(RecordingSession session)
var absolutePath = settings.FileNameGenerator.BuildAbsolutePath(session);
absolutePath = FileNameGenerator.SanitizePath(absolutePath);

var filteredFrames = FilterFrames(frames, settings.UniverseFilter);
switch (settings.OutputFormat)
{
case ArtNetRecorderSettings.ArtNetRecorderOutputFormat.Binary:
BinaryWrite(frames, absolutePath);
BinaryWrite(filteredFrames, absolutePath);
break;
case ArtNetRecorderSettings.ArtNetRecorderOutputFormat.AnimationClip:
AnimationClipWrite(frames, absolutePath);
AnimationClipWrite(filteredFrames, absolutePath);
break;
default:
throw new System.ArgumentOutOfRangeException();
Expand All @@ -52,6 +53,11 @@ protected override void EndRecording(RecordingSession session)
}
}

private static List<UniverseData> FilterFrames(List<UniverseData> frames, UniverseFilter filter)
{
return frames.Where(f => filter.IsMatch((int) f.Universe)).ToList();
}

private static void BinaryWrite(List<UniverseData> frames, string absolutePath)
{
var binary = RecordData.SerializeUniverseData(frames);
Expand Down
11 changes: 10 additions & 1 deletion Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ArtNet.Editor.UnityRecorder
[CustomEditor(typeof(ArtNetRecorderSettings))]
public class ArtNetRecorderEditor : RecorderEditor
{
private SerializedProperty _outputFormat;
private SerializedProperty _outputFormat, _universeFilter;

private static class Styles
{
Expand All @@ -22,6 +22,15 @@ protected override void OnEnable()
return;

_outputFormat = serializedObject.FindProperty("_outputFormat");
_universeFilter = serializedObject.FindProperty("_universeFilter");
}

protected override void ExtraOptionsGUI()
{
base.ExtraOptionsGUI();

EditorGUILayout.Space();
EditorGUILayout.PropertyField(_universeFilter, Styles.FormatLabel);
}

protected override void FileTypeAndFormatGUI()
Expand Down
7 changes: 7 additions & 0 deletions Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderSettings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.Collections.Generic;
using ArtNet.Editor.DmxRecorder;
using ArtNet.Editor.UnityRecorder.Input;
using UnityEditor.Recorder;
using UnityEngine;
using DefaultWildcard = UnityEditor.Recorder.DefaultWildcard;
using RecorderSettings = UnityEditor.Recorder.RecorderSettings;

namespace ArtNet.Editor.UnityRecorder
{
Expand All @@ -23,6 +26,7 @@ public override IEnumerable<RecorderInputSettings> InputsSettings
}

[SerializeField] private ArtNetRecorderOutputFormat _outputFormat = ArtNetRecorderOutputFormat.Binary;
[SerializeField] private UniverseFilter _universeFilter = new();

public ArtNetRecorderOutputFormat OutputFormat
{
Expand All @@ -43,6 +47,8 @@ protected override string Extension
}
}

public UniverseFilter UniverseFilter => _universeFilter;

public ArtNetRecorderSettings()
{
FileNameGenerator.AddWildcard(DefaultWildcard.GeneratePattern("GameObject"), GameObjectNameResolver);
Expand All @@ -68,6 +74,7 @@ private string GameObjectSceneNameResolver(RecordingSession session)
protected override void GetErrors(List<string> errors)
{
base.GetErrors(errors);
_universeFilter.GetErrors(errors);

if (ArtNetInputSettings.GameObject == null)
errors.Add("No assigned game object to record");
Expand Down

0 comments on commit f08a32b

Please sign in to comment.