Improve audio clip window usability in Editor
This commit is contained in:
@@ -34,16 +34,16 @@ namespace FlaxEditor.Windows.Assets
|
||||
return;
|
||||
var height = Height;
|
||||
var width = Width;
|
||||
|
||||
|
||||
// Draw current time
|
||||
var playPosition = Source.Time / info.Length * width;
|
||||
Render2D.DrawLine(new Float2(playPosition, 0), new Float2( playPosition, height), Color.White);
|
||||
|
||||
Render2D.DrawLine(new Float2(playPosition, 0), new Float2(playPosition, height), Color.White);
|
||||
|
||||
// Draw current mouse pointer
|
||||
var mousePos = PointFromScreen(Input.MouseScreenPosition);
|
||||
if (mousePos.X > 0 && mousePos.Y > 0 && mousePos.X < width && mousePos.Y < height)
|
||||
{
|
||||
Render2D.DrawLine(new Float2(mousePos.X, 0), new Float2( mousePos.X, height), Color.White.AlphaMultiplied(0.3f));
|
||||
Render2D.DrawLine(new Float2(mousePos.X, 0), new Float2(mousePos.X, height), Color.White.AlphaMultiplied(0.3f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,10 +196,13 @@ namespace FlaxEditor.Windows.Assets
|
||||
// Toolstrip
|
||||
_toolstrip.AddButton(Editor.Icons.Import64, () => Editor.ContentImporting.Reimport((BinaryAssetItem)Item)).LinkTooltip("Reimport");
|
||||
_toolstrip.AddSeparator();
|
||||
_playButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Play64, OnPlay).LinkTooltip("Play/stop audio");
|
||||
_pauseButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Pause64, OnPause).LinkTooltip("Pause audio");
|
||||
_playButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Play64, OnPlay).LinkTooltip("Play/stop audio (F5)");
|
||||
_pauseButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Pause64, OnPause).LinkTooltip("Pause audio (F6)");
|
||||
_toolstrip.AddSeparator();
|
||||
_toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/audio/audio-clip.html")).LinkTooltip("See documentation to learn more");
|
||||
|
||||
InputActions.Add(options => options.Play, OnPlay);
|
||||
InputActions.Add(options => options.Pause, OnPause);
|
||||
}
|
||||
|
||||
private void OnPlay()
|
||||
@@ -213,6 +216,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
_previewSource = new AudioSource
|
||||
{
|
||||
Parent = _previewScene,
|
||||
AllowSpatialization = false,
|
||||
Clip = _asset,
|
||||
};
|
||||
_preview.Source = _previewSource;
|
||||
@@ -227,7 +231,12 @@ namespace FlaxEditor.Windows.Assets
|
||||
private void OnPause()
|
||||
{
|
||||
if (_previewSource)
|
||||
_previewSource.Pause();
|
||||
{
|
||||
if (_previewSource.State == AudioSource.States.Playing)
|
||||
_previewSource.Pause();
|
||||
else
|
||||
_previewSource.Play();
|
||||
}
|
||||
UpdateToolstrip();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user