readme
This commit is contained in:
@@ -20,7 +20,7 @@ public partial class PlaybackService : UXPanel
|
||||
[Export] private PackedScene template;
|
||||
[Export] private PackedScene labelTemplate;
|
||||
[Export] private DataPlayer dataPlayer;
|
||||
|
||||
private CancellationTokenSource cancellationTokenSource;
|
||||
public PlaybackService()
|
||||
{
|
||||
BITApp.ServiceCollection.AddSingleton(this);
|
||||
@@ -28,11 +28,17 @@ public partial class PlaybackService : UXPanel
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
OnExit();
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
cancellationTokenSource.Cancel();
|
||||
}
|
||||
public override void OnEntry()
|
||||
{
|
||||
cancellationTokenSource.Token.ThrowIfCancellationRequested();
|
||||
|
||||
var files =
|
||||
new DirectoryInfo(PathHelper.GetFolderPath("Demos", GetTree().CurrentScene.Name))
|
||||
.GetFiles()
|
||||
@@ -62,8 +68,18 @@ public partial class PlaybackService : UXPanel
|
||||
await UniTask.SwitchToTaskPool();
|
||||
|
||||
var array = BITAssets.Read<string[]>(x.FullName, "base64");
|
||||
|
||||
try
|
||||
{
|
||||
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext,
|
||||
cancellationTokenSource.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
stopwatch.Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext);
|
||||
stopwatch.Stop();
|
||||
|
||||
BIT4Log.Log<PlaybackService>($"已加载:{playableInfo.Name},耗时:{stopwatch.ElapsedMilliseconds}ms");
|
||||
|
Reference in New Issue
Block a user