浏览代码

color node now updates dependent nodes when the color is modified.

/main
Tim Cooper 8 年前
当前提交
8736b714
共有 6 个文件被更改,包括 53 次插入2 次删除
  1. 15
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/MaterialGraphDataSource.cs
  2. 16
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/MaterialNodeData.cs
  3. 2
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableNode.cs
  4. 3
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Interfaces/INode.cs
  5. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeDrawers/AbstractMaterialNodeUI.cs
  6. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/ColorNode.cs

15
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/MaterialGraphDataSource.cs


public IGraphAsset graphAsset { get; private set; }
void OnNodeChanged(INode inNode)
{
var dependentNodes = new List<INode>();
NodeUtils.CollectNodesNodeFeedsInto(dependentNodes, inNode);
foreach (var node in dependentNodes)
{
var theElements = m_Elements.OfType<MaterialNodeData>().ToList();
var found = theElements.Where(x => x.node.guid == node.guid).ToList();
foreach (var drawableNode in found)
drawableNode.MarkDirtyHack();
}
}
public MaterialGraphDataSource(IGraphAsset graphAsset)
{
this.graphAsset = graphAsset;

nodeData = ScriptableObject.CreateInstance<ColorNodeData>();
else
nodeData = ScriptableObject.CreateInstance<MaterialNodeData>();
node.onModified += OnNodeChanged;
nodeData.Initialize(node);
drawableNodes.Add(nodeData);

16
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Drawing/MaterialNodeData.cs


{
public override void OnGUIHandler()
{
EditorGUILayout.ColorField("test", Color.blue);
var cNode = node as UnityEngine.MaterialGraph.ColorNode;
if (cNode == null)
return;
cNode.color = EditorGUILayout.ColorField("Color", cNode.color);
}
}

protected override IEnumerable<GraphElementData> GetControlData()
{
var instance = CreateInstance<ColorNodeContolData>();
instance.Initialize(node);
return new List<GraphElementData> { instance };
}
}

protected MaterialNodeData()
{}
//TODO: Kill this and the function below after talking with shanti
[SerializeField]
private int m_SerializationRandom;
public void MarkDirtyHack()
{
m_SerializationRandom++;
}
public void Initialize(INode inNode)
{

2
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableNode.cs


public virtual void ValidateNode()
{}
public OnNodeModified onModified { get; set; }
public IEnumerable<T> GetInputSlots<T>() where T : ISlot
{

3
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Interfaces/INode.cs


namespace UnityEngine.Graphing
{
public delegate void OnNodeModified(INode node);
OnNodeModified onModified { get; set; }
IGraph owner { get; set; }
Guid guid { get; }
Guid RewriteGuid();

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeDrawers/AbstractMaterialNodeUI.cs


[Serializable]
public abstract class NodeControlData : GraphElementData
{
public INode node { get; private set; }
public void Initialize(INode inNode)
{
node = inNode;
}
public abstract void OnGUIHandler();
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/ColorNode.cs


public Color color
{
get { return m_Color; }
set { m_Color = value; }
set
{
if (m_Color == value)
return;
m_Color = value;
if (onModified != null)
{
onModified(this);
}
}
}
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode)

正在加载...
取消
保存