diff --git a/Assets/uLipSync/Editor/Preference.cs b/Assets/uLipSync/Editor/Preference.cs new file mode 100644 index 0000000..402b662 --- /dev/null +++ b/Assets/uLipSync/Editor/Preference.cs @@ -0,0 +1,59 @@ +using UnityEditor; + +namespace uLipSync +{ + +internal class EditorPrefsStr +{ + public const string DisplayWaveformOnTimeline = "uLipSync-Timeline-DisplayWaveform"; +} + +public static class Preference +{ + public static bool displayWaveformOnTimeline + { + get => EditorPrefs.GetBool(EditorPrefsStr.DisplayWaveformOnTimeline, true); + set => EditorPrefs.SetBool(EditorPrefsStr.DisplayWaveformOnTimeline, value); + } +} + +public class PreferenceProvider : SettingsProvider +{ + const string PreferencePath = "Preferences/uLipSync"; + const int LabelWidth = 200; + + PreferenceProvider(string path, SettingsScope scopes) : base(path, scopes) + { + } + + public override void OnGUI(string searchContext) + { + EditorGUILayout.Separator(); + + var defaultLabelWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = LabelWidth; + + ++EditorGUI.indentLevel; + + { + bool current = Preference.displayWaveformOnTimeline; + bool result = EditorGUILayout.Toggle("Display Waveform On Timeline", current); + if (current != result) + { + Preference.displayWaveformOnTimeline = result; + } + } + + --EditorGUI.indentLevel; + + EditorGUIUtility.labelWidth = defaultLabelWidth; + } + + [SettingsProvider] + public static SettingsProvider CreateSettingProvider() + { + return new PreferenceProvider(PreferencePath, SettingsScope.User); + } +} + +} \ No newline at end of file diff --git a/Assets/uLipSync/Editor/Preference.cs.meta b/Assets/uLipSync/Editor/Preference.cs.meta new file mode 100644 index 0000000..9e3a9cc --- /dev/null +++ b/Assets/uLipSync/Editor/Preference.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a4af94b9fd083432aaf499b1e38fb22c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uLipSync/Editor/Timeline/uLipSyncClipEditor.cs b/Assets/uLipSync/Editor/Timeline/uLipSyncClipEditor.cs index 5cbb377..7d1a6d2 100644 --- a/Assets/uLipSync/Editor/Timeline/uLipSyncClipEditor.cs +++ b/Assets/uLipSync/Editor/Timeline/uLipSyncClipEditor.cs @@ -122,7 +122,7 @@ Texture2D GetOrCreateCachedTexture(uLipSyncClip clip, int width, int height) public override void DrawBackground(TimelineClip clip, ClipBackgroundRegion region) { DrawBackground(region); - DrawWave(clip, region); + if (Preference.displayWaveformOnTimeline) DrawWave(clip, region); } void DrawBackground(ClipBackgroundRegion region)