浏览代码
Merge branch 'exposed-prop-subgraph'
Merge branch 'exposed-prop-subgraph'
# Conflicts: # MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs # MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs # MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphIONode.cs # MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphIONode.cs.meta # MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs # MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs # MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs # MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs # MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SubGraph/SubGraphOutputNode.cs/main
Tim Cooper
7 年前
当前提交
a5c9b0ce
共有 101 个文件被更改,包括 3223 次插入 和 881 次删除
-
6MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableGraph.cs
-
5MaterialGraphProject/Assets/GraphFramework/SerializableGraph/Editor/Implementation/SerializableSlot.cs
-
2MaterialGraphProject/Assets/NewNodes/Editor/Keep/ConstantsNode.cs
-
12MaterialGraphProject/Assets/NewNodes/Editor/Keep/GradientNode.cs
-
4MaterialGraphProject/Assets/NewNodes/Editor/Keep/ParallaxNode.cs
-
2MaterialGraphProject/Assets/NewNodes/Editor/Keep/SamplerStateNode.cs
-
16MaterialGraphProject/Assets/NewNodes/Editor/Keep/TextureSamplerNode.cs
-
4MaterialGraphProject/Assets/NewNodes/Editor/Keep/TransformNode.cs
-
10MaterialGraphProject/Assets/NewNodes/Editor/Kill/MultiLayerParallaxNode.cs
-
12MaterialGraphProject/Assets/NewNodes/Editor/Kill/VertexNormalNode.cs
-
146MaterialGraphProject/Assets/PartyPreview.ShaderGraph
-
2MaterialGraphProject/Assets/PartyPreview.ShaderGraph.meta
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateShaderGraph.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs.meta
-
239MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractShaderProperty.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialGraph.cs
-
655MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialSlot.cs
-
20MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Interfaces/MaterialGraphChange.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightMetallicMasterNode.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightSpecularMasterNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightweightUnlitMasterNode.cs
-
163MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/AbstractMaterialNode.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Channel/SplitNode.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/HLSLNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/ColorNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/BitangentNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/NormalNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/PositionNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/UVNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/VertexColorNode.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/ViewDirectionNode.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpacePositionNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Geometry/WorldSpaceTangentNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix4Node.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/MatrixCommonNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/CameraDirNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/CameraPosNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/SceneData/ScreenPosNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/SinTimeNode.cs
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Time/TimeNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector1Node.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector2Node.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector3Node.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Vector/Vector4Node.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Matrix/MatrixMultiplyByVectorNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Matrix/MatrixMultiplyNode.cs
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyNode.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/SlotValue.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/VertexInterpolatorNode.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph.meta
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/AbstractSubGraphNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/MasterRemapNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphNode.cs
-
47MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphOutputNode.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/SubGraphOutputNode.cs.meta
-
18MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs
-
68MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
-
56MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/IMGUISlotEditorView.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/BasicNodeInspector.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/NodeInspectors/SubgraphOutputNodeInspector.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/MasterRemapGraphImporterEditor.cs
-
39MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
-
15MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderSubGraphImporterEditor.cs
-
14MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/DynamicSlotTests.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/FixedSlotTests.cs
-
15MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialNodeTests.cs
-
90MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/MaterialSlotTests.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/ShaderGeneratorTests.cs
-
24MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateLayeredShaderGraph.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/AssetCallbacks/CreateLayeredShaderGraph.cs.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IShaderGraph.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IShaderGraph.cs.meta
-
37MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableGuid.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableGuid.cs.meta
-
115MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs.orig
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs.orig.meta
-
126MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs.orig
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs.orig.meta
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayerWeightsOutputNode.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayerWeightsOutputNode.cs.meta
-
361MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayeredShaderGraph.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/SubGraph/LayeredShaderGraph.cs.meta
-
470MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs.orig
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/AbstractMaterialGraphEditWindow.cs.orig.meta
-
260MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs.orig
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs.orig.meta
-
46MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderLayerview.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderLayerview.cs.meta
-
395MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs.orig
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs.orig.meta
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes.meta
-
8MaterialGraphProject/Assets/UnityShaderEditor/Runtime.meta
-
42MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Nodes/SubgraphIONodePresenter.cs.meta
-
153MaterialGraphProject/Assets/fresnelstuff.ShaderSubGraph
146
MaterialGraphProject/Assets/PartyPreview.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 706886b5adec4e3409ceb9a30e04440e |
|||
guid: f329b5b280b7f6f449659f05937ac2f2 |
|||
timeCreated: 1465559218 |
|||
licenseType: Pro |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7e981d45b83422d4aa5407e9fe5c7ab5 |
|||
guid: 605eb5c5a280c014fa0952cd022f2579 |
|||
timeCreated: 1465559218 |
|||
licenseType: Pro |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.IO; |
|||
using UnityEditor.ProjectWindowCallback; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph |
|||
{ |
|||
public class CreateLayeredShaderGraph : EndNameEditAction |
|||
{ |
|||
[MenuItem("Assets/Create/Layered Shader Graph", false, 208)] |
|||
public static void CreateLayeredGraph() |
|||
{ |
|||
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreateLayeredShaderGraph>(), |
|||
"New Layerd Shader Graph.LayeredShaderGraph", null, null); |
|||
} |
|||
|
|||
public override void Action(int instanceId, string pathName, string resourceFile) |
|||
{ |
|||
var graph = new LayeredShaderGraph(); |
|||
graph.AddNode(new LayerWeightsOutputNode()); |
|||
File.WriteAllText(pathName, EditorJsonUtility.ToJson(graph)); |
|||
AssetDatabase.Refresh(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0c11588a25854ed5bd03171503c84789 |
|||
timeCreated: 1507403047 |
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public interface IShaderGraph |
|||
{ |
|||
string GetShader(string name, GenerationMode mode, out List<PropertyCollector.TextureInfo> configuredTextures); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ad9b7f8f562a4ee59873c8c222874ce7 |
|||
timeCreated: 1507398800 |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class SerializableGuid : ISerializationCallbackReceiver |
|||
{ |
|||
public SerializableGuid() |
|||
{ |
|||
m_Guid = Guid.NewGuid(); |
|||
} |
|||
|
|||
[NonSerialized] |
|||
private Guid m_Guid; |
|||
|
|||
[SerializeField] |
|||
private string m_GuidSerialized; |
|||
|
|||
public Guid guid |
|||
{ |
|||
get { return m_Guid; } |
|||
} |
|||
|
|||
public virtual void OnBeforeSerialize() |
|||
{ |
|||
m_GuidSerialized = m_Guid.ToString(); |
|||
} |
|||
|
|||
public virtual void OnAfterDeserialize() |
|||
{ |
|||
if (!string.IsNullOrEmpty(m_GuidSerialized)) |
|||
m_Guid = new Guid(m_GuidSerialized); |
|||
else |
|||
m_Guid = Guid.NewGuid(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fb9a23efd2bc46e9a5e34bf5ff0c9768 |
|||
timeCreated: 1507479217 |
|
|||
using UnityEditor.MaterialGraph.Drawing.Controls; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Matrix/Matrix 2")] |
|||
public class Matrix2Node : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
const int kOutputSlotId = 0; |
|||
const string kOutputSlotName = "Value"; |
|||
|
|||
[SerializeField] |
|||
Vector2 m_Row0; |
|||
|
|||
[SerializeField] |
|||
Vector2 m_Row1; |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector2 row0 |
|||
{ |
|||
get { return m_Row0; } |
|||
set { SetRow(ref m_Row0, value); } |
|||
} |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector2 row1 |
|||
{ |
|||
get { return m_Row1; } |
|||
set { SetRow(ref m_Row1, value); } |
|||
} |
|||
|
|||
void SetRow(ref Vector2 row, Vector2 value) |
|||
{ |
|||
if (value == row) |
|||
return; |
|||
row = value; |
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
|
|||
public Matrix2Node() |
|||
{ |
|||
name = "Matrix2"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Matrix2MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public string propertyName |
|||
{ |
|||
get |
|||
{ |
|||
return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode()); |
|||
} |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return propertyName; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview()) |
|||
// return; |
|||
|
|||
visitor.AddShaderChunk(precision + "2 " + name + " = " + precision + "2x2 (" + m_Row0.x + ", " + m_Row0.y + ", " + m_Row1.x + ", " + m_Row1.y + ");", true); |
|||
} |
|||
|
|||
[SerializeField] |
|||
string m_Description = string.Empty; |
|||
|
|||
public string description |
|||
{ |
|||
get |
|||
{ |
|||
return string.IsNullOrEmpty(m_Description) ? name : m_Description; |
|||
} |
|||
set { m_Description = value; } |
|||
} |
|||
|
|||
// TODO - Remove Property entries everywhere? |
|||
// Matrix cant be a shader property |
|||
/*public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Matrix2; } |
|||
}*/ |
|||
|
|||
/*public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed) |
|||
visitor.AddShaderProperty(new VectorPropertyChunk(propertyName, description, m_Value, PropertyChunk.HideState.Visible)); |
|||
}*/ |
|||
|
|||
/*public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed || generationMode.IsPreview()) |
|||
visitor.AddShaderChunk(precision + "2 " + propertyName + ";", true); |
|||
}*/ |
|||
|
|||
/*public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Vector2, |
|||
m_Vector2 = m_Value |
|||
}; |
|||
}*/ |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 060d1826a682e4d4e9c45b4b4c93cb51 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEditor.MaterialGraph.Drawing.Controls; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Matrix/Matrix 3")] |
|||
public class Matrix3Node : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
const int kOutputSlotId = 0; |
|||
const string kOutputSlotName = "Value"; |
|||
|
|||
[SerializeField] |
|||
Vector3 m_Row0; |
|||
|
|||
[SerializeField] |
|||
Vector3 m_Row1; |
|||
|
|||
[SerializeField] |
|||
Vector3 m_Row2; |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector3 row0 |
|||
{ |
|||
get { return m_Row0; } |
|||
set { SetRow(ref m_Row0, value); } |
|||
} |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector3 row1 |
|||
{ |
|||
get { return m_Row1; } |
|||
set { SetRow(ref m_Row1, value); } |
|||
} |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector3 row2 |
|||
{ |
|||
get { return m_Row2; } |
|||
set { SetRow(ref m_Row2, value); } |
|||
} |
|||
|
|||
void SetRow(ref Vector3 row, Vector3 value) |
|||
{ |
|||
if (value == row) |
|||
return; |
|||
row = value; |
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
|
|||
public Matrix3Node() |
|||
{ |
|||
name = "Matrix3"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
<<<<<<< HEAD:MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix3, Vector3.zero)); |
|||
======= |
|||
AddSlot(new Matrix3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output)); |
|||
>>>>>>> exposed-prop-subgraph:MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public string propertyName |
|||
{ |
|||
get { return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode()); } |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return propertyName; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview()) |
|||
// return; |
|||
|
|||
visitor.AddShaderChunk(precision + "3x3 " + propertyName + " = " + precision + "3x3 (" + m_Row0.x + ", " + m_Row0.y + ", " + m_Row0.z + ", " + m_Row1.x + ", " + m_Row1.y + ", " + m_Row1.z + ", " + m_Row2.x + ", " + m_Row2.y + ", " + m_Row2.z + ");", true); |
|||
} |
|||
|
|||
[SerializeField] |
|||
string m_Description = string.Empty; |
|||
|
|||
public string description |
|||
{ |
|||
get |
|||
{ |
|||
return string.IsNullOrEmpty(m_Description) ? name : m_Description; |
|||
} |
|||
set { m_Description = value; } |
|||
} |
|||
|
|||
// TODO - Remove Property entries everywhere? |
|||
// Matrix cant be a shader property |
|||
/*public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Matrix2; } |
|||
}*/ |
|||
|
|||
/*public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed) |
|||
visitor.AddShaderProperty(new VectorPropertyChunk(propertyName, description, m_Value, PropertyChunk.HideState.Visible)); |
|||
}*/ |
|||
|
|||
/*public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed || generationMode.IsPreview()) |
|||
visitor.AddShaderChunk(precision + "2 " + propertyName + ";", true); |
|||
}*/ |
|||
|
|||
/*public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Vector2, |
|||
m_Vector3 = m_Value |
|||
}; |
|||
}*/ |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c8c352d3b6e0d8548ae31d044b0266a8 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class LayerWeightsOutputNode : AbstractMaterialNode, IOnAssetEnabled |
|||
{ |
|||
public LayerWeightsOutputNode() |
|||
{ |
|||
name = "LayerWeights"; |
|||
} |
|||
|
|||
public override bool allowedInRemapGraph { get { return false; } } |
|||
public override bool allowedInSubGraph { get { return false; } } |
|||
|
|||
public void OnEnable() |
|||
{ |
|||
var layeredGraph = owner as LayeredShaderGraph; |
|||
if (layeredGraph == null) |
|||
return; |
|||
|
|||
var goodSlots = new List<int>(); |
|||
foreach (var layer in layeredGraph.layers) |
|||
{ |
|||
AddSlot(new Vector1MaterialSlot(layer.guid.GetHashCode(), LayeredShaderGraph.LayerToFunctionName(layer.guid), LayeredShaderGraph.LayerToFunctionName(layer.guid), SlotType.Input,0)); |
|||
goodSlots.Add(layer.guid.GetHashCode()); |
|||
} |
|||
|
|||
RemoveSlotsNameNotMatching(goodSlots); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 789274d827ef4cb2a635638cb2a24718 |
|||
timeCreated: 1507401785 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using UnityEditor; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
public class LayeredShaderGraph : AbstractMaterialGraph, IShaderGraph |
|||
{ |
|||
[Serializable] |
|||
public class Layer |
|||
{ |
|||
[SerializeField] |
|||
private SerializableGuid m_Guid = new SerializableGuid(); |
|||
|
|||
[SerializeField] |
|||
private Shader m_Shader; |
|||
|
|||
public Layer() |
|||
{} |
|||
|
|||
public Guid guid |
|||
{ |
|||
get { return m_Guid.guid; } |
|||
} |
|||
|
|||
public Shader shader |
|||
{ |
|||
get { return m_Shader; } |
|||
set { m_Shader = value; } |
|||
} |
|||
} |
|||
|
|||
[NonSerialized] |
|||
private List<Layer> m_Layers = new List<Layer>(); |
|||
|
|||
[SerializeField] |
|||
List<SerializationHelper.JSONSerializedElement> m_SerializedLayers = new List<SerializationHelper.JSONSerializedElement>(); |
|||
|
|||
public IEnumerable<Layer> layers |
|||
{ |
|||
get { return m_Layers; } |
|||
} |
|||
|
|||
[NonSerialized] |
|||
private LayerWeightsOutputNode m_OutputNode; |
|||
|
|||
public LayerWeightsOutputNode outputNode |
|||
{ |
|||
get |
|||
{ |
|||
// find existing node
|
|||
if (m_OutputNode == null) |
|||
m_OutputNode = GetNodes<LayerWeightsOutputNode>().FirstOrDefault(); |
|||
|
|||
return m_OutputNode; |
|||
} |
|||
} |
|||
|
|||
public override void AddNode(INode node) |
|||
{ |
|||
if (outputNode != null && node is LayerWeightsOutputNode) |
|||
{ |
|||
Debug.LogWarning("Attempting to add second LayerWeightsOutputNode to LayeredShaderGraph. This is not allowed."); |
|||
return; |
|||
} |
|||
|
|||
base.AddNode(node); |
|||
} |
|||
|
|||
public void AddLayer() |
|||
{ |
|||
var layer = new Layer(); |
|||
m_Layers.Add(layer); |
|||
NotifyChange(new LayerAdded(layer)); |
|||
|
|||
if (outputNode != null) |
|||
outputNode.onModified(outputNode, ModificationScope.Graph); |
|||
} |
|||
|
|||
public bool SetLayer(Guid layerId, Shader newShader) |
|||
{ |
|||
try |
|||
{ |
|||
var path = AssetDatabase.GetAssetPath(newShader); |
|||
|
|||
if (!path.EndsWith("shaderGraph", StringComparison.InvariantCultureIgnoreCase)) |
|||
return false; |
|||
|
|||
var name = Path.GetFileNameWithoutExtension(path); |
|||
var textGraph = File.ReadAllText(path, Encoding.UTF8); |
|||
var graph = JsonUtility.FromJson<MaterialGraph>(textGraph); |
|||
if (graph == null) |
|||
return false; |
|||
|
|||
var layer = layers.FirstOrDefault(x => x.guid == layerId); |
|||
if (layer == null) |
|||
return false; |
|||
|
|||
layer.shader = newShader; |
|||
|
|||
if (outputNode != null) |
|||
{ |
|||
outputNode.OnEnable(); |
|||
outputNode.onModified(outputNode, ModificationScope.Graph); |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
// ignored
|
|||
} |
|||
return false; |
|||
} |
|||
|
|||
public void RemoveLayer(Guid id) |
|||
{ |
|||
var num = m_Layers.RemoveAll(x => x.guid == id); |
|||
|
|||
if (num > 0) |
|||
{ |
|||
NotifyChange(new LayerRemoved(id)); |
|||
|
|||
if (outputNode != null) |
|||
outputNode.onModified(outputNode, ModificationScope.Graph); |
|||
} |
|||
|
|||
} |
|||
|
|||
public override void OnBeforeSerialize() |
|||
{ |
|||
base.OnBeforeSerialize(); |
|||
m_SerializedLayers = SerializationHelper.Serialize<Layer>(m_Layers); |
|||
} |
|||
|
|||
public override void OnAfterDeserialize() |
|||
{ |
|||
m_OutputNode = null; |
|||
m_Layers = SerializationHelper.Deserialize<Layer>(m_SerializedLayers, null); |
|||
m_SerializedLayers = null; |
|||
base.OnAfterDeserialize(); |
|||
} |
|||
|
|||
public static string LayerToFunctionName(Guid id) |
|||
{ |
|||
return string.Format("Layer_{0}", GuidEncoder.Encode(id)); |
|||
} |
|||
|
|||
public string GetShader(string name, GenerationMode mode, out List<PropertyCollector.TextureInfo> configuredTextures) |
|||
{ |
|||
if (outputNode == null) |
|||
throw new InvalidOperationException(); |
|||
|
|||
var layerMap = new Dictionary<Guid, MaterialGraph>(); |
|||
|
|||
foreach (var layer in layers) |
|||
{ |
|||
var path = AssetDatabase.GetAssetPath(layer.shader); |
|||
|
|||
if (!path.EndsWith("shaderGraph", StringComparison.InvariantCultureIgnoreCase)) |
|||
continue; |
|||
|
|||
var textGraph = File.ReadAllText(path, Encoding.UTF8); |
|||
var graph = JsonUtility.FromJson<MaterialGraph>(textGraph); |
|||
if (graph == null) |
|||
continue; |
|||
|
|||
layerMap[layer.guid] = graph; |
|||
} |
|||
|
|||
if (layerMap.Count == 0) |
|||
{ |
|||
configuredTextures = new List<PropertyCollector.TextureInfo>(); |
|||
return string.Empty; |
|||
} |
|||
|
|||
var vertexShader = new ShaderGenerator(); |
|||
var layerShaders = new ShaderGenerator(); |
|||
var surfaceDescriptionFunction = new ShaderGenerator(); |
|||
var surfaceDescriptionStruct = new ShaderGenerator(); |
|||
var shaderFunctionVisitor = new ShaderGenerator(); |
|||
var surfaceInputs = new ShaderGenerator(); |
|||
|
|||
var graphVertexInput = @"
|
|||
struct GraphVertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float3 normal : NORMAL; |
|||
float4 tangent : TANGENT; |
|||
float4 texcoord0 : TEXCOORD0; |
|||
float4 lightmapUV : TEXCOORD1; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
};";
|
|||
|
|||
surfaceInputs.AddShaderChunk("struct SurfaceInputs{", false); |
|||
surfaceInputs.Indent(); |
|||
|
|||
var requirements = ShaderGraphRequirements.none; |
|||
foreach (var layer in layerMap) |
|||
requirements = requirements.Union(GetRequierments(layer.Value.masterNode as AbstractMaterialNode)); |
|||
|
|||
requirements = requirements.Union(GetRequierments(outputNode)); |
|||
|
|||
GenerateSpaceTranslationSurfaceInputs(requirements.requiresNormal, surfaceInputs, |
|||
ShaderGeneratorNames.ObjectSpaceNormal, ShaderGeneratorNames.ViewSpaceNormal, |
|||
ShaderGeneratorNames.WorldSpaceNormal, ShaderGeneratorNames.TangentSpaceNormal); |
|||
|
|||
GenerateSpaceTranslationSurfaceInputs(requirements.requiresTangent, surfaceInputs, |
|||
ShaderGeneratorNames.ObjectSpaceTangent, ShaderGeneratorNames.ViewSpaceTangent, |
|||
ShaderGeneratorNames.WorldSpaceTangent, ShaderGeneratorNames.TangentSpaceTangent); |
|||
|
|||
GenerateSpaceTranslationSurfaceInputs(requirements.requiresBitangent, surfaceInputs, |
|||
ShaderGeneratorNames.ObjectSpaceBiTangent, ShaderGeneratorNames.ViewSpaceBiTangent, |
|||
ShaderGeneratorNames.WorldSpaceBiTangent, ShaderGeneratorNames.TangentSpaceBiTangent); |
|||
|
|||
GenerateSpaceTranslationSurfaceInputs(requirements.requiresViewDir, surfaceInputs, |
|||
ShaderGeneratorNames.ObjectSpaceViewDirection, ShaderGeneratorNames.ViewSpaceViewDirection, |
|||
ShaderGeneratorNames.WorldSpaceViewDirection, ShaderGeneratorNames.TangentSpaceViewDirection); |
|||
|
|||
GenerateSpaceTranslationSurfaceInputs(requirements.requiresPosition, surfaceInputs, |
|||
ShaderGeneratorNames.ObjectSpacePosition, ShaderGeneratorNames.ViewSpacePosition, |
|||
ShaderGeneratorNames.WorldSpacePosition, ShaderGeneratorNames.TangentSpacePosition); |
|||
|
|||
if (requirements.requiresVertexColor) |
|||
surfaceInputs.AddShaderChunk(string.Format("float4 {0};", ShaderGeneratorNames.VertexColor), false); |
|||
|
|||
if (requirements.requiresScreenPosition) |
|||
surfaceInputs.AddShaderChunk(string.Format("float4 {0};", ShaderGeneratorNames.ScreenPosition), false); |
|||
|
|||
|
|||
foreach (var channel in requirements.requiresMeshUVs.Distinct()) |
|||
surfaceInputs.AddShaderChunk(string.Format("half4 {0};", channel.GetUVName()), false); |
|||
|
|||
surfaceInputs.Deindent(); |
|||
surfaceInputs.AddShaderChunk("};", false); |
|||
|
|||
vertexShader.AddShaderChunk("GraphVertexInput PopulateVertexData(GraphVertexInput v){", false); |
|||
vertexShader.Indent(); |
|||
vertexShader.AddShaderChunk("return v;", false); |
|||
vertexShader.Deindent(); |
|||
vertexShader.AddShaderChunk("}", false); |
|||
|
|||
var shaderProperties = new PropertyCollector(); |
|||
|
|||
var baseGraph = layerMap.Values.FirstOrDefault(); |
|||
if (baseGraph == null) |
|||
{ |
|||
configuredTextures = new List<PropertyCollector.TextureInfo>(); |
|||
return string.Empty; |
|||
} |
|||
|
|||
var masterNode = baseGraph.masterNode; |
|||
GenerateSurfaceDescriptionStruct(surfaceDescriptionStruct, masterNode as AbstractMaterialNode, true); |
|||
|
|||
foreach (var layer in layerMap) |
|||
{ |
|||
GenerateSurfaceDescription( |
|||
layer.Value.masterNode as AbstractMaterialNode, |
|||
surfaceDescriptionFunction, |
|||
shaderFunctionVisitor, |
|||
shaderProperties, |
|||
requirements, |
|||
mode, |
|||
true, |
|||
LayerToFunctionName(layer.Key)); |
|||
} |
|||
|
|||
surfaceDescriptionStruct.AddShaderChunk("struct WeightsSurfaceDescription{", false); |
|||
surfaceDescriptionStruct.Indent(); |
|||
|
|||
foreach (var slot in outputNode.GetInputSlots<MaterialSlot>()) |
|||
surfaceDescriptionStruct.AddShaderChunk(AbstractMaterialNode.ConvertConcreteSlotValueTypeToString(AbstractMaterialNode.OutputPrecision.@float, slot.concreteValueType) + " " + slot.shaderOutputName + ";", false); |
|||
|
|||
surfaceDescriptionStruct.Deindent(); |
|||
surfaceDescriptionStruct.AddShaderChunk("};", false); |
|||
|
|||
GenerateSurfaceDescription( |
|||
outputNode, |
|||
surfaceDescriptionFunction, |
|||
shaderFunctionVisitor, |
|||
shaderProperties, |
|||
requirements, |
|||
mode, |
|||
true, |
|||
"PopulateWeightsGraph", |
|||
"WeightsSurfaceDescription"); |
|||
|
|||
|
|||
string functionName = "PopulateSurfaceData"; |
|||
string surfaceDescriptionName = "SurfaceDescription"; |
|||
layerShaders.AddShaderChunk(string.Format("{0} {1}(SurfaceInputs IN) {{", surfaceDescriptionName, functionName), false); |
|||
layerShaders.Indent(); |
|||
|
|||
layerShaders.AddShaderChunk("WeightsSurfaceDescription weights = PopulateWeightsGraph(IN);", false); |
|||
layerShaders.AddShaderChunk("SurfaceDescription result = (SurfaceDescription)0;", false); |
|||
|
|||
foreach (var layer in layerMap) |
|||
{ |
|||
layerShaders.AddShaderChunk( |
|||
string.Format( |
|||
"{0} {1} = {2}({3});", |
|||
surfaceDescriptionName, |
|||
LayerToFunctionName(layer.Key) + "_surface", |
|||
LayerToFunctionName(layer.Key), |
|||
"IN"), false); |
|||
|
|||
layerShaders.AddShaderChunk( |
|||
string.Format("ScaleSurfaceDescription({0}_surface, weights.{0});", LayerToFunctionName(layer.Key)), false); |
|||
|
|||
|
|||
layerShaders.AddShaderChunk(string.Format("AddSurfaceDescription(result, {0}_surface);", LayerToFunctionName(layer.Key)), false); |
|||
} |
|||
layerShaders.AddShaderChunk("return result;", false); |
|||
|
|||
layerShaders.Deindent(); |
|||
layerShaders.AddShaderChunk("}", false); |
|||
|
|||
var finalShader = new ShaderGenerator(); |
|||
finalShader.AddShaderChunk(string.Format(@"Shader ""{0}""", name), false); |
|||
finalShader.AddShaderChunk("{", false); |
|||
finalShader.Indent(); |
|||
|
|||
finalShader.AddShaderChunk("Properties", false); |
|||
finalShader.AddShaderChunk("{", false); |
|||
finalShader.Indent(); |
|||
finalShader.AddShaderChunk(shaderProperties.GetPropertiesBlock(2), false); |
|||
finalShader.Deindent(); |
|||
finalShader.AddShaderChunk("}", false); |
|||
|
|||
finalShader.AddShaderChunk("CGINCLUDE", false); |
|||
finalShader.AddShaderChunk("#include \"UnityCG.cginc\"", false); |
|||
finalShader.AddShaderChunk(shaderFunctionVisitor.GetShaderString(2), false); |
|||
finalShader.AddShaderChunk(graphVertexInput, false); |
|||
finalShader.AddShaderChunk(surfaceInputs.GetShaderString(2), false); |
|||
finalShader.AddShaderChunk(surfaceDescriptionStruct.GetShaderString(2), false); |
|||
finalShader.AddShaderChunk(shaderProperties.GetPropertiesDeclaration(2), false); |
|||
finalShader.AddShaderChunk(vertexShader.GetShaderString(2), false); |
|||
finalShader.AddShaderChunk(surfaceDescriptionFunction.GetShaderString(2), false); |
|||
finalShader.AddShaderChunk(layerShaders.GetShaderString(2), false); |
|||
finalShader.AddShaderChunk("ENDCG", false); |
|||
|
|||
if (masterNode != null) |
|||
{ |
|||
var subShaders = masterNode.GetSubshader(requirements, null); |
|||
foreach (var ss in subShaders) |
|||
finalShader.AddShaderChunk(ss, false); |
|||
} |
|||
|
|||
finalShader.Deindent(); |
|||
finalShader.AddShaderChunk("}", false); |
|||
configuredTextures = shaderProperties.GetConfiguredTexutres(); |
|||
return finalShader.GetShaderString(0); |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ce99f0c764243ab9e2713566d4105af |
|||
timeCreated: 1507398692 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
public interface IMaterialGraphEditWindow |
|||
{ |
|||
void PingAsset(); |
|||
|
|||
void UpdateAsset(); |
|||
|
|||
void Repaint(); |
|||
|
|||
void ToSubGraph(); |
|||
|
|||
void Show(); |
|||
void Focus(); |
|||
Object selected { get; set; } |
|||
void ChangeSelection(Object newSelection); |
|||
} |
|||
|
|||
public abstract class HelperMaterialGraphEditWindow : EditorWindow, IMaterialGraphEditWindow |
|||
{ |
|||
public abstract AbstractMaterialGraph GetMaterialGraph(); |
|||
public abstract void PingAsset(); |
|||
public abstract void UpdateAsset(); |
|||
public abstract void ToSubGraph(); |
|||
public abstract Object selected { get; set; } |
|||
public abstract void ChangeSelection(Object newSelection); |
|||
} |
|||
|
|||
public class MaterialGraphEditWindow : AbstractMaterialGraphEditWindow<UnityEngine.MaterialGraph.MaterialGraph> |
|||
{ |
|||
public override AbstractMaterialGraph GetMaterialGraph() |
|||
{ |
|||
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph; |
|||
} |
|||
} |
|||
|
|||
public class SubGraphEditWindow : AbstractMaterialGraphEditWindow<SubGraph> |
|||
{ |
|||
public override AbstractMaterialGraph GetMaterialGraph() |
|||
{ |
|||
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph; |
|||
} |
|||
} |
|||
|
|||
public class MasterReampGraphEditWindow : AbstractMaterialGraphEditWindow<MasterRemapGraph> |
|||
{ |
|||
public override AbstractMaterialGraph GetMaterialGraph() |
|||
{ |
|||
return graphObject == null ? null : graphObject.graph as AbstractMaterialGraph; |
|||
} |
|||
} |
|||
|
|||
public class LayeredGraphEditWindow : AbstractMaterialGraphEditWindow<LayeredShaderGraph> |
|||
{ |
|||
public override AbstractMaterialGraph GetMaterialGraph() |
|||
{ |
|||
return inMemoryAsset; |
|||
} |
|||
} |
|||
|
|||
public abstract class AbstractMaterialGraphEditWindow<TGraphType> : HelperMaterialGraphEditWindow where TGraphType : AbstractMaterialGraph |
|||
{ |
|||
[SerializeField] |
|||
Object m_Selected; |
|||
|
|||
[SerializeField] |
|||
SerializableGraphObject m_GraphObject; |
|||
|
|||
GraphEditorView m_GraphEditorView; |
|||
GraphEditorView graphEditorView |
|||
{ |
|||
get { return m_GraphEditorView; } |
|||
set |
|||
{ |
|||
if (m_GraphEditorView != null) |
|||
{ |
|||
rootVisualContainer.Remove(m_GraphEditorView); |
|||
m_GraphEditorView.Dispose(); |
|||
} |
|||
m_GraphEditorView = value; |
|||
if (m_GraphEditorView != null) |
|||
{ |
|||
m_GraphEditorView.onUpdateAssetClick += UpdateAsset; |
|||
m_GraphEditorView.onConvertToSubgraphClick += ToSubGraph; |
|||
m_GraphEditorView.onShowInProjectClick += PingAsset; |
|||
m_GraphEditorView.RegisterCallback<PostLayoutEvent>(OnPostLayout); |
|||
rootVisualContainer.Add(graphEditorView); |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected SerializableGraphObject graphObject |
|||
{ |
|||
get { return m_GraphObject; } |
|||
set |
|||
{ |
|||
if (m_GraphObject != null) |
|||
DestroyImmediate(m_GraphObject); |
|||
m_GraphObject = value; |
|||
} |
|||
} |
|||
|
|||
public override Object selected |
|||
{ |
|||
get { return m_Selected; } |
|||
set { m_Selected = value; } |
|||
} |
|||
|
|||
void Update() |
|||
{ |
|||
var materialGraph = GetMaterialGraph(); |
|||
if (materialGraph == null) |
|||
return; |
|||
if (graphEditorView == null || graphEditorView.graphPresenter == null) |
|||
{ |
|||
graphEditorView = new GraphEditorView(materialGraph, this, selected.name); |
|||
} |
|||
if (graphEditorView != null) |
|||
graphEditorView.previewSystem.Update(); |
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
graphEditorView = null; |
|||
} |
|||
|
|||
void OnDestroy() |
|||
{ |
|||
if (EditorUtility.DisplayDialog("Shader Graph Might Have Been Modified", "Do you want to save the changes you made in the shader graph?", "Save", "Don't Save")) |
|||
{ |
|||
UpdateAsset(); |
|||
} |
|||
Undo.ClearUndo(graphObject); |
|||
DestroyImmediate(graphObject); |
|||
graphEditorView = null; |
|||
} |
|||
|
|||
void OnGUI() |
|||
{ |
|||
if (graphEditorView == null) |
|||
return; |
|||
|
|||
var presenter = graphEditorView.graphPresenter; |
|||
var e = Event.current; |
|||
|
|||
if (e.type == EventType.ValidateCommand && ( |
|||
e.commandName == "Copy" && presenter.canCopy |
|||
|| e.commandName == "Paste" && presenter.canPaste |
|||
|| e.commandName == "Duplicate" && presenter.canDuplicate |
|||
|| e.commandName == "Cut" && presenter.canCut |
|||
|| (e.commandName == "Delete" || e.commandName == "SoftDelete") && presenter.canDelete)) |
|||
{ |
|||
e.Use(); |
|||
} |
|||
|
|||
if (e.type == EventType.ExecuteCommand) |
|||
{ |
|||
if (e.commandName == "Copy") |
|||
presenter.Copy(); |
|||
if (e.commandName == "Paste") |
|||
presenter.Paste(); |
|||
if (e.commandName == "Duplicate") |
|||
presenter.Duplicate(); |
|||
if (e.commandName == "Cut") |
|||
presenter.Cut(); |
|||
if (e.commandName == "Delete" || e.commandName == "SoftDelete") |
|||
presenter.Delete(); |
|||
} |
|||
|
|||
if (e.type == EventType.KeyDown) |
|||
{ |
|||
if (e.keyCode == KeyCode.A) |
|||
graphEditorView.graphView.FrameAll(); |
|||
if (e.keyCode == KeyCode.F) |
|||
graphEditorView.graphView.FrameSelection(); |
|||
if (e.keyCode == KeyCode.O) |
|||
graphEditorView.graphView.FrameOrigin(); |
|||
if (e.keyCode == KeyCode.Tab) |
|||
graphEditorView.graphView.FrameNext(); |
|||
if (e.keyCode == KeyCode.Tab && e.modifiers == EventModifiers.Shift) |
|||
graphEditorView.graphView.FramePrev(); |
|||
} |
|||
} |
|||
|
|||
public override void PingAsset() |
|||
{ |
|||
if (selected != null) |
|||
EditorGUIUtility.PingObject(selected); |
|||
} |
|||
|
|||
public override void UpdateAsset() |
|||
{ |
|||
if (selected != null && graphObject != null) |
|||
{ |
|||
var path = AssetDatabase.GetAssetPath(selected); |
|||
if (string.IsNullOrEmpty(path) || graphObject == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
if (typeof(TGraphType) == typeof(UnityEngine.MaterialGraph.MaterialGraph)) |
|||
UpdateShaderGraphOnDisk(path); |
|||
|
|||
if (typeof(TGraphType) == typeof(LayeredShaderGraph)) |
|||
UpdateShaderGraphOnDisk(path); |
|||
|
|||
if (typeof(TGraphType) == typeof(SubGraph)) |
|||
UpdateAbstractSubgraphOnDisk<SubGraph>(path); |
|||
|
|||
if (typeof(TGraphType) == typeof(MasterRemapGraph)) |
|||
UpdateAbstractSubgraphOnDisk<MasterRemapGraph>(path); |
|||
} |
|||
} |
|||
|
|||
public override void ToSubGraph() |
|||
{ |
|||
string path = EditorUtility.SaveFilePanelInProject("Save subgraph", "New SubGraph", "ShaderSubGraph", ""); |
|||
path = path.Replace(Application.dataPath, "Assets"); |
|||
if (path.Length == 0) |
|||
return; |
|||
|
|||
var graphPresenter = graphEditorView.graphPresenter; |
|||
var selected = graphPresenter.elements.Where(e => e.selected); |
|||
|
|||
var filtered = new List<GraphElementPresenter>(); |
|||
|
|||
foreach (var presenter in selected) |
|||
{ |
|||
var nodePresenter = presenter as MaterialNodePresenter; |
|||
if (nodePresenter != null) |
|||
{ |
|||
if (!(nodePresenter.node is PropertyNode)) |
|||
filtered.Add(nodePresenter); |
|||
} |
|||
else |
|||
{ |
|||
filtered.Add(presenter); |
|||
} |
|||
} |
|||
|
|||
var deserialized = MaterialGraphPresenter.DeserializeCopyBuffer(JsonUtility.ToJson(MaterialGraphPresenter.CreateCopyPasteGraph(filtered))); |
|||
|
|||
if (deserialized == null) |
|||
return; |
|||
|
|||
var graph = new SubGraph(); |
|||
graph.AddNode(new SubGraphOutputNode()); |
|||
|
|||
var nodeGuidMap = new Dictionary<Guid, Guid>(); |
|||
foreach (var node in deserialized.GetNodes<INode>()) |
|||
{ |
|||
var oldGuid = node.guid; |
|||
var newGuid = node.RewriteGuid(); |
|||
nodeGuidMap[oldGuid] = newGuid; |
|||
graph.AddNode(node); |
|||
} |
|||
|
|||
// remap outputs to the subgraph |
|||
var onlyInputInternallyConnected = new List<IEdge>(); |
|||
var onlyOutputInternallyConnected = new List<IEdge>(); |
|||
foreach (var edge in deserialized.edges) |
|||
{ |
|||
var outputSlot = edge.outputSlot; |
|||
var inputSlot = edge.inputSlot; |
|||
|
|||
Guid remappedOutputNodeGuid; |
|||
Guid remappedInputNodeGuid; |
|||
var outputRemapExists = nodeGuidMap.TryGetValue(outputSlot.nodeGuid, out remappedOutputNodeGuid); |
|||
var inputRemapExists = nodeGuidMap.TryGetValue(inputSlot.nodeGuid, out remappedInputNodeGuid); |
|||
|
|||
// pasting nice internal links! |
|||
if (outputRemapExists && inputRemapExists) |
|||
{ |
|||
var outputSlotRef = new SlotReference(remappedOutputNodeGuid, outputSlot.slotId); |
|||
var inputSlotRef = new SlotReference(remappedInputNodeGuid, inputSlot.slotId); |
|||
graph.Connect(outputSlotRef, inputSlotRef); |
|||
} |
|||
// one edge needs to go to outside world |
|||
else if (outputRemapExists) |
|||
{ |
|||
onlyOutputInternallyConnected.Add(edge); |
|||
} |
|||
else if (inputRemapExists) |
|||
{ |
|||
onlyInputInternallyConnected.Add(edge); |
|||
} |
|||
} |
|||
|
|||
var uniqueInputEdges = onlyOutputInternallyConnected.GroupBy( |
|||
edge => edge.outputSlot, |
|||
edge => edge, |
|||
(key, edges) => new {slotRef = key, edges = edges.ToList()}); |
|||
var inputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>(); |
|||
foreach (var group in uniqueInputEdges) |
|||
{ |
|||
var inputNode = new PropertyNode(); |
|||
|
|||
var sr = group.slotRef; |
|||
var fromNode = graphPresenter.graph.GetNodeFromGuid(sr.nodeGuid); |
|||
var fromSlot = fromNode.FindOutputSlot<MaterialSlot>(sr.slotId); |
|||
|
|||
switch (fromSlot.concreteValueType) |
|||
{ |
|||
case ConcreteSlotValueType.SamplerState: |
|||
break; |
|||
case ConcreteSlotValueType.Matrix4: |
|||
break; |
|||
case ConcreteSlotValueType.Matrix3: |
|||
break; |
|||
case ConcreteSlotValueType.Matrix2: |
|||
break; |
|||
case ConcreteSlotValueType.Texture2D: |
|||
break; |
|||
case ConcreteSlotValueType.Vector4: |
|||
break; |
|||
case ConcreteSlotValueType.Vector3: |
|||
break; |
|||
case ConcreteSlotValueType.Vector2: |
|||
break; |
|||
case ConcreteSlotValueType.Vector1: |
|||
break; |
|||
default: |
|||
throw new ArgumentOutOfRangeException(); |
|||
} |
|||
} |
|||
|
|||
var uniqueOutputEdges = onlyInputInternallyConnected.GroupBy( |
|||
edge => edge.inputSlot, |
|||
edge => edge, |
|||
(key, edges) => new {slot = key, edges = edges.ToList()}); |
|||
|
|||
var outputsNeedingConnection = new List<KeyValuePair<IEdge, IEdge>>(); |
|||
foreach (var group in uniqueOutputEdges) |
|||
{ |
|||
var outputNode = graph.outputNode; |
|||
var slotId = outputNode.AddSlot(); |
|||
|
|||
var inputSlotRef = new SlotReference(outputNode.guid, slotId); |
|||
|
|||
foreach (var edge in group.edges) |
|||
{ |
|||
var newEdge = graph.Connect(new SlotReference(nodeGuidMap[edge.outputSlot.nodeGuid], edge.outputSlot.slotId), inputSlotRef); |
|||
outputsNeedingConnection.Add(new KeyValuePair<IEdge, IEdge>(edge, newEdge)); |
|||
} |
|||
} |
|||
|
|||
File.WriteAllText(path, EditorJsonUtility.ToJson(graph)); |
|||
AssetDatabase.ImportAsset(path); |
|||
|
|||
var subGraph = AssetDatabase.LoadAssetAtPath(path, typeof(MaterialSubGraphAsset)) as MaterialSubGraphAsset; |
|||
if (subGraph == null) |
|||
return; |
|||
|
|||
var subGraphNode = new SubGraphNode(); |
|||
graphPresenter.graph.AddNode(subGraphNode); |
|||
subGraphNode.subGraphAsset = subGraph; |
|||
|
|||
/* foreach (var edgeMap in inputsNeedingConnection) |
|||
{ |
|||
graphPresenter.graph.Connect(edgeMap.Key.outputSlot, new SlotReference(subGraphNode.guid, edgeMap.Value.outputSlot.slotId)); |
|||
}*/ |
|||
|
|||
foreach (var edgeMap in outputsNeedingConnection) |
|||
{ |
|||
graphPresenter.graph.Connect(new SlotReference(subGraphNode.guid, edgeMap.Value.inputSlot.slotId), edgeMap.Key.inputSlot); |
|||
} |
|||
|
|||
var toDelete = graphPresenter.elements.Where(e => e.selected).OfType<MaterialNodePresenter>(); |
|||
graphPresenter.RemoveElements(toDelete, new List<GraphEdgePresenter>()); |
|||
} |
|||
|
|||
private void UpdateAbstractSubgraphOnDisk<T>(string path) where T : AbstractSubGraph |
|||
{ |
|||
var graph = graphObject.graph as T; |
|||
if (graph == null) |
|||
return; |
|||
|
|||
File.WriteAllText(path, EditorJsonUtility.ToJson(graph, true)); |
|||
AssetDatabase.ImportAsset(path); |
|||
} |
|||
|
|||
private void UpdateShaderGraphOnDisk(string path) |
|||
{ |
|||
<<<<<<< HEAD |
|||
var graph = graphObject.graph as UnityEngine.MaterialGraph.MaterialGraph; |
|||
======= |
|||
var graph = inMemoryAsset as IShaderGraph; |
|||
>>>>>>> exposed-prop-subgraph |
|||
if (graph == null) |
|||
return; |
|||
|
|||
List<PropertyCollector.TextureInfo> configuredTextures; |
|||
graph.GetShader(Path.GetFileNameWithoutExtension(path), GenerationMode.ForReals, out configuredTextures); |
|||
|
|||
var shaderImporter = AssetImporter.GetAtPath(path) as ShaderImporter; |
|||
if (shaderImporter == null) |
|||
return; |
|||
|
|||
var textureNames = new List<string>(); |
|||
var textures = new List<Texture>(); |
|||
foreach (var textureInfo in configuredTextures.Where(x => x.modifiable)) |
|||
{ |
|||
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture; |
|||
if (texture == null) |
|||
continue; |
|||
textureNames.Add(textureInfo.name); |
|||
textures.Add(texture); |
|||
} |
|||
shaderImporter.SetDefaultTextures(textureNames.ToArray(), textures.ToArray()); |
|||
|
|||
textureNames.Clear(); |
|||
textures.Clear(); |
|||
foreach (var textureInfo in configuredTextures.Where(x => !x.modifiable)) |
|||
{ |
|||
var texture = EditorUtility.InstanceIDToObject(textureInfo.textureId) as Texture; |
|||
if (texture == null) |
|||
continue; |
|||
textureNames.Add(textureInfo.name); |
|||
textures.Add(texture); |
|||
} |
|||
shaderImporter.SetNonModifiableTextures(textureNames.ToArray(), textures.ToArray()); |
|||
File.WriteAllText(path, EditorJsonUtility.ToJson(graph, true)); |
|||
shaderImporter.SaveAndReimport(); |
|||
AssetDatabase.ImportAsset(path); |
|||
} |
|||
|
|||
|
|||
public override void ChangeSelection(Object newSelection) |
|||
{ |
|||
if (!EditorUtility.IsPersistent(newSelection)) |
|||
return; |
|||
|
|||
if (selected == newSelection) |
|||
return; |
|||
|
|||
selected = newSelection; |
|||
|
|||
var path = AssetDatabase.GetAssetPath(newSelection); |
|||
var textGraph = File.ReadAllText(path, Encoding.UTF8); |
|||
graphObject = CreateInstance<SerializableGraphObject>(); |
|||
graphObject.hideFlags = HideFlags.HideAndDontSave; |
|||
graphObject.graph = JsonUtility.FromJson<TGraphType>(textGraph); |
|||
graphObject.graph.OnEnable(); |
|||
graphObject.graph.ValidateGraph(); |
|||
|
|||
graphEditorView = new GraphEditorView(GetMaterialGraph(), this, selected.name); |
|||
titleContent = new GUIContent(selected.name); |
|||
|
|||
Repaint(); |
|||
} |
|||
|
|||
void OnPostLayout(PostLayoutEvent evt) |
|||
{ |
|||
graphEditorView.UnregisterCallback<PostLayoutEvent>(OnPostLayout); |
|||
graphEditorView.graphView.FrameAll(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5585390fdc911dd4e938a94c9c579c90 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Linq; |
|||
using UnityEditor.Graphing.Util; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEngine.Experimental.UIElements.StyleEnums; |
|||
using UnityEngine.Experimental.UIElements.StyleSheets; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Inspector |
|||
{ |
|||
public class GraphInspectorView : VisualElement, IDisposable |
|||
{ |
|||
[SerializeField] |
|||
GraphInspectorPresenter m_Presenter; |
|||
|
|||
int m_SelectionHash; |
|||
|
|||
VisualElement m_Title; |
|||
VisualElement m_PropertyItems; |
|||
VisualElement m_LayerItems; |
|||
VisualElement m_ContentContainer; |
|||
AbstractNodeEditorView m_EditorView; |
|||
|
|||
TypeMapper m_TypeMapper; |
|||
Image m_Preview; |
|||
VisualElement m_TopContainer; |
|||
|
|||
public GraphInspectorView() |
|||
{ |
|||
AddStyleSheetPath("Styles/MaterialGraph"); |
|||
|
|||
m_TopContainer = new VisualElement { name = "top" }; |
|||
{ |
|||
var headerContainer = new VisualElement { name = "header" }; |
|||
{ |
|||
m_Title = new VisualElement() { name = "title" }; |
|||
headerContainer.Add(m_Title); |
|||
} |
|||
m_TopContainer.Add(headerContainer); |
|||
|
|||
m_ContentContainer = new VisualElement { name = "content" }; |
|||
m_TopContainer.Add(m_ContentContainer); |
|||
} |
|||
Add(m_TopContainer); |
|||
|
|||
var bottomContainer = new VisualElement { name = "bottom" }; |
|||
{ |
|||
var propertiesContainer = new VisualElement { name = "properties" }; |
|||
{ |
|||
var header = new VisualElement { name = "header" }; |
|||
{ |
|||
var title = new VisualElement { name = "title", text = "Properties" }; |
|||
header.Add(title); |
|||
|
|||
var addPropertyButton = new Button(OnAddProperty) { text = "Add", name = "addButton" }; |
|||
header.Add(addPropertyButton); |
|||
} |
|||
propertiesContainer.Add(header); |
|||
|
|||
m_PropertyItems = new VisualContainer { name = "items" }; |
|||
propertiesContainer.Add(m_PropertyItems); |
|||
} |
|||
bottomContainer.Add(propertiesContainer); |
|||
|
|||
<<<<<<< HEAD |
|||
m_Preview = new Image { name = "preview", image = Texture2D.blackTexture }; |
|||
======= |
|||
//if (m_Presenter.graph is LayeredShaderGraph) |
|||
{ |
|||
var layersContainer = new VisualElement {name = "properties"}; |
|||
{ |
|||
var header = new VisualElement {name = "header"}; |
|||
{ |
|||
var title = new VisualElement {name = "title", text = "Layers"}; |
|||
header.Add(title); |
|||
|
|||
var addLayerButton = new Button(OnAddLayer) {text = "Add", name = "addButton"}; |
|||
header.Add(addLayerButton); |
|||
} |
|||
propertiesContainer.Add(header); |
|||
|
|||
m_LayerItems = new VisualContainer {name = "items"}; |
|||
propertiesContainer.Add(m_LayerItems); |
|||
} |
|||
bottomContainer.Add(layersContainer); |
|||
} |
|||
|
|||
m_Preview = new Image { name = "preview", image = Texture2D.blackTexture}; |
|||
>>>>>>> exposed-prop-subgraph |
|||
bottomContainer.Add(m_Preview); |
|||
} |
|||
Add(bottomContainer); |
|||
|
|||
// Nodes missing custom editors: |
|||
// - PropertyNode |
|||
// - SubGraphInputNode |
|||
// - SubGraphOutputNode |
|||
m_TypeMapper = new TypeMapper(typeof(INode), typeof(AbstractNodeEditorView), typeof(StandardNodeEditorView)) |
|||
{ |
|||
// { typeof(AbstractSurfaceMasterNode), typeof(SurfaceMasterNodeEditorView) } |
|||
}; |
|||
} |
|||
|
|||
void OnAddProperty() |
|||
{ |
|||
var gm = new GenericMenu(); |
|||
<<<<<<< HEAD |
|||
gm.AddItem(new GUIContent("Float"), false, () => AddProperty(new FloatShaderProperty())); |
|||
gm.AddItem(new GUIContent("Vector2"), false, () => AddProperty(new Vector2ShaderProperty())); |
|||
gm.AddItem(new GUIContent("Vector3"), false, () => AddProperty(new Vector3ShaderProperty())); |
|||
gm.AddItem(new GUIContent("Vector4"), false, () => AddProperty(new Vector4ShaderProperty())); |
|||
gm.AddItem(new GUIContent("Color"), false, () => AddProperty(new ColorShaderProperty())); |
|||
gm.AddItem(new GUIContent("Texture"), false, () => AddProperty(new TextureShaderProperty())); |
|||
gm.ShowAsContext(); |
|||
} |
|||
|
|||
void AddProperty(IShaderProperty property) |
|||
{ |
|||
m_Presenter.graph.owner.RegisterCompleteObjectUndo("Add Property"); |
|||
m_Presenter.graph.AddShaderProperty(property); |
|||
======= |
|||
gm.AddItem(new GUIContent("Float"), false, () => m_Presenter.graph.AddShaderProperty(new FloatShaderProperty())); |
|||
gm.AddItem(new GUIContent("Vector2"), false, () => m_Presenter.graph.AddShaderProperty(new Vector2ShaderProperty())); |
|||
gm.AddItem(new GUIContent("Vector3"), false, () => m_Presenter.graph.AddShaderProperty(new Vector3ShaderProperty())); |
|||
gm.AddItem(new GUIContent("Vector4"), false, () => m_Presenter.graph.AddShaderProperty(new Vector4ShaderProperty())); |
|||
gm.AddItem(new GUIContent("Color"), false, () => m_Presenter.graph.AddShaderProperty(new ColorShaderProperty())); |
|||
gm.AddItem(new GUIContent("Texture"), false, () => m_Presenter.graph.AddShaderProperty(new TextureShaderProperty())); |
|||
gm.ShowAsContext(); |
|||
} |
|||
|
|||
void OnAddLayer() |
|||
{ |
|||
var layerGraph = m_Presenter.graph as LayeredShaderGraph; |
|||
if (layerGraph == null) |
|||
return; |
|||
|
|||
layerGraph.AddLayer(); |
|||
>>>>>>> exposed-prop-subgraph |
|||
} |
|||
|
|||
public void OnChange(GraphInspectorPresenter.ChangeType changeType) |
|||
{ |
|||
if (presenter == null) |
|||
{ |
|||
m_ContentContainer.Clear(); |
|||
m_SelectionHash = 0; |
|||
return; |
|||
} |
|||
|
|||
if ((changeType & GraphInspectorPresenter.ChangeType.AssetName) != 0) |
|||
m_Title.text = presenter.assetName; |
|||
|
|||
if ((changeType & GraphInspectorPresenter.ChangeType.SelectedNodes) != 0) |
|||
{ |
|||
var selectionHash = UIUtilities.GetHashCode(presenter.selectedNodes.Count, presenter.selectedNodes != null ? presenter.selectedNodes.FirstOrDefault() : null); |
|||
if (selectionHash != m_SelectionHash) |
|||
{ |
|||
m_SelectionHash = selectionHash; |
|||
m_ContentContainer.Clear(); |
|||
if (presenter.selectedNodes.Count > 1) |
|||
{ |
|||
var element = new VisualElement {name = "selectionCount", text = string.Format("{0} nodes selected.", presenter.selectedNodes.Count)}; |
|||
m_ContentContainer.Add(element); |
|||
} |
|||
else if (presenter.selectedNodes.Count == 1) |
|||
{ |
|||
var node = presenter.selectedNodes.First(); |
|||
var view = (AbstractNodeEditorView) Activator.CreateInstance(m_TypeMapper.MapType(node.GetType())); |
|||
view.node = node; |
|||
m_ContentContainer.Add(view); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if ((changeType & GraphInspectorPresenter.ChangeType.PreviewTexture) != 0) |
|||
{ |
|||
m_Preview.image = presenter.previewTexture ?? Texture2D.blackTexture; |
|||
} |
|||
|
|||
if ((changeType & GraphInspectorPresenter.ChangeType.Graph) != 0) |
|||
{ |
|||
if (m_Graph != null) |
|||
{ |
|||
m_Graph.onChange -= OnGraphChange; |
|||
m_PropertyItems.Clear(); |
|||
m_LayerItems.Clear(); |
|||
m_Graph = null; |
|||
} |
|||
if (m_Presenter.graph != null) |
|||
{ |
|||
m_Graph = m_Presenter.graph; |
|||
foreach (var property in m_Graph.properties) |
|||
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property)); |
|||
|
|||
var layerGraph = m_Presenter.graph as LayeredShaderGraph; |
|||
if (layerGraph != null) |
|||
foreach (var layer in layerGraph.layers) |
|||
m_LayerItems.Add(new ShaderLayerView(layerGraph, layer)); |
|||
m_Graph.onChange += OnGraphChange; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void OnGraphChange(GraphChange change) |
|||
{ |
|||
var propertyAdded = change as ShaderPropertyAdded; |
|||
if (propertyAdded != null) |
|||
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, propertyAdded.shaderProperty)); |
|||
|
|||
var propertyRemoved = change as ShaderPropertyRemoved; |
|||
if (propertyRemoved != null) |
|||
{ |
|||
var propertyView = m_PropertyItems.OfType<ShaderPropertyView>().FirstOrDefault(v => v.property.guid == propertyRemoved.guid); |
|||
if (propertyView != null) |
|||
m_PropertyItems.Remove(propertyView); |
|||
} |
|||
|
|||
var layerGraph = m_Graph as LayeredShaderGraph; |
|||
if (layerGraph == null) |
|||
return; |
|||
|
|||
var layerAdded = change as LayerAdded; |
|||
if (layerAdded != null) |
|||
m_LayerItems.Add(new ShaderLayerView(layerGraph, layerAdded.layer)); |
|||
|
|||
var layerRemoved = change as LayerRemoved; |
|||
if (layerRemoved != null) |
|||
{ |
|||
var view = m_LayerItems.OfType<ShaderLayerView>().FirstOrDefault(v => v.layer.guid == layerRemoved.id); |
|||
if (view != null) |
|||
m_LayerItems.Remove(view); |
|||
} |
|||
} |
|||
|
|||
AbstractMaterialGraph m_Graph; |
|||
|
|||
public GraphInspectorPresenter presenter |
|||
{ |
|||
get { return m_Presenter; } |
|||
set |
|||
{ |
|||
if (m_Presenter == value) |
|||
return; |
|||
if (m_Presenter != null) |
|||
m_Presenter.onChange -= OnChange; |
|||
m_Presenter = value; |
|||
OnChange(GraphInspectorPresenter.ChangeType.All); |
|||
m_Presenter.onChange += OnChange; |
|||
} |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
if (m_Presenter != null) |
|||
m_Presenter.onChange -= OnChange; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d82dd6376c038284f9b84c0cc59b2af4 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEngine.Graphing; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing.Inspector |
|||
{ |
|||
public class ShaderLayerView : VisualElement |
|||
{ |
|||
public LayeredShaderGraph graph { get; } |
|||
public LayeredShaderGraph.Layer layer { get; } |
|||
|
|||
public ShaderLayerView(LayeredShaderGraph graph, LayeredShaderGraph.Layer layer) |
|||
{ |
|||
this.graph = graph; |
|||
this.layer = layer; |
|||
|
|||
Add(new IMGUIContainer(ValueField) { name = "value" }); |
|||
Add(new Button(OnClickRemove) { name = "remove", text = "Remove" }); |
|||
} |
|||
|
|||
void OnClickRemove() |
|||
{ |
|||
graph.RemoveLayer(layer.guid); |
|||
NotifyNodes(); |
|||
} |
|||
|
|||
void ValueField() |
|||
{ |
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
var newShader = EditorGUILayout.ObjectField("Shader", layer.shader, typeof(Shader), false) as Shader; |
|||
if (newShader != layer.shader) |
|||
{ |
|||
if (graph.SetLayer(layer.guid, newShader)) |
|||
NotifyNodes(); |
|||
} |
|||
} |
|||
|
|||
void NotifyNodes() |
|||
{ |
|||
foreach (var node in graph.GetNodes<PropertyNode>()) |
|||
node.onModified(node, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e1839e94c8024ee6a36ff3aa05cef37b |
|||
timeCreated: 1507451136 |
|
|||
using System; |
|||
using UnityEngine.MaterialGraph; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEditor.Graphing.Util; |
|||
using UnityEngine; |
|||
using UnityEngine.Assertions; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
public class MaterialGraphPresenter : GraphViewPresenter |
|||
{ |
|||
PreviewSystem m_PreviewSystem; |
|||
|
|||
public IGraph graph { get; private set; } |
|||
|
|||
protected MaterialGraphPresenter() |
|||
{ |
|||
<<<<<<< HEAD |
|||
======= |
|||
typeMapper = new GraphTypeMapper(typeof(MaterialNodePresenter)); |
|||
typeMapper[typeof(AbstractMaterialNode)] = typeof(MaterialNodePresenter); |
|||
typeMapper[typeof(ColorNode)] = typeof(ColorNodePresenter); |
|||
typeMapper[typeof(GradientNode)] = typeof(GradientNodePresenter); |
|||
|
|||
// typeMapper[typeof(ScatterNode)] = typeof(ScatterNodePresenter); |
|||
//typeMapper[typeof(TextureNode)] = typeof(TextureNodePresenter); |
|||
//typeMapper[typeof(SamplerAssetNode)] = typeof(SamplerAssetNodePresenter); |
|||
//typeMapper[typeof(TextureSamplerNode)] = typeof(TextureSamplerNodePresenter); |
|||
// typeMapper[typeof(Texture2DNode)] = typeof(TextureAssetNodePresenter); |
|||
// typeMapper[typeof(TextureLODNode)] = typeof(TextureLODNodePresenter); |
|||
typeMapper[typeof(SamplerStateNode)] = typeof(SamplerStateNodePresenter); |
|||
// typeMapper[typeof(CubemapNode)] = typeof(CubeNodePresenter); |
|||
// typeMapper[typeof(ToggleNode)] = typeof(ToggleNodePresenter); |
|||
typeMapper[typeof(UVNode)] = typeof(UVNodePresenter); |
|||
typeMapper[typeof(Vector1Node)] = typeof(Vector1NodePresenter); |
|||
typeMapper[typeof(Vector2Node)] = typeof(Vector2NodePresenter); |
|||
typeMapper[typeof(Vector3Node)] = typeof(Vector3NodePresenter); |
|||
typeMapper[typeof(Vector4Node)] = typeof(Vector4NodePresenter); |
|||
typeMapper[typeof(PropertyNode)] = typeof(PropertyNodePresenter); |
|||
|
|||
/* typeMapper[typeof(ScaleOffsetNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter |
|||
typeMapper[typeof(RadialShearNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter |
|||
typeMapper[typeof(SphereWarpNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter |
|||
typeMapper[typeof(SphericalIndentationNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter |
|||
typeMapper[typeof(AACheckerboardNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter |
|||
typeMapper[typeof(AACheckerboard3dNode)] = typeof(AnyNodePresenter); // anything derived from AnyNode should use the AnyNodePresenter*/ |
|||
typeMapper[typeof(SubGraphNode)] = typeof(SubgraphNodePresenter); |
|||
typeMapper[typeof(MasterRemapNode)] = typeof(MasterRemapNodePresenter); |
|||
|
|||
// typeMapper[typeof(MasterRemapInputNode)] = typeof(RemapInputNodePresenter); |
|||
typeMapper[typeof(SubGraphOutputNode)] = typeof(SubgraphIONodePresenter); |
|||
// typeMapper[typeof(AbstractSurfaceMasterNode)] = typeof(SurfaceMasterNodePresenter); |
|||
typeMapper[typeof(LevelsNode)] = typeof(LevelsNodePresenter); |
|||
typeMapper[typeof(ConstantsNode)] = typeof(ConstantsNodePresenter); |
|||
|
|||
//typeMapper[typeof(SwizzleNode)] = typeof(SwizzleNodePresenter); |
|||
typeMapper[typeof(BlendModeNode)] = typeof(BlendModeNodePresenter); |
|||
|
|||
// typeMapper[typeof(AddManyNode)] = typeof(AddManyNodePresenter); |
|||
typeMapper[typeof(IfNode)] = typeof(IfNodePresenter); |
|||
|
|||
//typeMapper[typeof(CustomCodeNode)] = typeof(CustomCodePresenter); |
|||
typeMapper[typeof(Matrix2Node)] = typeof(Matrix2NodePresenter); |
|||
typeMapper[typeof(Matrix3Node)] = typeof(Matrix3NodePresenter); |
|||
typeMapper[typeof(Matrix4Node)] = typeof(Matrix4NodePresenter); |
|||
typeMapper[typeof(MatrixCommonNode)] = typeof(MatrixCommonNodePresenter); |
|||
typeMapper[typeof(TransformNode)] = typeof(TransformNodePresenter); |
|||
|
|||
// typeMapper[typeof(ConvolutionFilterNode)] = typeof(ConvolutionFilterNodePresenter); |
|||
>>>>>>> exposed-prop-subgraph |
|||
} |
|||
|
|||
public override List<NodeAnchorPresenter> GetCompatibleAnchors(NodeAnchorPresenter startAnchor, NodeAdapter nodeAdapter) |
|||
{ |
|||
var compatibleAnchors = new List<NodeAnchorPresenter>(); |
|||
var startAnchorPresenter = startAnchor as GraphAnchorPresenter; |
|||
if (startAnchorPresenter == null) |
|||
return compatibleAnchors; |
|||
var startSlot = startAnchorPresenter.slot as MaterialSlot; |
|||
if (startSlot == null) |
|||
return compatibleAnchors; |
|||
|
|||
var startStage = startSlot.shaderStage; |
|||
if (startStage == ShaderStage.Dynamic) |
|||
startStage = NodeUtils.FindEffectiveShaderStage(startSlot.owner, startSlot.isOutputSlot); |
|||
|
|||
foreach (var candidateAnchorPresenter in allChildren.OfType<GraphAnchorPresenter>()) |
|||
{ |
|||
if (!candidateAnchorPresenter.IsConnectable()) |
|||
continue; |
|||
if (candidateAnchorPresenter.orientation != startAnchor.orientation) |
|||
continue; |
|||
if (candidateAnchorPresenter.direction == startAnchor.direction) |
|||
continue; |
|||
if (nodeAdapter.GetAdapter(candidateAnchorPresenter.source, startAnchor.source) == null) |
|||
continue; |
|||
var candidateSlot = candidateAnchorPresenter.slot as MaterialSlot; |
|||
if (candidateSlot == null) |
|||
continue; |
|||
if (candidateSlot.owner == startSlot.owner) |
|||
continue; |
|||
if (!startSlot.IsCompatibleWithInputSlotType(candidateSlot.concreteValueType)) |
|||
continue; |
|||
|
|||
if (startStage != ShaderStage.Dynamic) |
|||
{ |
|||
var candidateStage = candidateSlot.shaderStage; |
|||
if (candidateStage == ShaderStage.Dynamic) |
|||
candidateStage = NodeUtils.FindEffectiveShaderStage(candidateSlot.owner, !startSlot.isOutputSlot); |
|||
if (candidateStage != ShaderStage.Dynamic && candidateStage != startStage) |
|||
continue; |
|||
} |
|||
|
|||
compatibleAnchors.Add(candidateAnchorPresenter); |
|||
} |
|||
return compatibleAnchors; |
|||
} |
|||
|
|||
void OnNodeChanged(INode inNode, ModificationScope scope) |
|||
{ |
|||
var dependentNodes = new List<INode>(); |
|||
NodeUtils.CollectNodesNodeFeedsInto(dependentNodes, inNode); |
|||
foreach (var node in dependentNodes) |
|||
{ |
|||
var theElements = m_Elements.OfType<MaterialNodePresenter>().ToList(); |
|||
var found = theElements.Where(x => x.node.guid == node.guid).ToList(); |
|||
foreach (var drawableNodeData in found) |
|||
drawableNodeData.OnModified(scope); |
|||
} |
|||
|
|||
// We might need to do something here |
|||
// if (scope == ModificationScope.Topological) |
|||
} |
|||
|
|||
public virtual void Initialize(IGraph graph, IMaterialGraphEditWindow container, PreviewSystem previewSystem) |
|||
{ |
|||
m_PreviewSystem = previewSystem; |
|||
this.graph = graph; |
|||
|
|||
if (graph == null) |
|||
return; |
|||
|
|||
foreach (var node in graph.GetNodes<INode>()) |
|||
NodeAdded(new NodeAddedGraphChange(node)); |
|||
foreach (var edge in graph.edges) |
|||
EdgeAdded(new EdgeAddedGraphChange(edge)); |
|||
|
|||
this.graph.onChange += OnChange; |
|||
} |
|||
|
|||
void OnChange(GraphChange change) |
|||
{ |
|||
change.Match(NodeAdded, NodeRemoved, EdgeAdded, EdgeRemoved); |
|||
} |
|||
|
|||
void NodeAdded(NodeAddedGraphChange change) |
|||
{ |
|||
var nodePresenter = CreateInstance<MaterialNodePresenter>(); |
|||
change.node.onModified += OnNodeChanged; |
|||
nodePresenter.Initialize(change.node, m_PreviewSystem); |
|||
m_Elements.Add(nodePresenter); |
|||
} |
|||
|
|||
void NodeRemoved(NodeRemovedGraphChange change) |
|||
{ |
|||
change.node.onModified -= OnNodeChanged; |
|||
var nodePresenter = m_Elements.OfType<MaterialNodePresenter>().FirstOrDefault(p => p.node.guid == change.node.guid); |
|||
if (nodePresenter != null) |
|||
m_Elements.Remove(nodePresenter); |
|||
} |
|||
|
|||
void EdgeAdded(EdgeAddedGraphChange change) |
|||
{ |
|||
var edge = change.edge; |
|||
|
|||
var sourceNode = graph.GetNodeFromGuid(edge.outputSlot.nodeGuid); |
|||
var sourceSlot = sourceNode.FindOutputSlot<ISlot>(edge.outputSlot.slotId); |
|||
var sourceNodePresenter = m_Elements.OfType<MaterialNodePresenter>().FirstOrDefault(x => x.node == sourceNode); |
|||
var sourceAnchorPresenter = sourceNodePresenter.outputAnchors.OfType<GraphAnchorPresenter>().FirstOrDefault(x => x.slot.Equals(sourceSlot)); |
|||
|
|||
var targetNode = graph.GetNodeFromGuid(edge.inputSlot.nodeGuid); |
|||
var targetSlot = targetNode.FindInputSlot<ISlot>(edge.inputSlot.slotId); |
|||
var targetNodePresenter = m_Elements.OfType<MaterialNodePresenter>().FirstOrDefault(x => x.node == targetNode); |
|||
var targetAnchor = targetNodePresenter.inputAnchors.OfType<GraphAnchorPresenter>().FirstOrDefault(x => x.slot.Equals(targetSlot)); |
|||
|
|||
var edgePresenter = CreateInstance<GraphEdgePresenter>(); |
|||
edgePresenter.Initialize(edge); |
|||
edgePresenter.output = sourceAnchorPresenter; |
|||
edgePresenter.output.Connect(edgePresenter); |
|||
edgePresenter.input = targetAnchor; |
|||
edgePresenter.input.Connect(edgePresenter); |
|||
m_Elements.Add(edgePresenter); |
|||
} |
|||
|
|||
void EdgeRemoved(EdgeRemovedGraphChange change) |
|||
{ |
|||
var edgePresenter = m_Elements.OfType<GraphEdgePresenter>().FirstOrDefault(p => p.edge == change.edge); |
|||
if (edgePresenter != null) |
|||
{ |
|||
edgePresenter.output.Disconnect(edgePresenter); |
|||
edgePresenter.input.Disconnect(edgePresenter); |
|||
m_Elements.Remove(edgePresenter); |
|||
} |
|||
} |
|||
|
|||
public void AddNode(INode node) |
|||
{ |
|||
graph.owner.RegisterCompleteObjectUndo("Add " + node.name); |
|||
graph.AddNode(node); |
|||
} |
|||
|
|||
public void RemoveElements(IEnumerable<MaterialNodePresenter> nodes, IEnumerable<GraphEdgePresenter> edges) |
|||
{ |
|||
graph.RemoveElements(nodes.Select(x => x.node as INode), edges.Select(x => x.edge)); |
|||
graph.ValidateGraph(); |
|||
} |
|||
|
|||
public void Connect(GraphAnchorPresenter left, GraphAnchorPresenter right) |
|||
{ |
|||
if (left != null && right != null) |
|||
{ |
|||
graph.owner.RegisterCompleteObjectUndo("Connect Edge"); |
|||
graph.Connect(left.slot.slotReference, right.slot.slotReference); |
|||
} |
|||
} |
|||
|
|||
internal static CopyPasteGraph CreateCopyPasteGraph(IEnumerable<GraphElementPresenter> selection) |
|||
{ |
|||
var graph = new CopyPasteGraph(); |
|||
foreach (var presenter in selection) |
|||
{ |
|||
var nodePresenter = presenter as MaterialNodePresenter; |
|||
if (nodePresenter != null) |
|||
{ |
|||
graph.AddNode(nodePresenter.node); |
|||
foreach (var edge in NodeUtils.GetAllEdges(nodePresenter.node)) |
|||
graph.AddEdge(edge); |
|||
} |
|||
|
|||
var edgePresenter = presenter as GraphEdgePresenter; |
|||
if (edgePresenter != null) |
|||
graph.AddEdge(edgePresenter.edge); |
|||
} |
|||
return graph; |
|||
} |
|||
|
|||
internal static CopyPasteGraph DeserializeCopyBuffer(string copyBuffer) |
|||
{ |
|||
try |
|||
{ |
|||
return JsonUtility.FromJson<CopyPasteGraph>(copyBuffer); |
|||
} |
|||
catch |
|||
{ |
|||
// ignored. just means copy buffer was not a graph :( |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
void InsertCopyPasteGraph(CopyPasteGraph copyGraph) |
|||
{ |
|||
if (copyGraph == null || graph == null) |
|||
return; |
|||
|
|||
var addedNodes = new List<INode>(); |
|||
var nodeGuidMap = new Dictionary<Guid, Guid>(); |
|||
foreach (var node in copyGraph.GetNodes<INode>()) |
|||
{ |
|||
var oldGuid = node.guid; |
|||
var newGuid = node.RewriteGuid(); |
|||
nodeGuidMap[oldGuid] = newGuid; |
|||
|
|||
var drawState = node.drawState; |
|||
var position = drawState.position; |
|||
position.x += 30; |
|||
position.y += 30; |
|||
drawState.position = position; |
|||
node.drawState = drawState; |
|||
graph.AddNode(node); |
|||
addedNodes.Add(node); |
|||
} |
|||
|
|||
// only connect edges within pasted elements, discard |
|||
// external edges. |
|||
foreach (var edge in copyGraph.edges) |
|||
{ |
|||
var outputSlot = edge.outputSlot; |
|||
var inputSlot = edge.inputSlot; |
|||
|
|||
Guid remappedOutputNodeGuid; |
|||
Guid remappedInputNodeGuid; |
|||
if (nodeGuidMap.TryGetValue(outputSlot.nodeGuid, out remappedOutputNodeGuid) |
|||
&& nodeGuidMap.TryGetValue(inputSlot.nodeGuid, out remappedInputNodeGuid)) |
|||
{ |
|||
var outputSlotRef = new SlotReference(remappedOutputNodeGuid, outputSlot.slotId); |
|||
var inputSlotRef = new SlotReference(remappedInputNodeGuid, inputSlot.slotId); |
|||
graph.Connect(outputSlotRef, inputSlotRef); |
|||
} |
|||
} |
|||
|
|||
graph.ValidateGraph(); |
|||
if (onSelectionChanged != null) |
|||
onSelectionChanged(addedNodes); |
|||
} |
|||
|
|||
public bool canCopy |
|||
{ |
|||
get { return elements.Any(e => e.selected); } |
|||
} |
|||
|
|||
public void Copy() |
|||
{ |
|||
var graph = CreateCopyPasteGraph(elements.Where(e => e.selected)); |
|||
EditorGUIUtility.systemCopyBuffer = JsonUtility.ToJson(graph, true); |
|||
} |
|||
|
|||
public bool canCut |
|||
{ |
|||
get { return canCopy; } |
|||
} |
|||
|
|||
public void Cut() |
|||
{ |
|||
Copy(); |
|||
graph.owner.RegisterCompleteObjectUndo("Cut"); |
|||
RemoveElements(elements.OfType<MaterialNodePresenter>().Where(e => e.selected), elements.OfType<GraphEdgePresenter>().Where(e => e.selected)); |
|||
} |
|||
|
|||
public bool canPaste |
|||
{ |
|||
get { return DeserializeCopyBuffer(EditorGUIUtility.systemCopyBuffer) != null; } |
|||
} |
|||
|
|||
public void Paste() |
|||
{ |
|||
var pastedGraph = DeserializeCopyBuffer(EditorGUIUtility.systemCopyBuffer); |
|||
graph.owner.RegisterCompleteObjectUndo("Paste"); |
|||
InsertCopyPasteGraph(pastedGraph); |
|||
} |
|||
|
|||
public bool canDuplicate |
|||
{ |
|||
get { return canCopy; } |
|||
} |
|||
|
|||
public void Duplicate() |
|||
{ |
|||
var deserializedGraph = DeserializeCopyBuffer(JsonUtility.ToJson(CreateCopyPasteGraph(elements.Where(e => e.selected)), true)); |
|||
graph.owner.RegisterCompleteObjectUndo("Duplicate"); |
|||
InsertCopyPasteGraph(deserializedGraph); |
|||
} |
|||
|
|||
public bool canDelete |
|||
{ |
|||
get { return canCopy; } |
|||
} |
|||
|
|||
public void Delete() |
|||
{ |
|||
graph.owner.RegisterCompleteObjectUndo("Delete"); |
|||
RemoveElements(elements.OfType<MaterialNodePresenter>().Where(e => e.selected), elements.OfType<GraphEdgePresenter>().Where(e => e.selected)); |
|||
} |
|||
|
|||
public override void AddElement(EdgePresenter edge) |
|||
{ |
|||
Connect(edge.output as GraphAnchorPresenter, edge.input as GraphAnchorPresenter); |
|||
} |
|||
|
|||
public delegate void OnSelectionChanged(IEnumerable<INode> presenters); |
|||
|
|||
public OnSelectionChanged onSelectionChanged; |
|||
|
|||
public void UpdateSelection(IEnumerable<MaterialNodePresenter> presenters) |
|||
{ |
|||
if (graph == null) |
|||
return; |
|||
if (onSelectionChanged != null) |
|||
onSelectionChanged(presenters.Select(x => x.node as INode)); |
|||
} |
|||
|
|||
public override void AddElement(GraphElementPresenter element) |
|||
{ |
|||
throw new ArgumentException("Not supported on Serializable Graph, data comes from data store"); |
|||
} |
|||
|
|||
public override void RemoveElement(GraphElementPresenter element) |
|||
{ |
|||
throw new ArgumentException("Not supported on Serializable Graph, data comes from data store"); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: bc4af21039c3d6b44a2ed6820e5c23ce |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7e4695133ddd49cf97b1629ca5537e5b |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c196fa3d7b5ae4049afeb1cd0400d9b6 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor.Experimental.UIElements.GraphView; |
|||
using UnityEngine; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class SubgraphIONodeControlPresenter : GraphControlPresenter |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var ioNode = node as SubGraphOutputNode; |
|||
if (ioNode == null) |
|||
return; |
|||
|
|||
if (GUILayout.Button("Add Slot")) |
|||
ioNode.AddSlot(); |
|||
if (GUILayout.Button("Remove Slot")) |
|||
ioNode.RemoveSlot(); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight * 2 + 3 * EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class SubgraphIONodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphControlPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<SubgraphIONodeControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphControlPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b8c4dd0c197664d5ebf80f433981c6b4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
{ |
|||
"m_SerializableNodes": [ |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.SubGraphInputNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"fee15ca4-2990-4a82-819a-e7c1cc065b84\",\n \"m_Name\": \"SubGraphInputs\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": 0.0,\n \"y\": 0.0,\n \"width\": 0.0,\n \"height\": 0.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": -1,\\n \\\"m_DisplayName\\\": \\\"Input 1\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 6,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"Input1\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.SubGraphOutputNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"0af42f22-ed9f-46b9-bb7a-0ebb795ab356\",\n \"m_Name\": \"SubGraphOutputs\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": 0.0,\n \"y\": 0.0,\n \"width\": 0.0,\n \"height\": 0.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"Output 1\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 6,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"Output1\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.CamDirNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"527ef353-4a94-4a32-a911-4578a7a7357d\",\n \"m_Name\": \"CameraDirection\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2806.62744140625,\n \"y\": 547.4772338867188,\n \"width\": 304.0,\n \"height\": 258.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Output\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 6,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"Output\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.WorldSpaceNormalNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"ab1fea28-c9be-4835-8e64-9fab4f96ab28\",\n \"m_Name\": \"WorldNormal\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2806.63818359375,\n \"y\": 827.5852661132813,\n \"width\": 308.0,\n \"height\": 258.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Normal\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 7,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 1.0,\\n \\\"w\\\": 1.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 1.0,\\n \\\"w\\\": 1.0\\n },\\n \\\"m_ConcreteValueType\\\": 6,\\n \\\"m_ShaderOutputName\\\": \\\"Normal\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.DotNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"ec289f62-8ec3-49ab-9fbd-76c75f980f54\",\n \"m_Name\": \"DotProduct\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2426.489501953125,\n \"y\": 736.7769165039063,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 7,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 6,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 7,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 6,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.SubtractNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"b6e0606d-0952-49e8-8d46-cebb582d47c1\",\n \"m_Name\": \"Subtract\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2075.592529296875,\n \"y\": 739.856201171875,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 1.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.PowerNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"ae331280-a6c0-4bd5-b0df-816dc3d28c46\",\n \"m_Name\": \"Power\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -1690.9185791015625,\n \"y\": 960.6397705078125,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 3.1700000762939455,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.MultiplyNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"400f6e19-0e93-442a-a7d8-79deb37f3f11\",\n \"m_Name\": \"Multiply\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2013.73779296875,\n \"y\": 1107.570068359375,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.TimeNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"ab5b6501-3879-40aa-9597-55a1403fac4c\",\n \"m_Name\": \"Time\",\n \"m_DrawState\": {\n \"m_Expanded\": false,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -3085.012939453125,\n \"y\": 1369.556640625,\n \"width\": 313.0,\n \"height\": 142.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"Time\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 6,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 5,\\n \\\"m_ShaderOutputName\\\": \\\"Time\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"Time/20\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"Time/20\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"Time\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"Time\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 3,\\n \\\"m_DisplayName\\\": \\\"Time * 2\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"Time * 2\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 4,\\n \\\"m_DisplayName\\\": \\\"Time * 3\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 9,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"Time * 3\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.SinNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"5c3aacb1-762e-4e14-a4db-8dcc4848ca6f\",\n \"m_Name\": \"Sin\",\n \"m_DrawState\": {\n \"m_Expanded\": false,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2718.04931640625,\n \"y\": 1334.964111328125,\n \"width\": 297.0,\n \"height\": 88.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"argument\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"argument\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.MaterialGraph.AddNode", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_GuidSerialized\": \"c099bbe1-c642-4cb3-a7bf-daea22f9b1aa\",\n \"m_Name\": \"Add\",\n \"m_DrawState\": {\n \"m_Expanded\": true,\n \"m_Position\": {\n \"serializedVersion\": \"2\",\n \"x\": -2344.2314453125,\n \"y\": 1313.0528564453125,\n \"width\": 297.0,\n \"height\": 310.0\n }\n },\n \"m_SerializableSlots\": [\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 0,\\n \\\"m_DisplayName\\\": \\\"first\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 1.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"first\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 1,\\n \\\"m_DisplayName\\\": \\\"second\\\",\\n \\\"m_SlotType\\\": 0,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 2.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"second\\\"\\n}\"\n },\n {\n \"typeInfo\": {\n \"fullName\": \"UnityEngine.MaterialGraph.MaterialSlot\",\n \"assemblyName\": \"Assembly-CSharp\"\n },\n \"JSONnodeData\": \"{\\n \\\"m_Id\\\": 2,\\n \\\"m_DisplayName\\\": \\\"result\\\",\\n \\\"m_SlotType\\\": 1,\\n \\\"m_Priority\\\": 2147483647,\\n \\\"m_Hidden\\\": false,\\n \\\"m_ValueType\\\": 5,\\n \\\"m_DefaultValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_CurrentValue\\\": {\\n \\\"x\\\": 0.0,\\n \\\"y\\\": 0.0,\\n \\\"z\\\": 0.0,\\n \\\"w\\\": 0.0\\n },\\n \\\"m_ConcreteValueType\\\": 8,\\n \\\"m_ShaderOutputName\\\": \\\"result\\\"\\n}\"\n }\n ]\n}" |
|||
} |
|||
], |
|||
"m_SerializableEdges": [ |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"527ef353-4a94-4a32-a911-4578a7a7357d\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"ec289f62-8ec3-49ab-9fbd-76c75f980f54\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"ab1fea28-c9be-4835-8e64-9fab4f96ab28\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"ec289f62-8ec3-49ab-9fbd-76c75f980f54\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"ec289f62-8ec3-49ab-9fbd-76c75f980f54\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"b6e0606d-0952-49e8-8d46-cebb582d47c1\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"b6e0606d-0952-49e8-8d46-cebb582d47c1\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"ae331280-a6c0-4bd5-b0df-816dc3d28c46\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"400f6e19-0e93-442a-a7d8-79deb37f3f11\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"ae331280-a6c0-4bd5-b0df-816dc3d28c46\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"c099bbe1-c642-4cb3-a7bf-daea22f9b1aa\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"400f6e19-0e93-442a-a7d8-79deb37f3f11\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 3,\n \"m_NodeGUIDSerialized\": \"ab5b6501-3879-40aa-9597-55a1403fac4c\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"5c3aacb1-762e-4e14-a4db-8dcc4848ca6f\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"5c3aacb1-762e-4e14-a4db-8dcc4848ca6f\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"c099bbe1-c642-4cb3-a7bf-daea22f9b1aa\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": -1,\n \"m_NodeGUIDSerialized\": \"fee15ca4-2990-4a82-819a-e7c1cc065b84\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 0,\n \"m_NodeGUIDSerialized\": \"400f6e19-0e93-442a-a7d8-79deb37f3f11\"\n }\n}" |
|||
}, |
|||
{ |
|||
"typeInfo": { |
|||
"fullName": "UnityEngine.Graphing.Edge", |
|||
"assemblyName": "Assembly-CSharp" |
|||
}, |
|||
"JSONnodeData": "{\n \"m_OutputSlot\": {\n \"m_SlotId\": 2,\n \"m_NodeGUIDSerialized\": \"ae331280-a6c0-4bd5-b0df-816dc3d28c46\"\n },\n \"m_InputSlot\": {\n \"m_SlotId\": 1,\n \"m_NodeGUIDSerialized\": \"0af42f22-ed9f-46b9-bb7a-0ebb795ab356\"\n }\n}" |
|||
} |
|||
] |
|||
} |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue