浏览代码

Merge pull request #130 from Unity-Technologies/inspector-preview-mesh

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

8
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

10
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));

m_PreviewScrollPosition.y = Mathf.Clamp(m_PreviewScrollPosition.y, -90f, 90f);
Quaternion previewRotation = Quaternion.Euler(m_PreviewScrollPosition.y, 0, 0) * Quaternion.Euler(0, m_PreviewScrollPosition.x, 0);
m_Graph.previewData.rotation = previewRotation;
masterNode.onModified(masterNode, ModificationScope.Node);
}
void OnMouseScroll(float scrollDelta)

masterNode.onModified(masterNode, ModificationScope.Node);
}
void OnAddProperty()

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);

正在加载...
取消
保存