grep .asmdef

This commit is contained in:
nakano yosuke 2019-12-09 00:58:46 +09:00
parent cac48dd659
commit bde59ad1be
3 changed files with 17 additions and 8 deletions

View File

@ -1,4 +1,6 @@
using UnityEditor; using System.IO;
using System.Linq;
using UnityEditor;
namespace AsmdefGraph.Editor { namespace AsmdefGraph.Editor {
public class AsmdefGraphEditorWindow : EditorWindow { public class AsmdefGraphEditorWindow : EditorWindow {
@ -8,7 +10,14 @@ namespace AsmdefGraph.Editor {
} }
void OnEnable() { void OnEnable() {
var graphView = new AsmdefGraphView() { // プロジェクトのasmdefを全検索
var asmdefs = Directory.EnumerateFiles(
Directory.GetCurrentDirectory(), "*.asmdef", SearchOption.AllDirectories);
var asmdefNames = asmdefs
.Select(x => x.Split('\\').LastOrDefault())
.Select(x => x.Replace(".asmdef", ""))
.Where(x => !string.IsNullOrEmpty(x));
var graphView = new AsmdefGraphView(asmdefNames) {
style = { flexGrow = 1 } style = { flexGrow = 1 }
}; };
rootVisualElement.Add(graphView); rootVisualElement.Add(graphView);

View File

@ -4,16 +4,16 @@ using UnityEngine.UIElements;
namespace AsmdefGraph.Editor { namespace AsmdefGraph.Editor {
public class AsmdefGraphView : GraphView { public class AsmdefGraphView : GraphView {
public AsmdefGraphView() : base() { public AsmdefGraphView(IEnumerable<string> asmdefs) : base() {
// zoom可能に // zoom可能に
SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale); SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);
// 背景を黒に // 背景を黒に
Insert(0, new GridBackground()); Insert(0, new GridBackground());
// ドラッグによる移動可能に // ドラッグによる移動可能に
this.AddManipulator(new SelectionDragger()); this.AddManipulator(new SelectionDragger());
AddElement(new AsmdefNode()); foreach (var asmdef in asmdefs) {
AddElement(new AsmdefNode()); AddElement(new AsmdefNode(asmdef));
AddElement(new AsmdefNode()); }
} }
public override List<Port> GetCompatiblePorts(Port startAnchor, NodeAdapter nodeAdapter) { public override List<Port> GetCompatiblePorts(Port startAnchor, NodeAdapter nodeAdapter) {

View File

@ -2,8 +2,8 @@
namespace AsmdefGraph.Editor { namespace AsmdefGraph.Editor {
public class AsmdefNode : Node { public class AsmdefNode : Node {
public AsmdefNode() { public AsmdefNode(string nodeName) {
title = "AsmdefNode"; title = nodeName;
var inputPort = Port.Create<Edge>(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, typeof(Port)); var inputPort = Port.Create<Edge>(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, typeof(Port));
inputPort.portName = "In"; inputPort.portName = "In";