浏览代码

Move "convert to subgraph" to context menu

/main
Peter Bay Bastian 7 年前
当前提交
90868fe3
共有 2 个文件被更改,包括 11 次插入14 次删除
  1. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/SearchWindowProvider.cs
  2. 19
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/SearchWindowProvider.cs


using System.Reflection;
using UnityEditor.Experimental.UIElements;
using UnityEditor.Experimental.UIElements.GraphView;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using INode = UnityEditor.Graphing.INode;

const string k_ConvertToInlineNode = "Convert To Inline Node";
const string k_ConvertToSubgraph = "Convert To Sub-graph";
const string k_CopyShader = "Copy Shader To Clipboard";
public Action onConvertToSubgraphClick { get; set; }
public void Initialize(EditorWindow editorWindow, AbstractMaterialGraph graph, GraphView graphView)
{

};
// Add in contextual node actions
var selection = m_GraphView.selection.OfType<MaterialNodeView>().ToList();
var selection = m_GraphView.selection.OfType<MaterialNodeView>().Where(v => v.node != null).ToList();
if (selection.Any())
tree.Add(new SearchTreeEntry(new GUIContent(k_ConvertToSubgraph, m_Icon)) { level = 1 });
if (selection.Any(v => v.node is IPropertyFromNode))

bool OnConvertToSubgraph()
{
if (onConvertToSubgraphClick != null) onConvertToSubgraphClick();
return true;
}

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


SearchWindowProvider m_SearchWindowProvider;
public Action onUpdateAssetClick { get; set; }
public Action onConvertToSubgraphClick { get; set; }
public Action onConvertToSubgraphClick
{
get { return m_SearchWindowProvider.onConvertToSubgraphClick; }
set { m_SearchWindowProvider.onConvertToSubgraphClick = value; }
}
public Action onShowInProjectClick { get; set; }
public MaterialGraphView graphView

if (onUpdateAssetClick != null) onUpdateAssetClick();
}));
m_ToolbarView.Add(updateAssetButton);
m_ToolbarView.Add(new ToolbarSeparatorView());
m_ToolbarView.Add(new ToolbarSpaceView());
m_ToolbarView.Add(new ToolbarSeparatorView());
var convertToSubgraphButton = new ToolbarButtonView { text = "Convert to subgraph" };
convertToSubgraphButton.AddManipulator(new Clickable(() =>
{
if (onConvertToSubgraphClick != null) onConvertToSubgraphClick();
}));
m_ToolbarView.Add(convertToSubgraphButton);
m_ToolbarView.Add(new ToolbarSeparatorView());
m_ToolbarView.Add(new ToolbarSpaceView());

正在加载...
取消
保存