浏览代码

Add copy to clipboard for selected node

/main
Jens Holm 7 年前
当前提交
2ecc2e08
共有 1 个文件被更改,包括 13 次插入2 次删除
  1. 15
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs

15
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs


m_CopyToClipboardButton = new ToolbarButtonView() { text = "Copy shader to clipboard" };
m_CopyToClipboardButton.AddManipulator(new Clickable(() =>
{
AbstractMaterialNode masterNode = graph.GetNodes<MasterNode>().First();
AbstractMaterialNode copyFromNode = graph.GetNodes<MasterNode>().First();
if (graphView.selection.Count == 1)
{
MaterialNodeView selectedNodeView = graphView.selection[0] as MaterialNodeView;
if (selectedNodeView.node != null && selectedNodeView.node.hasPreview)
{
copyFromNode = selectedNodeView.node;
}
}
string shader = graph.GetShader(masterNode, GenerationMode.ForReals, asset.name, out textureInfo, out previewMode);
string shader = graph.GetShader(copyFromNode, GenerationMode.ForReals, asset.name, out textureInfo, out previewMode);
GUIUtility.systemCopyBuffer = shader;
}
));

正在加载...
取消
保存