Browse Source

Force FlowchartWindow and BlockInspector to be refreshed when moving between and playmodes in editor

-and restore selected blocks from edit, to play, back to edit
master
desktop-maesty/steve 5 years ago
parent
commit
89381e1a91
  1. 13
      Assets/Fungus/Scripts/Components/Flowchart.cs
  2. 6
      Assets/Fungus/Scripts/Editor/BlockInspector.cs
  3. 21
      Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

13
Assets/Fungus/Scripts/Components/Flowchart.cs

@ -1186,7 +1186,18 @@ namespace Fungus
var res = gameObject.GetComponents<Block>();
selectedBlocks = res.Where(x => x.IsSelected).ToList();
}
public void ReverseUpdateSelectedCache()
{
for (int i = 0; i < selectedBlocks.Count; i++)
{
if(selectedBlocks[i] != null)
{
selectedBlocks[i].IsSelected = true;
}
}
}
/// <summary>
/// Reset the commands and variables in the Flowchart.
/// </summary>

6
Assets/Fungus/Scripts/Editor/BlockInspector.cs

@ -93,6 +93,12 @@ namespace Fungus.EditorUtils
return;
}
//if there is no selection but we are drawing, fix that
if (flowchart.SelectedBlocks.Count == 0)
{
flowchart.AddSelectedBlock(block);
}
if (activeBlockEditor == null ||
!block.Equals(activeBlockEditor.target))
{

21
Assets/Fungus/Scripts/Editor/FlowchartWindow.cs

@ -264,13 +264,30 @@ namespace Fungus.EditorUtils
EditorApplication.update += OnEditorUpdate;
Undo.undoRedoPerformed += Undo_ForceRepaint;
#if UNITY_2017_4_OR_NEWER
EditorApplication.playModeStateChanged += EditorApplication_playModeStateChanged;
#endif
}
protected virtual void OnDisable()
{
EditorApplication.update -= OnEditorUpdate;
Undo.undoRedoPerformed -= Undo_ForceRepaint;
#if UNITY_2017_4_OR_NEWER
EditorApplication.playModeStateChanged -= EditorApplication_playModeStateChanged;
#endif
}
#if UNITY_2017_4_OR_NEWER
private void EditorApplication_playModeStateChanged(PlayModeStateChange obj)
{
//force null so it can refresh context on the other side of the context
flowchart = null;
prevFlowchart = null;
blockInspector = null;
}
#endif
protected void Undo_ForceRepaint()
{
@ -664,6 +681,10 @@ namespace Fungus.EditorUtils
}
UpdateBlockCollection();
if(flowchart != null)
flowchart.ReverseUpdateSelectedCache();//becomes reverse restore selected cache
Repaint();
return true;
}

Loading…
Cancel
Save