Reload on resource external change

This commit is contained in:
Rendo 2025-07-17 21:11:10 +05:00
commit 5680ecc17e
2 changed files with 25 additions and 3 deletions

View file

@ -13,6 +13,11 @@ public partial class AdventureEditor : MarginContainer
[Signal]
public delegate void HardReloadRequestedEventHandler();
public override void _Ready()
{
EditorInterface.Singleton.GetInspector().PropertyEdited += OnInspectorPropertyChanged;
}
public void Reload()
{
EmitSignal(SignalName.ReloadRequested);
@ -33,5 +38,12 @@ public partial class AdventureEditor : MarginContainer
}
ResourceSaver.Save(editedResource, editedPath);
}
public void OnInspectorPropertyChanged(string property)
{
if (EditorInterface.Singleton.GetInspector().GetEditedObject() is AdventureLevelResource resource)
{
editedPath = resource.ResourcePath;
HardReload();
}
}
}