godot/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
Rémi Verschelde 2b55ac445b
Merge pull request #72111 from raulsntos/method-info-metadata
Add `GodotTypeInfo::Metadata` to `MethodInfo`
2023-01-27 15:41:38 +01:00

51 lines
1.2 KiB
C#

using Godot;
using GodotTools.Internals;
using JetBrains.Annotations;
using static GodotTools.Internals.Globals;
namespace GodotTools
{
public partial class HotReloadAssemblyWatcher : Node
{
private Timer _watchTimer;
public override void _Notification(int what)
{
if (what == Node.NotificationWMWindowFocusIn)
{
RestartTimer();
if (Internal.IsAssembliesReloadingNeeded())
Internal.ReloadAssemblies(softReload: false);
}
}
private void TimerTimeout()
{
if (Internal.IsAssembliesReloadingNeeded())
Internal.ReloadAssemblies(softReload: false);
}
[UsedImplicitly]
public void RestartTimer()
{
_watchTimer.Stop();
_watchTimer.Start();
}
public override void _Ready()
{
base._Ready();
_watchTimer = new Timer
{
OneShot = false,
WaitTime = 0.5f
};
_watchTimer.Timeout += TimerTimeout;
AddChild(_watchTimer);
_watchTimer.Start();
}
}
}