1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-25 15:37:42 +00:00
Files
godot/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs
2020-04-03 01:38:48 +02:00

49 lines
1.2 KiB
C#

using Godot;
using GodotTools.Internals;
using static GodotTools.Internals.Globals;
namespace GodotTools
{
public class HotReloadAssemblyWatcher : Node
{
private Timer watchTimer;
public override void _Notification(int what)
{
if (what == Node.NotificationWmFocusIn)
{
RestartTimer();
if (Internal.IsAssembliesReloadingNeeded())
Internal.ReloadAssemblies(softReload: false);
}
}
private void TimerTimeout()
{
if (Internal.IsAssembliesReloadingNeeded())
Internal.ReloadAssemblies(softReload: false);
}
public void RestartTimer()
{
watchTimer.Stop();
watchTimer.Start();
}
public override void _Ready()
{
base._Ready();
watchTimer = new Timer
{
OneShot = false,
WaitTime = (float)EditorDef("mono/assembly_watch_interval_sec", 0.5)
};
watchTimer.Timeout += TimerTimeout;
AddChild(watchTimer);
watchTimer.Start();
}
}
}