Skip to content

Commit

Permalink
add preference to hide waveforms on timeline to resolve performance i…
Browse files Browse the repository at this point in the history
…ssues.
  • Loading branch information
hecomi committed Jun 29, 2024
1 parent 33d6b67 commit 1f223dc
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
59 changes: 59 additions & 0 deletions Assets/uLipSync/Editor/Preference.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}

}
11 changes: 11 additions & 0 deletions Assets/uLipSync/Editor/Preference.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/uLipSync/Editor/Timeline/uLipSyncClipEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1f223dc

Please sign in to comment.