Clear VisjectSurface node caches and context menus during scripts reload
This commit is contained in:
@@ -161,6 +161,8 @@ namespace FlaxEditor.Surface
|
|||||||
|
|
||||||
private void OnScriptsReloadBegin()
|
private void OnScriptsReloadBegin()
|
||||||
{
|
{
|
||||||
|
_nodesCache.Clear();
|
||||||
|
|
||||||
// Check if any of the nodes comes from the game scripts - those can be reloaded at runtime so prevent crashes
|
// Check if any of the nodes comes from the game scripts - those can be reloaded at runtime so prevent crashes
|
||||||
bool hasTypeFromGameScripts = Editor.Instance.CodeEditing.AnimGraphNodes.HasTypeFromGameScripts;
|
bool hasTypeFromGameScripts = Editor.Instance.CodeEditing.AnimGraphNodes.HasTypeFromGameScripts;
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace FlaxEditor.Surface
|
|||||||
public BehaviorTreeSurface(IVisjectSurfaceOwner owner, Action onSave, FlaxEditor.Undo undo)
|
public BehaviorTreeSurface(IVisjectSurfaceOwner owner, Action onSave, FlaxEditor.Undo undo)
|
||||||
: base(owner, onSave, undo, CreateStyle())
|
: base(owner, onSave, undo, CreateStyle())
|
||||||
{
|
{
|
||||||
|
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SurfaceStyle CreateStyle()
|
private static SurfaceStyle CreateStyle()
|
||||||
@@ -35,6 +36,11 @@ namespace FlaxEditor.Surface
|
|||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnScriptsReloadBegin()
|
||||||
|
{
|
||||||
|
_nodesCache.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
private static void DrawBox(Box box)
|
private static void DrawBox(Box box)
|
||||||
{
|
{
|
||||||
var rect = new Rectangle(Float2.Zero, box.Size);
|
var rect = new Rectangle(Float2.Zero, box.Size);
|
||||||
@@ -186,6 +192,7 @@ namespace FlaxEditor.Surface
|
|||||||
{
|
{
|
||||||
if (IsDisposing)
|
if (IsDisposing)
|
||||||
return;
|
return;
|
||||||
|
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
|
||||||
_nodesCache.Wait();
|
_nodesCache.Wait();
|
||||||
|
|
||||||
base.OnDestroy();
|
base.OnDestroy();
|
||||||
|
|||||||
@@ -415,6 +415,15 @@ namespace FlaxEditor.Surface
|
|||||||
// Init drag handlers
|
// Init drag handlers
|
||||||
DragHandlers.Add(_dragAssets = new DragAssets<DragDropEventArgs>(ValidateDragItem));
|
DragHandlers.Add(_dragAssets = new DragAssets<DragDropEventArgs>(ValidateDragItem));
|
||||||
DragHandlers.Add(_dragParameters = new DragNames<DragDropEventArgs>(SurfaceParameter.DragPrefix, ValidateDragParameter));
|
DragHandlers.Add(_dragParameters = new DragNames<DragDropEventArgs>(SurfaceParameter.DragPrefix, ValidateDragParameter));
|
||||||
|
|
||||||
|
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnScriptsReloadBegin()
|
||||||
|
{
|
||||||
|
_activeVisjectCM = null;
|
||||||
|
_cmPrimaryMenu?.Dispose();
|
||||||
|
_cmPrimaryMenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1023,6 +1032,8 @@ namespace FlaxEditor.Surface
|
|||||||
_activeVisjectCM = null;
|
_activeVisjectCM = null;
|
||||||
_cmPrimaryMenu?.Dispose();
|
_cmPrimaryMenu?.Dispose();
|
||||||
|
|
||||||
|
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
|
||||||
|
|
||||||
base.OnDestroy();
|
base.OnDestroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ namespace FlaxEditor.Surface
|
|||||||
{
|
{
|
||||||
_supportsImplicitCastFromObjectToBoolean = true;
|
_supportsImplicitCastFromObjectToBoolean = true;
|
||||||
DragHandlers.Add(_dragActors = new DragActors(ValidateDragActor));
|
DragHandlers.Add(_dragActors = new DragActors(ValidateDragActor));
|
||||||
|
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnScriptsReloadBegin()
|
||||||
|
{
|
||||||
|
_nodesCache.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ValidateDragActor(ActorNode actor)
|
private bool ValidateDragActor(ActorNode actor)
|
||||||
@@ -631,6 +637,7 @@ namespace FlaxEditor.Surface
|
|||||||
{
|
{
|
||||||
if (IsDisposing)
|
if (IsDisposing)
|
||||||
return;
|
return;
|
||||||
|
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
|
||||||
_nodesCache.Wait();
|
_nodesCache.Wait();
|
||||||
|
|
||||||
base.OnDestroy();
|
base.OnDestroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user