31 lines
615 B
C#
31 lines
615 B
C#
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
using Godot;
|
|
|
|
namespace BITKit;
|
|
|
|
public static class LabelExtensions
|
|
{
|
|
public static async void SetTextAsync(this Label self, string text)
|
|
{
|
|
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext);
|
|
if (self is not null)
|
|
self.Text = text;
|
|
}
|
|
|
|
public static async void SetTextAsync(this RichTextLabel self, string text)
|
|
{
|
|
var path = self.SceneFilePath;
|
|
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext);
|
|
try
|
|
{
|
|
self.Text = text;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
BIT4Log.Warning(path);
|
|
throw;
|
|
}
|
|
|
|
}
|
|
} |