// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using FlaxEditor.Content;
using FlaxEditor.Content.Import;
namespace FlaxEditor.Progress.Handlers
{
///
/// Importing assets progress reporting handler.
///
///
public sealed class ImportAssetsProgress : ProgressHandler
{
private string _currentInfo;
///
/// Initializes a new instance of the class.
///
public ImportAssetsProgress()
{
var importing = Editor.Instance.ContentImporting;
importing.ImportingQueueBegin += OnStart;
importing.ImportingQueueEnd += OnEnd;
importing.ImportFileBegin += OnImportFileBegin;
}
private void OnImportFileBegin(IFileEntryAction importFileEntry)
{
if (importFileEntry is ImportFileEntry)
_currentInfo = string.Format("Importing \'{0}\'", System.IO.Path.GetFileName(importFileEntry.SourceUrl));
else
_currentInfo = string.Format("Creating \'{0}\'", importFileEntry.SourceUrl);
UpdateProgress();
}
private void UpdateProgress()
{
var importing = Editor.Instance.ContentImporting;
var info = string.Format("{0} ({1}/{2})...", _currentInfo, importing.ImportBatchDone, importing.ImportBatchSize);
OnUpdate(importing.ImportingProgress, info);
}
}
}