浏览代码

[shader graph]small tweaks and cleanup to the invalid state caching.

/main
Tim Cooper 9 年前
当前提交
450a5f11
共有 5 个文件被更改,包括 41 次插入47 次删除
  1. 14
      UnityProject/Assets/UnityShaderEditor/Editor/Source/BaseMaterialGraph.cs
  2. 5
      UnityProject/Assets/UnityShaderEditor/Editor/Source/MaterialSubGraph.cs
  3. 60
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/BaseMaterialNode.cs
  4. 1
      UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Function2Input.cs
  5. 8
      UnityProject/Assets/UnityShaderEditor/Editor/Source/PixelGraph.cs

14
UnityProject/Assets/UnityShaderEditor/Editor/Source/BaseMaterialGraph.cs


return;
RecacheActiveNodes();
UpdateNodeErrorState();
InvalidateAllNodes();
toNode.RegeneratePreviewShaders();
}

return newEdge;
RecacheActiveNodes();
UpdateNodeErrorState();
InvalidateAllNodes();
fromNode.CollectChildNodesByExecutionOrder().ToList().ForEach(s => s.UpdatePreviewProperties());
protected abstract void UpdateNodeErrorState();
protected virtual void InvalidateAllNodes()
{
var bmns = nodes.Where(x => x is BaseMaterialNode).Cast<BaseMaterialNode>().ToList();
foreach (var node in bmns)
node.InvalidateNode();
}
public override void AddNode(Node node)
{

5
UnityProject/Assets/UnityShaderEditor/Editor/Source/MaterialSubGraph.cs


{
}
protected override void UpdateNodeErrorState()
{
throw new System.NotImplementedException();
}
public new void OnEnable()
{
base.OnEnable();

60
UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/BaseMaterialNode.cs


{
get
{
UpdateConcreteSlotValueTypes();
BuildValidateNode();
if (m_Material == null)
{
m_Material = new Material(defaultPreviewShader) {hideFlags = HideFlags.DontSave};

}
[NonSerialized]
private bool m_ErrorsCalculated;
public bool errorsCalculated
private bool m_NodeInValidState;
public bool nodeInValidState
get { return m_ErrorsCalculated; }
set { m_ErrorsCalculated = value; }
get { return m_NodeInValidState; }
}
public void InvalidateNode()
{
m_NodeInValidState = false;
}
[NonSerialized]

get
{
if (!errorsCalculated)
UpdateConcreteSlotValueTypes();
if (!nodeInValidState)
BuildValidateNode();
return m_HasError;
}
}

get
{
if (!errorsCalculated)
UpdateConcreteSlotValueTypes();
if (!nodeInValidState)
BuildValidateNode();
return m_ConcreteInputSlotValueTypes;
}
}

get
{
if (!errorsCalculated)
UpdateConcreteSlotValueTypes();
if (!nodeInValidState)
BuildValidateNode();
return m_ConcreteOutputSlotValueTypes;
}
}

previewMaterial.shader.hideFlags = HideFlags.DontSave;
}
// this function looks at all the nodes that have a
// dependency on this node. They will then have their
// preview regenerated.
public void RegeneratePreviewShaders()
{
CollectDependentNodes()
.Where(x => x.hasPreview)
.All(s => s.UpdatePreviewMaterial());
}
private static Mesh[] s_Meshes = { null, null, null, null };
/// <summary>

}
}
// this function looks at all the nodes that have a
// dependency on this node. They will then have their
// preview regenerated.
public void RegeneratePreviewShaders()
{
var dependentNodesWithPreview = CollectDependentNodes().Where(x => x.hasPreview);
foreach (var dependentNode in dependentNodesWithPreview)
dependentNode.UpdatePreviewMaterial();
}
if (!hasPreview)
return;
if (!hasPreview)
return;
foreach (var prop in pList)
SetPreviewMaterialProperty (prop, previewMaterial);

return ConcreteSlotValueType.Error;
}
public void UpdateConcreteSlotValueTypes()
public void BuildValidateNode()
if (errorsCalculated)
if (nodeInValidState)
return;
// all children nodes needs to be updated first

{
var outputSlot = edge.fromSlot;
var outputNode = (BaseMaterialNode) outputSlot.node;
outputNode.UpdateConcreteSlotValueTypes();
outputNode.BuildValidateNode();
}
}

}
m_HasError = inputError || m_ConcreteOutputSlotValueTypes.Values.Any(x => x == ConcreteSlotValueType.Error);
errorsCalculated = true;
m_NodeInValidState = true;
}
public static string ConvertConcreteSlotValueTypeToString(ConcreteSlotValueType slotValue)

1
UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Function2Input.cs


using System.Linq;
using UnityEditor.Graphs;
using UnityEngine;

8
UnityProject/Assets/UnityShaderEditor/Editor/Source/PixelGraph.cs


return pixelMasterNode.previewMaterial;
}
protected override void UpdateNodeErrorState()
{
var bmns = nodes.Where(x => x is BaseMaterialNode).Cast<BaseMaterialNode>().ToList();
foreach (var node in bmns)
node.errorsCalculated = false;
}
}
}
正在加载...
取消
保存