浏览代码

misc fixes afer changes

/main
Tim Cooper 7 年前
当前提交
24923996
共有 9 个文件被更改,包括 80 次插入18 次删除
  1. 6
      MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableGraph.cs
  2. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
  3. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs
  4. 62
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialSlot.cs
  5. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
  6. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyNode.cs
  7. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/AbstractSubGraphNode.cs
  8. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/MasterRemapNode.cs
  9. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphNode.cs

6
MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Runtime/Implementation/SerializableGraph.cs


AddEdgeToNodeEdges(edge);
OnEnable();
ValidateGraph();
ValidateGraph();
}
public virtual void ValidateGraph()

//manually modifies serialized data
//of if they delete a node in the inspector
//debug view.
foreach (var edge in edges.ToArray())
//debug view.
foreach (var edge in edges.ToArray())
{
var outputNode = GetNodeFromGuid(edge.outputSlot.nodeGuid);
var inputNode = GetNodeFromGuid(edge.inputSlot.nodeGuid);

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs


using UnityEngine.Experimental.UIElements;
using UnityEngine.Graphing;
using UnityEngine.MaterialGraph;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
namespace UnityEditor.MaterialGraph.Drawing

6
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialGraph.cs


PreviewMode pmode;
return GetShader(masterNode as AbstractMaterialNode, mode, name, out configuredTextures, out pmode);
}
public override void OnAfterDeserialize()
{
base.OnAfterDeserialize();
}
}
}

62
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Graphs/MaterialSlot.cs


[SerializeField]
private float m_DefaultValue;
public Vector1MaterialSlot()
{
}
public Vector1MaterialSlot(
int slotId,
string displayName,

[SerializeField]
private Vector2 m_DefaultValue;
public Vector2MaterialSlot()
{
}
public Vector2MaterialSlot(
int slotId,

[SerializeField]
private Vector3 m_DefaultValue;
public Vector3MaterialSlot()
{
}
public Vector3MaterialSlot(
int slotId,

[SerializeField]
private Vector4 m_DefaultValue;
public Vector4MaterialSlot()
{
}
public Vector4MaterialSlot(
int slotId,

[Serializable]
public class Matrix2MaterialSlot : MaterialSlot
{
public Matrix2MaterialSlot()
{
}
public Matrix2MaterialSlot(
int slotId,
string displayName,

[Serializable]
public class Matrix3MaterialSlot : MaterialSlot
{
public Matrix3MaterialSlot()
{
}
public Matrix3MaterialSlot(
int slotId,
string displayName,

[Serializable]
public class Matrix4MaterialSlot : MaterialSlot
{
public Matrix4MaterialSlot()
{
}
public Matrix4MaterialSlot(
int slotId,
string displayName,

[Serializable]
public class Texture2DMaterialSlot : MaterialSlot
{
public Texture2DMaterialSlot()
{
}
public Texture2DMaterialSlot(
int slotId,
string displayName,

[Serializable]
public class SamplerStateMaterialSlot : MaterialSlot
{
public SamplerStateMaterialSlot()
{
}
public SamplerStateMaterialSlot(
int slotId,
string displayName,

private ConcreteSlotValueType m_ConcreteValueType = ConcreteSlotValueType.Vector4;
public DynamicVectorMaterialSlot()
{
}
public DynamicVectorMaterialSlot(
int slotId,
string displayName,

{
m_ConcreteValueType = valueType;
}
public override PreviewProperty GetPreviewProperty(string name)
{
var pp = new PreviewProperty
{
m_Name = name,
m_PropType = ConvertConcreteSlotValueTypeToPropertyType(concreteValueType),
m_Vector4 = new Vector4(value.x, value.y, value.z, value.w),
m_Float = value.x,
m_Color = new Vector4(value.x, value.x, value.z, value.w),
};
return pp;
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return precision + "4 (" + value.x + "," + value.y + "," + value.z + "," + value.w + ")";
}
}
[Serializable]

case SlotValueType.Dynamic:
return new DynamicVectorMaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
case SlotValueType.Vector4:
return new Vector3MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
return new Vector4MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
case SlotValueType.Vector3:
return new Vector3MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
case SlotValueType.Vector2:

4
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs


public override void ValidateNode()
{
var isInError = false;
var isInError = false;
// all children nodes needs to be updated first
// so do that here

var edges = owner.GetEdges(inputSlot.slotReference);
foreach (var edge in edges)
foreach (var edge in edges)
{
var fromSocketRef = edge.outputSlot;
var outputNode = owner.GetNodeFromGuid(fromSocketRef.nodeGuid);

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


namespace UnityEngine.MaterialGraph
{
[Title("Property Node")]
public class PropertyNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV
public class PropertyNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireMeshUV, IOnAssetEnabled
{
private Guid m_PropertyGuid;

}
}
public sealed override void UpdateNodeAfterDeserialization()
{
base.UpdateNodeAfterDeserialization();
}
public override string GetVariableNameForSlot(int slotId)
{
if (slotId != TOutputSlotId)

base.OnAfterDeserialize();
if (!string.IsNullOrEmpty(m_PropertyGuidSerialized))
m_PropertyGuid = new Guid(m_PropertyGuidSerialized);
}
public void OnEnable()
{
UpdateNode();
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/AbstractSubGraphNode.cs


{
public abstract class AbstractSubGraphNode : AbstractMaterialNode
, IGeneratesFunction
, IOnAssetEnabled
, IMayRequireNormal
, IMayRequireTangent
, IMayRequireBitangent

get { return null; }
}
public virtual void OnEnable()
public virtual void UpdateSlots()
{
var validNames = new List<int>();
if (referencedGraph == null)

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/MasterRemapNode.cs


var helper = new RemapGraphHelper();
helper.remapGraph = value;
m_SerializedRemapGraph = EditorJsonUtility.ToJson(helper, true);
OnEnable();
UpdateSlots();
if (onModified != null)
onModified(this, ModificationScope.Topological);

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphNode.cs


var helper = new SubGraphHelper();
helper.subGraph = value;
m_SerializedSubGraph = EditorJsonUtility.ToJson(helper, true);
OnEnable();
UpdateSlots();
if (onModified != null)
onModified(this, ModificationScope.Topological);

正在加载...
取消
保存