浏览代码

Minor refactor of preview mesh rotation and scale according to PR comments

/main
Jens Holm 7 年前
当前提交
8a16933b
共有 3 个文件被更改,包括 9 次插入9 次删除
  1. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs
  2. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/AbstractMaterialGraph.cs


List<Guid> m_RemovedProperties = new List<Guid>();
[NonSerialized]
public InspectorPreviewData previewData = new InspectorPreviewData();
InspectorPreviewData m_PreviewData = new InspectorPreviewData();
public Mesh previewMesh
public InspectorPreviewData previewData
get { return previewData.mesh; }
set { previewData.mesh = value; }
get { return m_PreviewData; }
set { m_PreviewData = value; }
}
public IEnumerable<IShaderProperty> properties

{
vertexInputs.AddShaderChunk("float4 color : COLOR;", false);
}
foreach (var channel in graphRequiements.requiresMeshUVs.Distinct())
{
vertexInputs.AddShaderChunk(string.Format("float4 texcoord{0} : TEXCOORD{1};", ((int)channel).ToString(), vertexInputIndex.ToString()), false);

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


m_PreviewRenderHandle = previewManager.masterRenderData;
m_PreviewRenderHandle.onPreviewChanged += OnPreviewChanged;
m_PreviewMeshPicker.SetValueAndNotify(m_Graph.previewMesh);
m_PreviewMeshPicker.SetValueAndNotify(m_Graph.previewData.mesh);
foreach (var property in m_Graph.properties)
m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property));

masterNode.onModified(masterNode, ModificationScope.Node);
if (m_Graph.previewMesh != changedMesh)
if (m_Graph.previewData.mesh != changedMesh)
m_Graph.previewMesh = changedMesh;
m_Graph.previewData.mesh = changedMesh;
}
public void UpdateSelection(IEnumerable<INode> nodes)

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs


RenderTexture.active = renderData.renderTexture;
GL.Clear(true, true, Color.black);
Graphics.Blit(Texture2D.whiteTexture, renderData.renderTexture, m_SceneResources.checkerboardMaterial);
var mesh = (renderData == masterRenderData && m_Graph.previewMesh) ? m_Graph.previewMesh : m_SceneResources.sphere;
var mesh = (renderData == masterRenderData && m_Graph.previewData.mesh) ? m_Graph.previewData.mesh : m_SceneResources.sphere;
Quaternion rotation = (renderData == masterRenderData) ? m_Graph.previewData.rotation : Quaternion.identity;
float scale = (renderData == masterRenderData) ? m_Graph.previewData.scale : 1f;
Graphics.DrawMesh(mesh, Matrix4x4.TRS(-mesh.bounds.center, rotation, Vector3.one * scale), m_PreviewMaterial, 1, m_SceneResources.camera, 0, m_PreviewPropertyBlock, ShadowCastingMode.Off, false, null, false);

正在加载...
取消
保存