From f08a32b2758149b2bf4da4d3e182141f2fc1574e Mon Sep 17 00:00:00 2001 From: NaoyaKohda Date: Thu, 28 Nov 2024 23:43:10 +0900 Subject: [PATCH] =?UTF-8?q?UnityRecorder=20=E3=81=AB=E3=82=82=20UnityFilte?= =?UTF-8?q?r=20=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorder.cs | 10 ++++++++-- .../Editor/UnityRecorder/ArtNetRecorderEditor.cs | 11 ++++++++++- .../Editor/UnityRecorder/ArtNetRecorderSettings.cs | 7 +++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorder.cs b/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorder.cs index 3526bb6..09fee71 100644 --- a/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorder.cs +++ b/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorder.cs @@ -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(); @@ -52,6 +53,11 @@ protected override void EndRecording(RecordingSession session) } } + private static List FilterFrames(List frames, UniverseFilter filter) + { + return frames.Where(f => filter.IsMatch((int) f.Universe)).ToList(); + } + private static void BinaryWrite(List frames, string absolutePath) { var binary = RecordData.SerializeUniverseData(frames); diff --git a/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderEditor.cs b/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderEditor.cs index 58651b0..5806eab 100644 --- a/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderEditor.cs +++ b/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderEditor.cs @@ -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 { @@ -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() diff --git a/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderSettings.cs b/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderSettings.cs index 0173e86..e8cbfda 100644 --- a/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderSettings.cs +++ b/Assets/ArtNet/Editor/UnityRecorder/ArtNetRecorderSettings.cs @@ -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 { @@ -23,6 +26,7 @@ public override IEnumerable InputsSettings } [SerializeField] private ArtNetRecorderOutputFormat _outputFormat = ArtNetRecorderOutputFormat.Binary; + [SerializeField] private UniverseFilter _universeFilter = new(); public ArtNetRecorderOutputFormat OutputFormat { @@ -43,6 +47,8 @@ protected override string Extension } } + public UniverseFilter UniverseFilter => _universeFilter; + public ArtNetRecorderSettings() { FileNameGenerator.AddWildcard(DefaultWildcard.GeneratePattern("GameObject"), GameObjectNameResolver); @@ -68,6 +74,7 @@ private string GameObjectSceneNameResolver(RecordingSession session) protected override void GetErrors(List errors) { base.GetErrors(errors); + _universeFilter.GetErrors(errors); if (ArtNetInputSettings.GameObject == null) errors.Add("No assigned game object to record");