浏览代码

Support "Cut" command

/main
Peter Bay Bastian 7 年前
当前提交
04fedafb
共有 3 个文件被更改,包括 18 次插入4 次删除
  1. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  2. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
  3. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs


if (e.type == EventType.ValidateCommand && (
e.commandName == "Copy" && presenter.canCopy
|| e.commandName == "Paste" && presenter.canPaste
|| e.commandName == "Duplicate" && presenter.canDuplicate))
|| e.commandName == "Duplicate" && presenter.canDuplicate
|| e.commandName == "Cut" && presenter.canCut))
{
e.Use();
}

presenter.Paste();
if (e.commandName == "Duplicate")
presenter.Duplicate();
if (e.commandName == "Cut")
presenter.Cut();
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs


EditorGUIUtility.systemCopyBuffer = JsonUtility.ToJson(graph, true);
}
public bool canCut
{
get { return canCopy; }
}
public void Cut()
{
Copy();
RemoveElements(elements.OfType<MaterialNodePresenter>().Where(e => e.selected), elements.OfType<GraphEdgePresenter>().Where(e => e.selected));
}
public bool canPaste
{
get { return DeserializeCopyBuffer(EditorGUIUtility.systemCopyBuffer) != null; }

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs


// TODO JOCE Remove the "new" here. Use the base class' impl
new EventPropagation DeleteSelection()
{
var nodalViewData = GetPresenter<MaterialGraphPresenter>();
if (nodalViewData == null)
var presenter = GetPresenter<MaterialGraphPresenter>();
if (presenter == null)
nodalViewData.RemoveElements(
presenter.RemoveElements(
selection.OfType<MaterialNodeView>().Select(x => x.GetPresenter<MaterialNodePresenter>()),
selection.OfType<Edge>().Select(x => x.GetPresenter<GraphEdgePresenter>())
);

正在加载...
取消
保存