浏览代码

Addded cache for subgraph. Before it was deserializing on every frame.

/main
Martin Thorzen 7 年前
当前提交
7c397424
共有 1 个文件被更改,包括 13 次插入4 次删除
  1. 17
      com.unity.shadergraph/Editor/Data/Nodes/Utility/SubGraphNode.cs

17
com.unity.shadergraph/Editor/Data/Nodes/Utility/SubGraphNode.cs


[SerializeField]
private string m_SerializedSubGraph = string.Empty;
[NonSerialized]
MaterialSubGraphAsset m_SubGraph;
[Serializable]
private class SubGraphHelper
{

if (string.IsNullOrEmpty(m_SerializedSubGraph))
return null;
var helper = new SubGraphHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedSubGraph, helper);
return helper.subGraph;
if (m_SubGraph == null)
{
var helper = new SubGraphHelper();
EditorJsonUtility.FromJsonOverwrite(m_SerializedSubGraph, helper);
m_SubGraph = helper.subGraph;
}
return m_SubGraph;
}
set
{

var helper = new SubGraphHelper();
helper.subGraph = value;
m_SerializedSubGraph = EditorJsonUtility.ToJson(helper, true);
m_SubGraph = null;
UpdateSlots();
Dirty(ModificationScope.Topological);

var validNames = new List<int>();
if (referencedGraph == null)
{
RemoveSlotsNameNotMatching(validNames);
RemoveSlotsNameNotMatching(validNames, true);
return;
}

正在加载...
取消
保存