浏览代码

Add copy to clipboard toolbar button

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

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


using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEditor.MaterialGraph.Drawing;

using UnityEngine.MaterialGraph;
using UnityEngine.Graphing;
using Object = UnityEngine.Object;
namespace UnityEditor.MaterialGraph.Drawing
{

GraphInspectorView m_GraphInspectorView;
ToolbarView m_ToolbarView;
ToolbarButtonView m_TimeButton;
ToolbarButtonView m_CopyToClipboardButton;
PreviewSystem m_PreviewSystem;

m_TimeButton.text = "Preview rate: " + previewRate;
}));
m_ToolbarView.Add(m_TimeButton);
m_ToolbarView.Add(new ToolbarSeparatorView());
m_CopyToClipboardButton = new ToolbarButtonView() { text = "Copy shader to clipboard" };
m_CopyToClipboardButton.AddManipulator(new Clickable(() =>
{
AbstractMaterialNode masterNode = graph.GetNodes<MasterNode>().First();
var textureInfo = new List<PropertyCollector.TextureInfo>();
PreviewMode previewMode;
string shader = graph.GetShader(masterNode, GenerationMode.ForReals, assetName, out textureInfo, out previewMode);
GUIUtility.systemCopyBuffer = shader;
}
));
m_ToolbarView.Add(m_CopyToClipboardButton);
m_ToolbarView.Add(new ToolbarSeparatorView());
}

正在加载...
取消
保存