parse asmdef
This commit is contained in:
parent
5d1e920f84
commit
61df3a4bb2
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "AsmdefGraph"
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6f2ba0cedcb8c3b47a21d0d0a4e78efe
|
|
||||||
AssemblyDefinitionImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,6 +1,10 @@
|
|||||||
namespace AsmdefGraph.Editor {
|
namespace AsmdefGraph.Editor {
|
||||||
public class Asmdef {
|
public class Asmdef {
|
||||||
public string Name;
|
public string name;
|
||||||
public string[] Asmdefs;
|
public string[] references;
|
||||||
|
public Asmdef() {
|
||||||
|
name = "";
|
||||||
|
references = new string[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
Assets/AsmdefGraph/Editor/Scripts/AsmdefFile.cs
Normal file
30
Assets/AsmdefGraph/Editor/Scripts/AsmdefFile.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace AsmdefGraph.Editor {
|
||||||
|
public class AsmdefFile {
|
||||||
|
public string FilePath { set; get; }
|
||||||
|
public string Guid { set; get; }
|
||||||
|
public Asmdef Content { set; get; }
|
||||||
|
public AsmdefFile() {
|
||||||
|
FilePath = "";
|
||||||
|
Guid = "";
|
||||||
|
Content = new Asmdef();
|
||||||
|
}
|
||||||
|
public bool LoadFromPath(string fullPath, string assetPath) {
|
||||||
|
FilePath = fullPath;
|
||||||
|
Guid = AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
|
var json = File.ReadAllText(fullPath);
|
||||||
|
if (string.IsNullOrEmpty(json)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Content = JsonUtility.FromJson<Asmdef>(json);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public IEnumerable<string> Guids =>
|
||||||
|
Content.references.Where(x => !string.IsNullOrEmpty(x)).Select(x => x.Replace("GUID:", ""));
|
||||||
|
}
|
||||||
|
}
|
11
Assets/AsmdefGraph/Editor/Scripts/AsmdefFile.cs.meta
Normal file
11
Assets/AsmdefGraph/Editor/Scripts/AsmdefFile.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ad4bbaa3b7aa9cd439fe68c352f6868c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
|||||||
using System.IO;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.IO;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
namespace AsmdefGraph.Editor {
|
namespace AsmdefGraph.Editor {
|
||||||
@ -10,14 +10,19 @@ namespace AsmdefGraph.Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable() {
|
void OnEnable() {
|
||||||
|
var asmdefs = new List<AsmdefFile>();
|
||||||
|
var projectPath = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
|
||||||
// プロジェクトのasmdefを全検索
|
// プロジェクトのasmdefを全検索
|
||||||
var asmdefs = Directory.EnumerateFiles(
|
var fullPathes = Directory.EnumerateFiles(projectPath, "*.asmdef", SearchOption.AllDirectories);
|
||||||
Directory.GetCurrentDirectory(), "*.asmdef", SearchOption.AllDirectories);
|
// asmdefの内容取得
|
||||||
var asmdefNames = asmdefs
|
foreach (var fullPath in fullPathes) {
|
||||||
.Select(x => x.Split('\\').LastOrDefault())
|
var assetPath = fullPath.Replace(projectPath, "");
|
||||||
.Select(x => x.Replace(".asmdef", ""))
|
var asmdef = new AsmdefFile();
|
||||||
.Where(x => !string.IsNullOrEmpty(x));
|
asmdef.LoadFromPath(fullPath, assetPath);
|
||||||
var graphView = new AsmdefGraphView(asmdefNames) {
|
asmdefs.Add(asmdef);
|
||||||
|
}
|
||||||
|
// viewの作成
|
||||||
|
var graphView = new AsmdefGraphView(asmdefs) {
|
||||||
style = { flexGrow = 1 }
|
style = { flexGrow = 1 }
|
||||||
};
|
};
|
||||||
rootVisualElement.Add(graphView);
|
rootVisualElement.Add(graphView);
|
||||||
|
@ -4,7 +4,7 @@ using UnityEngine.UIElements;
|
|||||||
|
|
||||||
namespace AsmdefGraph.Editor {
|
namespace AsmdefGraph.Editor {
|
||||||
public class AsmdefGraphView : GraphView {
|
public class AsmdefGraphView : GraphView {
|
||||||
public AsmdefGraphView(IEnumerable<string> asmdefs) : base() {
|
public AsmdefGraphView(IEnumerable<AsmdefFile> asmdefs) : base() {
|
||||||
// zoom可能に
|
// zoom可能に
|
||||||
SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);
|
SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);
|
||||||
// 背景を黒に
|
// 背景を黒に
|
||||||
@ -12,7 +12,7 @@ namespace AsmdefGraph.Editor {
|
|||||||
// ドラッグによる移動可能に
|
// ドラッグによる移動可能に
|
||||||
this.AddManipulator(new SelectionDragger());
|
this.AddManipulator(new SelectionDragger());
|
||||||
foreach (var asmdef in asmdefs) {
|
foreach (var asmdef in asmdefs) {
|
||||||
AddElement(new AsmdefNode(asmdef));
|
AddElement(new AsmdefNode(asmdef.Content.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefGraph.Example"
|
"name": "AsmdefGraph.Example",
|
||||||
|
"references": [
|
||||||
|
"GUID:2bafac87e7f4b9b418d9448d219b01ab"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
}
|
}
|
@ -1,3 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefGraph.Example.Fuga"
|
"name": "AsmdefGraph.Example.Fuga",
|
||||||
|
"references": [
|
||||||
|
"GUID:4326ab8b7972b7c4abe4e28df1a1c005",
|
||||||
|
"GUID:119b4cf3f63d4c84d920ceae3917f02c"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
}
|
}
|
@ -1,3 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefGraph.Example.Hoge"
|
"name": "AsmdefGraph.Example.Hoge",
|
||||||
|
"references": [
|
||||||
|
"GUID:4326ab8b7972b7c4abe4e28df1a1c005"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
}
|
}
|
@ -1,6 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefGraph.Example.Piyo",
|
"name": "AsmdefGraph.Example.Piyo",
|
||||||
"references": [],
|
"references": [
|
||||||
|
"GUID:4326ab8b7972b7c4abe4e28df1a1c005",
|
||||||
|
"GUID:119b4cf3f63d4c84d920ceae3917f02c",
|
||||||
|
"GUID:56e14997241bc0d4796fc4e693fcc806"
|
||||||
|
],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
"allowUnsafeCode": false,
|
"allowUnsafeCode": false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user