浏览代码

[FIX] #88 Added a forcedRedrawPreviews flag that will redraw the graph and update the nodes to reflect changes properly when an external source has been re-imported.

/main
Martin Thorzen 7 年前
当前提交
450a5759
共有 2 个文件被更改,包括 23 次插入1 次删除
  1. 14
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  2. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs

14
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs


[NonSerialized]
bool m_HasError;
[NonSerialized]
public bool forceRedrawPreviews = false;
GraphEditorView m_GraphEditorView;
GraphEditorView graphEditorView

m_GraphEditorView.RemoveFromHierarchy();
m_GraphEditorView.Dispose();
}
m_GraphEditorView = value;
if (m_GraphEditorView != null)
{

graphEditorView = new GraphEditorView(this, materialGraph, asset.name) { persistenceKey = selectedGuid };
}
if (forceRedrawPreviews)
{
// Redraw all previews
foreach (INode node in m_GraphObject.graph.GetNodes<INode>())
node.Dirty(ModificationScope.Node);
forceRedrawPreviews = false;
}
graphEditorView.HandleGraphChanges();
graphObject.graph.ClearChanges();
}

Undo.ClearUndo(graphObject);
DestroyImmediate(graphObject);
}
graphEditorView = null;
}

var inputSlotRef = new SlotReference(remappedInputNodeGuid, inputSlot.slotId);
subGraph.Connect(outputSlotRef, inputSlotRef);
}
// one edge needs to go to outside world
else if (outputSlotExistsInSubgraph)
{

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs


using System.Text;
using UnityEditor;
using UnityEditor.Experimental.AssetImporters;
using UnityEditor.Experimental.UIElements;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing;
[ScriptedImporter(1, ShaderGraphImporter.ShaderGraphExtension)]
public class ShaderGraphImporter : ScriptedImporter

static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
MaterialGraphEditWindow[] windows = Resources.FindObjectsOfTypeAll<MaterialGraphEditWindow>();
foreach (var matGraphEditWindow in windows)
{
matGraphEditWindow.forceRedrawPreviews = true;
}
}
}
正在加载...
取消
保存