Compare commits
No commits in common. "master" and "0.0.1" have entirely different histories.
@ -1,42 +0,0 @@
|
|||||||
# This file is the top-most EditorConfig file
|
|
||||||
root = true
|
|
||||||
|
|
||||||
# All Files
|
|
||||||
[*]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
# CSharp formatting settings:
|
|
||||||
[*.cs]
|
|
||||||
csharp_new_line_before_open_brace = none
|
|
||||||
csharp_new_line_before_else = false
|
|
||||||
csharp_new_line_before_catch = false
|
|
||||||
csharp_new_line_before_finally = false
|
|
||||||
csharp_new_line_before_members_in_object_initializers = false
|
|
||||||
csharp_new_line_before_members_in_anonymous_types = false
|
|
||||||
csharp_new_line_between_query_expression_clauses = false
|
|
||||||
|
|
||||||
csharp_indent_case_contents = true
|
|
||||||
csharp_indent_switch_labels = false
|
|
||||||
csharp_indent_labels = no_change
|
|
||||||
|
|
||||||
csharp_space_after_cast = false
|
|
||||||
csharp_space_after_keywords_in_control_flow_statements = true
|
|
||||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
|
||||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
|
||||||
csharp_space_between_parentheses = false
|
|
||||||
csharp_space_before_colon_in_inheritance_clause = true
|
|
||||||
csharp_space_after_colon_in_inheritance_clause = true
|
|
||||||
csharp_space_around_binary_operators = before_and_after
|
|
||||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
|
||||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
|
||||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
|
||||||
csharp_space_after_comma = true
|
|
||||||
csharp_space_after_dot = false
|
|
||||||
|
|
||||||
csharp_preserve_single_line_statements = true
|
|
||||||
csharp_preserve_single_line_blocks = true
|
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,7 +17,6 @@
|
|||||||
# /[Aa]ssets/AssetStoreTools*
|
# /[Aa]ssets/AssetStoreTools*
|
||||||
|
|
||||||
# Autogenerated Jetbrains Rider plugin
|
# Autogenerated Jetbrains Rider plugin
|
||||||
.idea/
|
|
||||||
[Aa]ssets/Plugins/Editor/JetBrains*
|
[Aa]ssets/Plugins/Editor/JetBrains*
|
||||||
|
|
||||||
# Visual Studio cache directory
|
# Visual Studio cache directory
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefHelper.CustomCreate.Editor",
|
"name": "AsmdefGraph.Editor",
|
||||||
"references": [],
|
"references": [],
|
||||||
"includePlatforms": [
|
"includePlatforms": [
|
||||||
"Editor"
|
"Editor"
|
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 7c50ab7221a3bee42bdce89ef8e44090
|
guid: 44786ea3be4b7284ea613b1e7aafc4ad
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
13
Assets/AsmdefGraph/Editor/Scripts/AsmdefDependency.cs
Normal file
13
Assets/AsmdefGraph/Editor/Scripts/AsmdefDependency.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AsmdefGraph.Editor {
|
||||||
|
public class AsmdefDependency {
|
||||||
|
public string DependsFrom { get; }
|
||||||
|
public IEnumerable<string> DependsTo { get; }
|
||||||
|
|
||||||
|
public AsmdefDependency(string key, IEnumerable<string> value) {
|
||||||
|
DependsFrom = key;
|
||||||
|
DependsTo = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 283e87eb30e41c0469f52bd068dbb487
|
guid: de8afe620d6667940a15a8871781c62d
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
32
Assets/AsmdefGraph/Editor/Scripts/AsmdefGraphEditorWindow.cs
Normal file
32
Assets/AsmdefGraph/Editor/Scripts/AsmdefGraphEditorWindow.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.Compilation;
|
||||||
|
|
||||||
|
namespace AsmdefGraph.Editor {
|
||||||
|
public class AsmdefGraphEditorWindow : EditorWindow {
|
||||||
|
[MenuItem("Window/Open Asmdef Graph Window")]
|
||||||
|
public static void Open() {
|
||||||
|
GetWindow<AsmdefGraphEditorWindow>("AsmdefGraphWindow");
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnEnable() {
|
||||||
|
// .asmdefをすべて取得
|
||||||
|
var asmdefs = CompilationPipeline.GetAssemblies();
|
||||||
|
var allDependencies = new List<AsmdefDependency>();
|
||||||
|
foreach (var asmdef in asmdefs) {
|
||||||
|
allDependencies.Add(
|
||||||
|
new AsmdefDependency(
|
||||||
|
asmdef.name,
|
||||||
|
asmdef.assemblyReferences?.Select(x => x.name) ?? new string[0])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// viewの作成
|
||||||
|
var graphView = new AsmdefGraphView(allDependencies) {
|
||||||
|
style = { flexGrow = 1 }
|
||||||
|
};
|
||||||
|
rootVisualElement.Add(graphView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
Assets/AsmdefGraph/Editor/Scripts/AsmdefGraphView.cs
Normal file
42
Assets/AsmdefGraph/Editor/Scripts/AsmdefGraphView.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor.Experimental.GraphView;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace AsmdefGraph.Editor {
|
||||||
|
public class AsmdefGraphView : GraphView {
|
||||||
|
public AsmdefGraphView(IEnumerable<AsmdefDependency> asmdefs) : base() {
|
||||||
|
// zoom可能に
|
||||||
|
SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);
|
||||||
|
// 背景を黒に
|
||||||
|
Insert(0, new GridBackground());
|
||||||
|
// ドラッグによる移動可能に
|
||||||
|
this.AddManipulator(new SelectionDragger());
|
||||||
|
// ノードの追加
|
||||||
|
var asmdefNodeDict = new Dictionary<string, AsmdefNode>();
|
||||||
|
foreach (var asmdef in asmdefs) {
|
||||||
|
var node = new AsmdefNode(asmdef.DependsFrom);
|
||||||
|
AddElement(node);
|
||||||
|
asmdefNodeDict.Add(node.title, node);
|
||||||
|
}
|
||||||
|
// 依存先にラインを追加
|
||||||
|
var nodeApapter = new NodeAdapter();
|
||||||
|
foreach (var asmdef in asmdefs) {
|
||||||
|
if (!asmdefNodeDict.TryGetValue(asmdef.DependsFrom, out var fromNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach (var dependents in asmdef.DependsTo) {
|
||||||
|
if (!asmdefNodeDict.TryGetValue(dependents, out var toNode)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var edge = fromNode.OutPort.ConnectTo(toNode.InPort);
|
||||||
|
contentContainer.Add(edge);// これが無いと線が表示されない
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override List<Port> GetCompatiblePorts(Port startAnchor, NodeAdapter nodeAdapter) {
|
||||||
|
return ports.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
Assets/AsmdefGraph/Editor/Scripts/AsmdefNode.cs
Normal file
20
Assets/AsmdefGraph/Editor/Scripts/AsmdefNode.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using UnityEditor.Experimental.GraphView;
|
||||||
|
|
||||||
|
namespace AsmdefGraph.Editor {
|
||||||
|
public class AsmdefNode : Node {
|
||||||
|
public readonly Port InPort;
|
||||||
|
public readonly Port OutPort;
|
||||||
|
|
||||||
|
public AsmdefNode(string nodeName) {
|
||||||
|
title = nodeName;
|
||||||
|
|
||||||
|
InPort = Port.Create<Edge>(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, typeof(Port));
|
||||||
|
InPort.portName = "In";
|
||||||
|
inputContainer.Add(InPort);
|
||||||
|
|
||||||
|
OutPort = Port.Create<Edge>(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, typeof(Port));
|
||||||
|
OutPort.portName = "Out";
|
||||||
|
outputContainer.Add(OutPort);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefHelper.Example",
|
"name": "AsmdefGraph.Example",
|
||||||
"references": [],
|
"references": [
|
||||||
|
"GUID:2bafac87e7f4b9b418d9448d219b01ab"
|
||||||
|
],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
"allowUnsafeCode": false,
|
"allowUnsafeCode": false,
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefHelper.Example.Fuga",
|
"name": "AsmdefGraph.Example.Fuga",
|
||||||
"references": [
|
"references": [
|
||||||
"GUID:4326ab8b7972b7c4abe4e28df1a1c005",
|
"GUID:4326ab8b7972b7c4abe4e28df1a1c005",
|
||||||
"GUID:119b4cf3f63d4c84d920ceae3917f02c"
|
"GUID:119b4cf3f63d4c84d920ceae3917f02c"
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AsmdefHelper.Example.Fuga {
|
namespace AsmdefGraph.Example.Fuga {
|
||||||
public class NewBehaviourScript : MonoBehaviour {
|
public class NewBehaviourScript : MonoBehaviour {
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start() {
|
void Start() {
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefHelper.Example.Hoge",
|
"name": "AsmdefGraph.Example.Hoge",
|
||||||
"references": [
|
"references": [
|
||||||
"GUID:4326ab8b7972b7c4abe4e28df1a1c005"
|
"GUID:4326ab8b7972b7c4abe4e28df1a1c005"
|
||||||
],
|
],
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AsmdefHelper.Example.Hoge {
|
namespace AsmdefGraph.Example.Hoge {
|
||||||
public class NewBehaviourScript : MonoBehaviour {
|
public class NewBehaviourScript : MonoBehaviour {
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start() {
|
void Start() {
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AsmdefHelper.Example {
|
namespace AsmdefGraph.Example {
|
||||||
public class NewBehaviourScript : MonoBehaviour {
|
public class NewBehaviourScript : MonoBehaviour {
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start() {
|
void Start() {
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "AsmdefHelper.Example.Piyo",
|
"name": "AsmdefGraph.Example.Piyo",
|
||||||
"references": [
|
"references": [
|
||||||
"GUID:4326ab8b7972b7c4abe4e28df1a1c005",
|
"GUID:4326ab8b7972b7c4abe4e28df1a1c005",
|
||||||
"GUID:119b4cf3f63d4c84d920ceae3917f02c",
|
"GUID:119b4cf3f63d4c84d920ceae3917f02c",
|
@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AsmdefHelper.Example.Piyo {
|
namespace AsmdefGraph.Example.Piyo {
|
||||||
public class NewBehaviourScript : MonoBehaviour {
|
public class NewBehaviourScript : MonoBehaviour {
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start() {
|
void Start() {
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 9ed3f50ff47b69749a094043f3dcd4f8
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "AsmdefHelper.CompileLocker.Editor",
|
|
||||||
"references": [
|
|
||||||
"GUID:211243abc45174c45b3a6c275ea126b9"
|
|
||||||
],
|
|
||||||
"includePlatforms": [
|
|
||||||
"Editor"
|
|
||||||
],
|
|
||||||
"excludePlatforms": [],
|
|
||||||
"allowUnsafeCode": false,
|
|
||||||
"overrideReferences": false,
|
|
||||||
"precompiledReferences": [],
|
|
||||||
"autoReferenced": true,
|
|
||||||
"defineConstraints": [],
|
|
||||||
"versionDefines": [],
|
|
||||||
"noEngineReferences": false
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2707709625a3b9144b2a94ff32287781
|
|
||||||
AssemblyDefinitionImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,27 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// original from: https://gist.github.com/decoc/bde047ac7ad8c9bfce7eb408f2712424
|
|
||||||
/// This editor utility can lock/unlock unity script compile from menu item.
|
|
||||||
/// See more https://raspberly.hateblo.jp/entry/InvalidateUnityCompile
|
|
||||||
/// </summary>
|
|
||||||
namespace AsmdefHelper.CompileLocker.Editor {
|
|
||||||
public static class CompileLocker {
|
|
||||||
const string menuPath = "AsmdefHelper/Compile Lock";
|
|
||||||
|
|
||||||
[MenuItem(menuPath, false, 1)]
|
|
||||||
static void Lock() {
|
|
||||||
var isLocked = Menu.GetChecked(menuPath);
|
|
||||||
if (isLocked) {
|
|
||||||
Debug.Log("Compile Unlocked");
|
|
||||||
EditorApplication.UnlockReloadAssemblies();
|
|
||||||
Menu.SetChecked(menuPath, false);
|
|
||||||
} else {
|
|
||||||
Debug.Log("Compile Locked");
|
|
||||||
EditorApplication.LockReloadAssemblies();
|
|
||||||
Menu.SetChecked(menuPath, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 9f931a3f0bee3fa40a0a5355ccffb389
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,86 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.CustomCreate.Editor {
|
|
||||||
// original: https://github.com/baba-s/UniAssemblyDefinitionCreator
|
|
||||||
public class AsmdefCustomCreateView : EditorWindow {
|
|
||||||
[MenuItem("Assets/AsmdefHelper/Create custom asmdef")]
|
|
||||||
public static void ShowWindow() {
|
|
||||||
var window = GetWindow<AsmdefCustomCreateView>();
|
|
||||||
window.titleContent = new GUIContent("AsmdefCustomCreateView");
|
|
||||||
window.minSize = new Vector2(200, 200);
|
|
||||||
window.maxSize = new Vector2(2000, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnEnable() {
|
|
||||||
// Each editor window contains a root VisualElement object
|
|
||||||
VisualElement root = rootVisualElement;
|
|
||||||
|
|
||||||
// Import UXML
|
|
||||||
var visualTree =
|
|
||||||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
|
|
||||||
"Assets/AsmdefHelper/CustomCreate/Editor/AsmdefCustomCreateView.uxml");
|
|
||||||
if (visualTree == null) {
|
|
||||||
visualTree =
|
|
||||||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
|
|
||||||
"Packages/dev.n5y.asmdefhelper/AsmdefHelper/CustomCreate/Editor/AsmdefCustomCreateView.uxml");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
VisualElement labelFromUXML = visualTree.Instantiate();
|
|
||||||
#else
|
|
||||||
VisualElement labelFromUXML = visualTree.CloneTree();
|
|
||||||
#endif
|
|
||||||
root.Add(labelFromUXML);
|
|
||||||
|
|
||||||
// UI取得
|
|
||||||
var pathTextField = root.Q<TextField>(className: "PathTextField");
|
|
||||||
var nameTextField = root.Q<TextField>(className: "NameTextField");
|
|
||||||
var allowUnsafeToggle = root.Q<Toggle>(className: "AllowUnsafeToggle");
|
|
||||||
var autoReferencedToggle = root.Q<Toggle>(className: "AutoReferencedToggle");
|
|
||||||
var noEngineReferencesToggle = root.Q<Toggle>(className: "NoEngineReferencesToggle");
|
|
||||||
var overrideReferencesToggle = root.Q<Toggle>(className: "OverrideReferencesToggle");
|
|
||||||
var rootNamespaceTextField = root.Q<TextField>(className: "RootNamespaceTextField");
|
|
||||||
var isEditorToggle = root.Q<Toggle>(className: "IsEditorToggle");
|
|
||||||
var createButton = root.Q<Button>(className: "CreateButton");
|
|
||||||
|
|
||||||
// PathとNameの初期値
|
|
||||||
var asset = Selection.activeObject;
|
|
||||||
var assetPath = AssetDatabase.GetAssetPath(asset);
|
|
||||||
var directory = string.IsNullOrWhiteSpace(assetPath) ? "Assets/" : assetPath;
|
|
||||||
pathTextField.value = directory;
|
|
||||||
var defaultName = directory.Replace("Assets/", "").Replace('/', '.');
|
|
||||||
nameTextField.value = defaultName;
|
|
||||||
|
|
||||||
// RootNamespace が設定できるのは2020.2以降
|
|
||||||
#if UNITY_2020_2_OR_NEWER
|
|
||||||
rootNamespaceTextField.value = defaultName;
|
|
||||||
#else
|
|
||||||
root.Q<Box>(className: "Box").Remove(rootNamespaceTextField);
|
|
||||||
#endif
|
|
||||||
// .asmdefを作成して閉じる
|
|
||||||
createButton.clickable.clicked += () => {
|
|
||||||
var asmdefName = nameTextField.value;
|
|
||||||
var asmdef = new AssemblyDefinitionJson {
|
|
||||||
name = asmdefName,
|
|
||||||
#if UNITY_2020_2_OR_NEWER
|
|
||||||
rootNamespace = rootNamespaceTextField.value,
|
|
||||||
#endif
|
|
||||||
allowUnsafeCode = allowUnsafeToggle.value,
|
|
||||||
autoReferenced = autoReferencedToggle.value,
|
|
||||||
overrideReferences = overrideReferencesToggle.value,
|
|
||||||
noEngineReferences = noEngineReferencesToggle.value,
|
|
||||||
includePlatforms = isEditorToggle.value ? new[] { "Editor" } : new string[0]
|
|
||||||
};
|
|
||||||
var asmdefJson = JsonUtility.ToJson(asmdef, true);
|
|
||||||
var asmdefPath = $"{directory}/{asmdefName}.asmdef";
|
|
||||||
File.WriteAllText(asmdefPath, asmdefJson, Encoding.UTF8);
|
|
||||||
AssetDatabase.Refresh();
|
|
||||||
Close();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 926b0632a73e00a49920d50fa76a5195
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,5 +0,0 @@
|
|||||||
Label {
|
|
||||||
font-size: 20px;
|
|
||||||
-unity-font-style: bold;
|
|
||||||
color: rgb(68, 138, 255);
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: be72726e4ea53eb469f4e77fa6f5bef4
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
disableValidation: 0
|
|
@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<engine:UXML
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:engine="UnityEngine.UIElements"
|
|
||||||
xmlns:editor="UnityEditor.UIElements"
|
|
||||||
xsi:noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd"
|
|
||||||
>
|
|
||||||
<engine:Label class="AsmdefInfo" text="Input your asmdef info"/>
|
|
||||||
<engine:Box class="Box">
|
|
||||||
<engine:TextField class="PathTextField" label="Path" text="ASMDEF_PATH_HERE" readonly="true"/>
|
|
||||||
<engine:TextField class="NameTextField" label="Name" text="ASMDEF_NAME_HERE"/>
|
|
||||||
<engine:Toggle class="AllowUnsafeToggle" label="Allow 'unsafe' Code" value="false"/>
|
|
||||||
<engine:Toggle class="AutoReferencedToggle" label="Auto Referenced" value="true"/>
|
|
||||||
<engine:Toggle class="NoEngineReferencesToggle" label="No Engine References" value="false"/>
|
|
||||||
<engine:Toggle class="OverrideReferencesToggle" label="Override Referenced" value="false"/>
|
|
||||||
<engine:TextField class="RootNamespaceTextField" label="Root Namespace" text="ROOT_NAMESPACE_HERE"/>
|
|
||||||
<engine:Toggle class="IsEditorToggle" label="Is Editor" value="false"/>
|
|
||||||
<engine:Button class="CreateButton" text="Create" />
|
|
||||||
</engine:Box>
|
|
||||||
</engine:UXML>
|
|
@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8dd177060f55cb34e9b13226e7cddccc
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ef8f6755542bf154299235116e58cfab
|
|
||||||
AssemblyDefinitionImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,92 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.CustomCreate.Editor {
|
|
||||||
public class AsmdefRenameView : EditorWindow {
|
|
||||||
static string renameAsmdefPath = "";
|
|
||||||
static string asmdefDirectory = "";
|
|
||||||
|
|
||||||
[MenuItem("Assets/AsmdefHelper/Rename asmdef")]
|
|
||||||
public static void ShowWindow() {
|
|
||||||
// PathとNameの初期値
|
|
||||||
var asset = Selection.activeObject;
|
|
||||||
renameAsmdefPath = AssetDatabase.GetAssetPath(asset);
|
|
||||||
asmdefDirectory = Path.GetDirectoryName(renameAsmdefPath);
|
|
||||||
// asmdefが選択されている時のみ開く
|
|
||||||
var extension = renameAsmdefPath.Split('.').LastOrDefault();
|
|
||||||
if (extension == "asmdef") {
|
|
||||||
var window = GetWindow<AsmdefRenameView>();
|
|
||||||
window.titleContent = new GUIContent("AsmdefRenameView");
|
|
||||||
window.minSize = new Vector2(200, 100);
|
|
||||||
window.maxSize = new Vector2(2000, 100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnEnable() {
|
|
||||||
// Each editor window contains a root VisualElement object
|
|
||||||
VisualElement root = rootVisualElement;
|
|
||||||
|
|
||||||
// Import UXML
|
|
||||||
var visualTree =
|
|
||||||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
|
|
||||||
"Assets/AsmdefHelper/CustomCreate/Editor/AsmdefRenameView.uxml");
|
|
||||||
if (visualTree == null) {
|
|
||||||
visualTree =
|
|
||||||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
|
|
||||||
"Packages/dev.n5y.asmdefhelper/AsmdefHelper/CustomCreate/Editor/AsmdefRenameView.uxml");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
VisualElement labelFromUXML = visualTree.Instantiate();
|
|
||||||
#else
|
|
||||||
VisualElement labelFromUXML = visualTree.CloneTree();
|
|
||||||
#endif
|
|
||||||
root.Add(labelFromUXML);
|
|
||||||
|
|
||||||
// UI取得
|
|
||||||
var pathTextField = root.Q<TextField>(className: "PathTextField");
|
|
||||||
var nameTextField = root.Q<TextField>(className: "NameTextField");
|
|
||||||
var rootNamespaceTextField = root.Q<TextField>(className: "RootNamespaceTextField");
|
|
||||||
var createButton = root.Q<Button>(className: "RenameButton");
|
|
||||||
|
|
||||||
// 既存のasmdef読み込み
|
|
||||||
var orgText = File.ReadAllText(renameAsmdefPath);
|
|
||||||
var asmdef = JsonUtility.FromJson<AssemblyDefinitionJson>(orgText);
|
|
||||||
|
|
||||||
// 既存パラメータの反映
|
|
||||||
pathTextField.value = asmdefDirectory;
|
|
||||||
nameTextField.value = asmdef.name;
|
|
||||||
var asmdefNameOrg = asmdef.name;
|
|
||||||
|
|
||||||
// RootNamespace が設定できるのは2020.2以降
|
|
||||||
#if UNITY_2020_2_OR_NEWER
|
|
||||||
rootNamespaceTextField.value = asmdef.rootNamespace;
|
|
||||||
#else
|
|
||||||
root.Q<Box>(className: "Box").Remove(rootNamespaceTextField);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// .asmdefのnameとファイル名を更新して閉じる
|
|
||||||
createButton.clickable.clicked += () => {
|
|
||||||
var asmdefName = nameTextField.value;
|
|
||||||
asmdef.name = asmdefName;
|
|
||||||
#if UNITY_2020_2_OR_NEWER
|
|
||||||
asmdef.rootNamespace = rootNamespaceTextField.value;
|
|
||||||
#endif
|
|
||||||
var asmdefJson = JsonUtility.ToJson(asmdef, true);
|
|
||||||
var newAsmdefPath = $"{asmdefDirectory}/{asmdefName}.asmdef";
|
|
||||||
// 新asmdef作成
|
|
||||||
File.WriteAllText(newAsmdefPath, asmdefJson, Encoding.UTF8);
|
|
||||||
// ファイル名が変わった場合は旧asmdef削除
|
|
||||||
if (asmdefNameOrg != asmdefName) {
|
|
||||||
FileUtil.DeleteFileOrDirectory(renameAsmdefPath);
|
|
||||||
}
|
|
||||||
AssetDatabase.Refresh();
|
|
||||||
Close();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 9cc99bb7ae3447c29afa7daef6d72347
|
|
||||||
timeCreated: 1603812149
|
|
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<engine:UXML
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:engine="UnityEngine.UIElements"
|
|
||||||
xmlns:editor="UnityEditor.UIElements"
|
|
||||||
xsi:noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd"
|
|
||||||
>
|
|
||||||
<engine:Label class="AsmdefInfo" text="Input your asmdef info"/>
|
|
||||||
<engine:Box>
|
|
||||||
<engine:TextField class="PathTextField" label="Path" text="ASMDEF_PATH_HERE" readonly="true"/>
|
|
||||||
<engine:TextField class="NameTextField" label="Name" text="ASMDEF_NAME_HERE"/>
|
|
||||||
<engine:TextField label="Root Namespace" text="ROOT_NAMESPACE_HERE" class="RootNamespaceTextField" />
|
|
||||||
<engine:Button class="RenameButton" text="Rename" />
|
|
||||||
</engine:Box>
|
|
||||||
</engine:UXML>
|
|
@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 72a349d5d05ba6c4db6d137a4bc54b01
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
@ -1,18 +0,0 @@
|
|||||||
namespace AsmdefHelper.CustomCreate.Editor {
|
|
||||||
public class AssemblyDefinitionJson {
|
|
||||||
public string name = string.Empty;
|
|
||||||
#if UNITY_2020_2_OR_NEWER
|
|
||||||
public string rootNamespace = string.Empty;
|
|
||||||
#endif
|
|
||||||
public string[] references = new string[0];
|
|
||||||
public string[] includePlatforms = new string[0];
|
|
||||||
public string[] excludePlatforms = new string[0];
|
|
||||||
public bool allowUnsafeCode = false;
|
|
||||||
public bool overrideReferences = false;
|
|
||||||
public string[] precompiledReferences = new string[0];
|
|
||||||
public bool autoReferenced = false;
|
|
||||||
public string[] defineConstraints = new string[0];
|
|
||||||
public string[] versionDefines = new string[0];
|
|
||||||
public bool noEngineReferences = false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0364ec00ec0f6a2448715767f1e1441f
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,40 +0,0 @@
|
|||||||
using UnityEditor;
|
|
||||||
using UnityEditor.Compilation;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public class AsmdefGraphEditorWindow : EditorWindow, IToggleCheckDelegate {
|
|
||||||
static AsmdefSelectionView selectionWindow;
|
|
||||||
AsmdefGraphView graphView;
|
|
||||||
|
|
||||||
[MenuItem("AsmdefHelper/Open DependencyGraph", priority = 2000)]
|
|
||||||
public static void Open() {
|
|
||||||
GetWindow<AsmdefGraphEditorWindow>("Asmdef Dependency");
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnEnable() {
|
|
||||||
// .asmdefをすべて取得
|
|
||||||
var asmdefs = CompilationPipeline.GetAssemblies();
|
|
||||||
// viewの作成
|
|
||||||
graphView = new AsmdefGraphView(asmdefs) {
|
|
||||||
style = { flexGrow = 1 }
|
|
||||||
};
|
|
||||||
rootVisualElement.Add(graphView);
|
|
||||||
|
|
||||||
// 選択ウィンドウも作成
|
|
||||||
selectionWindow = GetWindow<AsmdefSelectionView>("Asmdef Selection");
|
|
||||||
selectionWindow.SetAsmdef(asmdefs, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 片方を閉じる
|
|
||||||
void OnDestroy() {
|
|
||||||
if (selectionWindow != null) {
|
|
||||||
selectionWindow.Close();
|
|
||||||
}
|
|
||||||
selectionWindow = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IToggleCheckDelegate.OnSelectionChanged(string label, bool isChecked) {
|
|
||||||
graphView.SetNodeVisibility(label, isChecked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using AsmdefHelper.DependencyGraph.Editor.DependencyNode;
|
|
||||||
using AsmdefHelper.DependencyGraph.Editor.DependencyNode.Sort;
|
|
||||||
using AsmdefHelper.DependencyGraph.Editor.NodeView;
|
|
||||||
using UnityEditor.Compilation;
|
|
||||||
using UnityEditor.Experimental.GraphView;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public sealed class AsmdefGraphView : GraphView {
|
|
||||||
readonly Dictionary<string, IAsmdefNodeView> asmdefNodeDict;
|
|
||||||
public AsmdefGraphView(IEnumerable<Assembly> assemblies) {
|
|
||||||
var assemblyArr = assemblies.ToArray();
|
|
||||||
// zoom可能に
|
|
||||||
SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);
|
|
||||||
// 背景を黒に
|
|
||||||
Insert(0, new GridBackground());
|
|
||||||
// ドラッグによる移動可能に
|
|
||||||
this.AddManipulator(new SelectionDragger());
|
|
||||||
// ドラッグで描画範囲を動かせるように
|
|
||||||
this.AddManipulator(new ContentDragger());
|
|
||||||
// ノードの追加
|
|
||||||
asmdefNodeDict = new Dictionary<string, IAsmdefNodeView>();
|
|
||||||
foreach (var asm in assemblyArr) {
|
|
||||||
var node = new AsmdefNode(asm.name, contentContainer);
|
|
||||||
AddElement(node);
|
|
||||||
asmdefNodeDict.Add(node.title, node);
|
|
||||||
}
|
|
||||||
// 依存の整理
|
|
||||||
var nodeProfiles = assemblyArr
|
|
||||||
.Select((x, i) => new NodeProfile(new NodeId(i), x.name))
|
|
||||||
.ToDictionary(x => x.Name);
|
|
||||||
var dependencies = new List<IDependencyNode>(nodeProfiles.Count);
|
|
||||||
// 依存先の設定
|
|
||||||
foreach (var asm in assemblyArr) {
|
|
||||||
if (nodeProfiles.TryGetValue(asm.name, out var profile)) {
|
|
||||||
var requireProfiles = asm.assemblyReferences
|
|
||||||
.Where(x => nodeProfiles.ContainsKey(x.name))
|
|
||||||
.Select(x => nodeProfiles[x.name]);
|
|
||||||
var dep = new HashSetDependencyNode(profile);
|
|
||||||
dep.SetRequireNodes(requireProfiles);
|
|
||||||
dependencies.Add(dep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 依存元の設定
|
|
||||||
NodeProcessor.SetBeRequiredNodes(dependencies);
|
|
||||||
|
|
||||||
// 依存先にのみラインを追加
|
|
||||||
foreach (var dep in dependencies) {
|
|
||||||
if (!asmdefNodeDict.TryGetValue(dep.Profile.Name, out var fromNode)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
foreach (var dest in dep.Destinations) {
|
|
||||||
if (!asmdefNodeDict.TryGetValue(dest.Name, out var toNode)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
fromNode.RightPort.Connect(toNode.LeftPort);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Portに接続数を追記
|
|
||||||
foreach (var dep in dependencies) {
|
|
||||||
if (asmdefNodeDict.TryGetValue(dep.Profile.Name, out var node)) {
|
|
||||||
node.LeftPort.Label = $"RefBy({dep.Sources.Count})";
|
|
||||||
node.RightPort.Label = $"RefTo({dep.Destinations.Count})";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ノードの場所を整列
|
|
||||||
var sortStrategy = new AlignSortStrategy(AlignParam.Default(), Vector2.zero);
|
|
||||||
var sortedNode = sortStrategy.Sort(dependencies);
|
|
||||||
foreach (var node in sortedNode) {
|
|
||||||
if (asmdefNodeDict.TryGetValue(node.Profile.Name, out var nodeView)) {
|
|
||||||
nodeView.SetPositionXY(node.Position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetNodeVisibility(string nodeName, bool visible_) {
|
|
||||||
if (asmdefNodeDict.TryGetValue(nodeName, out var node)) {
|
|
||||||
node.Visibility = visible_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override List<Port> GetCompatiblePorts(Port startAnchor, NodeAdapter nodeAdapter) {
|
|
||||||
return ports.ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "AsmdefHelper.DependencyGraph.Editor",
|
|
||||||
"references": [],
|
|
||||||
"includePlatforms": [
|
|
||||||
"Editor"
|
|
||||||
],
|
|
||||||
"excludePlatforms": [],
|
|
||||||
"allowUnsafeCode": false,
|
|
||||||
"overrideReferences": false,
|
|
||||||
"precompiledReferences": [],
|
|
||||||
"autoReferenced": true,
|
|
||||||
"defineConstraints": [],
|
|
||||||
"versionDefines": [],
|
|
||||||
"noEngineReferences": false
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
using AsmdefHelper.DependencyGraph.Editor.NodeView;
|
|
||||||
using UnityEditor.Experimental.GraphView;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public class AsmdefNode : UiElementsNodeView, IAsmdefNodeView {
|
|
||||||
readonly GraphViewPort leftPort;
|
|
||||||
readonly GraphViewPort rightPort;
|
|
||||||
public IPort LeftPort => leftPort;
|
|
||||||
public IPort RightPort => rightPort;
|
|
||||||
|
|
||||||
public AsmdefNode(string nodeName, VisualElement parentContentContainer) {
|
|
||||||
Label = nodeName;
|
|
||||||
|
|
||||||
leftPort = new GraphViewPort(parentContentContainer, Direction.Input) { Label = "Ref By" };
|
|
||||||
inputContainer.Add(LeftPort as Port); // as right side
|
|
||||||
|
|
||||||
rightPort = new GraphViewPort(parentContentContainer, Direction.Output) { Label = "Ref To" };
|
|
||||||
outputContainer.Add(RightPort as Port); // as left side
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Visibility {
|
|
||||||
get => base.Visibility;
|
|
||||||
set {
|
|
||||||
base.Visibility = value;
|
|
||||||
// right(output)
|
|
||||||
foreach (var edge in rightPort.connections) {
|
|
||||||
edge.visible = edge.input.node.visible & visible;
|
|
||||||
}
|
|
||||||
// left(input)
|
|
||||||
foreach (var edge in leftPort.connections) {
|
|
||||||
edge.visible = edge.output.node.visible & visible;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 686371b55f14bdb4ca1a0ee236361071
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,124 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AsmdefHelper.DependencyGraph.Editor.DependencyNode;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEditor.Compilation;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public class AsmdefSelectionView : EditorWindow {
|
|
||||||
const int toggleCount = 1000;
|
|
||||||
static EditorWindow graphWindow;
|
|
||||||
readonly ToggleDict groupMasterToggleDict = new ToggleDict();
|
|
||||||
readonly ToggleDict toggleDict = new ToggleDict();
|
|
||||||
IToggleCheckDelegate toggleDelegate;
|
|
||||||
|
|
||||||
public void OnEnable() {
|
|
||||||
graphWindow = GetWindow<AsmdefGraphEditorWindow>();
|
|
||||||
|
|
||||||
// Each editor window contains a root VisualElement object
|
|
||||||
VisualElement root = rootVisualElement;
|
|
||||||
|
|
||||||
// Import UXML
|
|
||||||
var visualTree =
|
|
||||||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
|
|
||||||
"Assets/AsmdefHelper/DependencyGraph/Editor/AsmdefSelectionView/AsmdefSelectionView.uxml");
|
|
||||||
if (visualTree == null) {
|
|
||||||
visualTree =
|
|
||||||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
|
|
||||||
"Packages/dev.n5y.asmdefhelper/AsmdefHelper/DependencyGraph/Editor/AsmdefSelectionView/AsmdefSelectionView.uxml");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
VisualElement labelFromUXML = visualTree.Instantiate();
|
|
||||||
#else
|
|
||||||
VisualElement labelFromUXML = visualTree.CloneTree();
|
|
||||||
#endif
|
|
||||||
root.Add(labelFromUXML);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAsmdef(Assembly[] assemblies, IToggleCheckDelegate toggleDelegate_) {
|
|
||||||
var sortedAssemblies = assemblies.OrderBy(x => x.name).ToArray();
|
|
||||||
var scrollView = rootVisualElement.Q<ScrollView>(className: "ScrollView");
|
|
||||||
toggleDict.Clear();
|
|
||||||
for (var i = 0; i < toggleCount; i++) {
|
|
||||||
var toggle = rootVisualElement.Q<Toggle>(className: $"toggle{i}");
|
|
||||||
if (i < sortedAssemblies.Length) {
|
|
||||||
var assemblyName = sortedAssemblies[i].name;
|
|
||||||
toggle.text = assemblyName;
|
|
||||||
toggle.value = true;
|
|
||||||
toggleDict.Add(assemblyName, new UiElementToggle(toggle));
|
|
||||||
} else {
|
|
||||||
scrollView.Remove(toggle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// グループに分ける
|
|
||||||
var group = new DomainGroup();
|
|
||||||
group.Create(sortedAssemblies.Select(x => x.name));
|
|
||||||
var tops = group.GetTopDomainsWithSomeSubDomains().ToArray();
|
|
||||||
foreach (var top in tops) {
|
|
||||||
var topToggle = new Toggle { text = top, value = true};
|
|
||||||
var slaveToggles = new List<IToggle>();
|
|
||||||
Toggle firstToggle = null;
|
|
||||||
var domains = group.GetSubDomains(top);
|
|
||||||
foreach (var domain in domains) {
|
|
||||||
var isLast = domains.Last() == domain;
|
|
||||||
if (toggleDict.TryGetToggle(domain.FullName, out var toggle)) {
|
|
||||||
var keisen = isLast ? "└" : "├";
|
|
||||||
toggle.Name = domain.HasSubDomain() ? $"{keisen} {domain.SubDomain}" : toggle.Name;
|
|
||||||
slaveToggles.Add(toggle);
|
|
||||||
if (firstToggle == null && toggle is UiElementToggle y) {
|
|
||||||
firstToggle = y.Toggle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var toggleGroup = new ToggleGroup(new UiElementToggle(topToggle), slaveToggles);
|
|
||||||
if (firstToggle != null) {
|
|
||||||
var index = scrollView.IndexOf(firstToggle);
|
|
||||||
// グループに属する toggle は box に入れる
|
|
||||||
var box = new Box();
|
|
||||||
scrollView.Insert(index, topToggle);
|
|
||||||
scrollView.Insert(index + 1, box);
|
|
||||||
foreach (var slaveToggle in slaveToggles) {
|
|
||||||
if (slaveToggle is UiElementToggle x) {
|
|
||||||
box.Add(x.Toggle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
groupMasterToggleDict.Add(top, toggleGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleDelegate = toggleDelegate_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnGUI() {
|
|
||||||
// toggle の更新を監視 (onValueChangedが無さそう)
|
|
||||||
// ToggleGroup の長
|
|
||||||
var updatedGroups = groupMasterToggleDict.ScanUpdate().ToArray();
|
|
||||||
groupMasterToggleDict.OverwriteToggles(updatedGroups.Select(x => x.Item1));
|
|
||||||
// 普通の Toggle達
|
|
||||||
var updated = toggleDict.ScanUpdate().ToArray();
|
|
||||||
foreach (var x in updated) {
|
|
||||||
var (key, current) = x;
|
|
||||||
toggleDelegate?.OnSelectionChanged(key, current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 片方を閉じる
|
|
||||||
async void OnDestroy() {
|
|
||||||
// 同フレームで OnDestroy を呼ぶと警告が出るので遅延実行
|
|
||||||
await Task.Delay(1);
|
|
||||||
if (graphWindow != null) {
|
|
||||||
graphWindow.Close();
|
|
||||||
}
|
|
||||||
graphWindow = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 69bee09693f54d46954fb60401f58b66
|
|
||||||
timeCreated: 1606312787
|
|
@ -1,5 +0,0 @@
|
|||||||
Label {
|
|
||||||
font-size: 20px;
|
|
||||||
-unity-font-style: bold;
|
|
||||||
color: rgb(68, 138, 255);
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7906d8f1d4e539745bf53fba8fc20d3a
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
disableValidation: 0
|
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 24d749776c208f4408be0cfccb02d1c7
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
@ -1,6 +0,0 @@
|
|||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public interface IToggle {
|
|
||||||
bool IsOn { set; get; }
|
|
||||||
string Name { set; get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 4f8c1aea6924490e9d1f3745569b7c03
|
|
||||||
timeCreated: 1606663328
|
|
@ -1,5 +0,0 @@
|
|||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public interface IToggleCheckDelegate {
|
|
||||||
void OnSelectionChanged(string label, bool isChecked);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0c48da7c3f95419cbfc95c4ec2816489
|
|
||||||
timeCreated: 1606313215
|
|
@ -1,58 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public class ToggleDict {
|
|
||||||
class TogglePair {
|
|
||||||
public bool prevToggleValue;
|
|
||||||
public readonly IToggle toggle;
|
|
||||||
|
|
||||||
public TogglePair(IToggle toggle) {
|
|
||||||
this.toggle = toggle;
|
|
||||||
prevToggleValue = toggle.IsOn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly IDictionary<string, TogglePair> dict;
|
|
||||||
|
|
||||||
public ToggleDict() {
|
|
||||||
dict = new Dictionary<string, TogglePair>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(string key, IToggle toggle) {
|
|
||||||
dict.Add(key, new TogglePair(toggle));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<(string, bool)> ScanUpdate() {
|
|
||||||
return dict
|
|
||||||
.Where(x => x.Value.prevToggleValue != x.Value.toggle.IsOn)
|
|
||||||
.Select(x => {
|
|
||||||
// 更新も行う
|
|
||||||
dict[x.Key].prevToggleValue = x.Value.toggle.IsOn;
|
|
||||||
return (x.Key, x.Value.toggle.IsOn);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OverwriteToggles(IEnumerable<string> updateKeys) {
|
|
||||||
// UI 上の Toggle の check が変わってもisOnには反映されないのでここで設定
|
|
||||||
foreach (var keys in updateKeys) {
|
|
||||||
var val = dict[keys];
|
|
||||||
val.toggle.IsOn = val.toggle.IsOn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryGetToggle(string key, out IToggle toggle) {
|
|
||||||
if (dict.TryGetValue(key, out var x)) {
|
|
||||||
toggle = x.toggle;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle = default;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Clear() {
|
|
||||||
dict.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8725d14bce6043b387ea7f0361a56750
|
|
||||||
timeCreated: 1606747756
|
|
@ -1,28 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public class ToggleGroup : IToggle {
|
|
||||||
readonly IToggle masterToggle;
|
|
||||||
readonly IEnumerable<IToggle> slaveToggles;
|
|
||||||
|
|
||||||
public ToggleGroup(IToggle masterToggle, IEnumerable<IToggle> slaveToggles) {
|
|
||||||
this.masterToggle = masterToggle;
|
|
||||||
this.slaveToggles = slaveToggles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name {
|
|
||||||
get => masterToggle.Name;
|
|
||||||
set => masterToggle.Name = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsOn {
|
|
||||||
get => masterToggle.IsOn;
|
|
||||||
set {
|
|
||||||
masterToggle.IsOn = value;
|
|
||||||
foreach (var toggle in slaveToggles) {
|
|
||||||
toggle.IsOn = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5308ff649752450ba423e8ce799f2048
|
|
||||||
timeCreated: 1606663303
|
|
@ -1,10 +0,0 @@
|
|||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor {
|
|
||||||
public class UiElementToggle : IToggle {
|
|
||||||
public readonly Toggle Toggle;
|
|
||||||
public UiElementToggle(Toggle toggle) => Toggle = toggle;
|
|
||||||
public string Name { get => Toggle.text; set => Toggle.text = value; }
|
|
||||||
public bool IsOn { get => Toggle.value; set => Toggle.value = value; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: faa82404bed34442b46aceb699aa2fd6
|
|
||||||
timeCreated: 1606663359
|
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: bbaa68e4da2746ed9af5d76e173b5e8c
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,67 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
|
||||||
public class DomainGroup {
|
|
||||||
readonly Dictionary<string, List<DomainUnit>> dict;
|
|
||||||
|
|
||||||
public DomainGroup() {
|
|
||||||
dict = new Dictionary<string, List<DomainUnit>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Create(IEnumerable<string> all) {
|
|
||||||
dict.Clear();
|
|
||||||
foreach (var str in all) {
|
|
||||||
var unit = new DomainUnit(str, '.');
|
|
||||||
if (!unit.HasSubDomain()) {
|
|
||||||
unit = new DomainUnit(str, '-');
|
|
||||||
}
|
|
||||||
if (!unit.HasSubDomain()) {
|
|
||||||
unit = new DomainUnit(str, '_');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unit.HasSubDomain()) {
|
|
||||||
dict.Add(unit.FullName, new List<DomainUnit> { unit });
|
|
||||||
} else {
|
|
||||||
if (dict.TryGetValue(unit.TopDomain, out var list)) {
|
|
||||||
list.Add(unit);
|
|
||||||
} else {
|
|
||||||
dict.Add(unit.TopDomain, new List<DomainUnit> { unit });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 1つしかなかったものを単独とする
|
|
||||||
var soloKeys = GetSoloDomains().ToArray();
|
|
||||||
foreach (var key in soloKeys) {
|
|
||||||
var unit = dict[key].FirstOrDefault();
|
|
||||||
if (unit == null || key == unit.FullName) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
dict.Remove(key);
|
|
||||||
var newKey = unit.FullName;
|
|
||||||
if (dict.ContainsKey(newKey)) {
|
|
||||||
dict[newKey].Add(unit);
|
|
||||||
} else {
|
|
||||||
dict.Add(newKey, new List<DomainUnit> { new DomainUnit(unit.FullName, '\0') });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<string> GetTopDomains() => dict.Keys;
|
|
||||||
public IEnumerable<string> GetSoloDomains() => dict
|
|
||||||
.Where(x => x.Value.Count == 1)
|
|
||||||
.Select(x => x.Key);
|
|
||||||
|
|
||||||
public IEnumerable<string> GetTopDomainsWithSomeSubDomains() => dict
|
|
||||||
.Keys
|
|
||||||
.Except(GetSoloDomains());
|
|
||||||
|
|
||||||
public IEnumerable<DomainUnit> GetSubDomains(string topDomain) {
|
|
||||||
if (dict.TryGetValue(topDomain, out var list)) {
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
return new DomainUnit[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d9fe84ab1b8c44b0a841738f0ecb37d3
|
|
||||||
timeCreated: 1606659209
|
|
@ -1,27 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
|
||||||
public class DomainUnit {
|
|
||||||
public readonly string FullName;
|
|
||||||
public readonly string TopDomain;
|
|
||||||
public readonly string SubDomain;
|
|
||||||
|
|
||||||
public DomainUnit(string fullName, char separator) {
|
|
||||||
this.FullName = fullName;
|
|
||||||
if (string.IsNullOrEmpty(FullName)) return;
|
|
||||||
var split = fullName.Split(separator).Where(x => !string.IsNullOrEmpty(x)).ToArray();
|
|
||||||
if (split.Length < 2) {
|
|
||||||
TopDomain = fullName.Replace(separator.ToString(), "");
|
|
||||||
SubDomain = string.Empty;
|
|
||||||
} else {
|
|
||||||
TopDomain = split[0];
|
|
||||||
SubDomain = split.Skip(1).Aggregate((a, b) => $"{a}{separator}{b}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasSubDomain() => !string.IsNullOrEmpty(SubDomain);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2927a4439ddc45a0a386b64e05220d53
|
|
||||||
timeCreated: 1606658272
|
|
@ -1,18 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
|
||||||
public class HashSetDependencyNode : IDependencyNode {
|
|
||||||
public NodeProfile Profile { get; }
|
|
||||||
public ICollection<NodeProfile> Sources => sources;
|
|
||||||
public ICollection<NodeProfile> Destinations => destinations;
|
|
||||||
|
|
||||||
readonly HashSet<NodeProfile> sources;
|
|
||||||
readonly HashSet<NodeProfile> destinations;
|
|
||||||
|
|
||||||
public HashSetDependencyNode(NodeProfile profile) {
|
|
||||||
Profile = profile;
|
|
||||||
sources = new HashSet<NodeProfile>();
|
|
||||||
destinations = new HashSet<NodeProfile>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3b278ba5cdda49eca5f5aa0b2941713d
|
|
||||||
timeCreated: 1605450089
|
|
@ -1,9 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
|
||||||
public interface IDependencyNode {
|
|
||||||
NodeProfile Profile { get; }
|
|
||||||
ICollection<NodeProfile> Sources { get; }
|
|
||||||
ICollection<NodeProfile> Destinations { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 365c6defe4c649a496963187a24ffca0
|
|
||||||
timeCreated: 1605449577
|
|
@ -1,33 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
|
||||||
public readonly struct NodeId : IEquatable<NodeId> {
|
|
||||||
public readonly int value;
|
|
||||||
|
|
||||||
public NodeId(int value) => this.value = value;
|
|
||||||
|
|
||||||
public bool Equals(NodeId other) {
|
|
||||||
return value == other.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj) {
|
|
||||||
return obj is NodeId other && Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString() {
|
|
||||||
return value.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(NodeId x, NodeId y) {
|
|
||||||
return x.Equals(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(NodeId x, NodeId y) {
|
|
||||||
return !(x == y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 11a5fcf054a34f8083cdcdb038b4c70c
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,25 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
|
||||||
public static class NodeProcessor {
|
|
||||||
|
|
||||||
public static void SetBeRequiredNodes(IEnumerable<IDependencyNode> nodes) {
|
|
||||||
var array = nodes as IDependencyNode[] ?? nodes.ToArray();
|
|
||||||
var dict = array.ToDictionary(x => x.Profile.Id);
|
|
||||||
foreach (var n in array) {
|
|
||||||
foreach (var d in n.Destinations) {
|
|
||||||
dict[d.Id].Sources.Add(n.Profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetRequireNodes(this IDependencyNode node, IEnumerable<NodeProfile> requireNodes) {
|
|
||||||
node.Sources.Clear();
|
|
||||||
node.Destinations.Clear();
|
|
||||||
foreach (var d in requireNodes) {
|
|
||||||
node.Destinations.Add(d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6febd7e408df42d89d561ffe371c602f
|
|
||||||
timeCreated: 1605454341
|
|
@ -1,44 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode {
|
|
||||||
public class NodeProfile : IEquatable<NodeProfile> {
|
|
||||||
public NodeId Id { get; }
|
|
||||||
public string Name { set; get; }
|
|
||||||
|
|
||||||
public NodeProfile(NodeId id, string name) {
|
|
||||||
Id = id;
|
|
||||||
Name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(NodeProfile other)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, other)) return false;
|
|
||||||
if (ReferenceEquals(this, other)) return true;
|
|
||||||
return Id.Equals(other.Id) && Name == other.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj)) return false;
|
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
if (obj.GetType() != this.GetType()) return false;
|
|
||||||
return Equals((NodeProfile) obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
unchecked
|
|
||||||
{
|
|
||||||
return (Id.GetHashCode() * 397) ^ (Name != null ? Name.GetHashCode() : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(NodeProfile x, NodeProfile y) {
|
|
||||||
return x.Equals(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(NodeProfile x, NodeProfile y) {
|
|
||||||
return !(x == y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8cf71e8ce8054c4b95902fcd1bda7010
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d7b935eca30945f5bff132d6a7645320
|
|
||||||
timeCreated: 1605459681
|
|
@ -1,50 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode.Sort {
|
|
||||||
public struct AlignParam {
|
|
||||||
public readonly int tryCount;
|
|
||||||
|
|
||||||
public readonly float basicDistance;
|
|
||||||
public readonly float nodeWidth;
|
|
||||||
public readonly float nodeHeight;
|
|
||||||
|
|
||||||
public readonly float relationK;
|
|
||||||
public readonly float relationNaturalLength;
|
|
||||||
public readonly float repulsivePower;
|
|
||||||
public readonly float threshold;
|
|
||||||
|
|
||||||
public AlignParam(int tryCount, float basicDistance, float nodeWidth, float nodeHeight,
|
|
||||||
float relationK, float relationNaturalLength, float repulsivePower, float threshold) {
|
|
||||||
this.tryCount = tryCount;
|
|
||||||
this.basicDistance = basicDistance;
|
|
||||||
this.nodeWidth = nodeWidth;
|
|
||||||
this.nodeHeight = nodeHeight;
|
|
||||||
this.relationK = relationK;
|
|
||||||
this.relationNaturalLength = relationNaturalLength;
|
|
||||||
this.repulsivePower = repulsivePower;
|
|
||||||
this.threshold = threshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AlignParam Default() => new AlignParam(1000, 100, 600, 100, -0.01F, 300, 0.01F, 300.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class AlignParamEx {
|
|
||||||
public static Vector2 接続したノード同士はばねによって引き合う(this AlignParam align, Vector2 target, Vector2 other) {
|
|
||||||
var k = align.relationK;
|
|
||||||
var nl = align.relationNaturalLength;
|
|
||||||
|
|
||||||
var l = (target - other).magnitude;
|
|
||||||
var delta = l - nl;
|
|
||||||
|
|
||||||
return -(delta * k * (other - target).normalized);
|
|
||||||
}
|
|
||||||
public static Vector2 全ノードは互いに斥力が発生する(this AlignParam align, Vector2 target, Vector2 other) {
|
|
||||||
var l = (other - target).magnitude;
|
|
||||||
if (l < align.threshold)
|
|
||||||
{
|
|
||||||
return -(other - target).normalized * ((align.threshold - l) * align.repulsivePower);
|
|
||||||
}
|
|
||||||
return Vector2.zero;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 949ed302d4b143d3b3fea3039ec3f9e9
|
|
||||||
timeCreated: 1605794098
|
|
@ -1,59 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
//https://github.com/TORISOUP/AnimatorControllerLayouter/blob/master/Assets/TORISOUP/AnimatorControllerLayouter/Editor/LayoutHelper.cs
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode.Sort {
|
|
||||||
public class AlignSortStrategy : ISortStrategy {
|
|
||||||
readonly AlignParam alignParam;
|
|
||||||
readonly Vector2 originPosition;
|
|
||||||
|
|
||||||
public AlignSortStrategy(AlignParam alignParam, Vector2 originPosition) {
|
|
||||||
this.alignParam = alignParam;
|
|
||||||
this.originPosition = originPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<SortedNode> Sort(IEnumerable<IDependencyNode> nodes) {
|
|
||||||
var nodeArr = nodes.ToArray();
|
|
||||||
var posDict = nodeArr.ToDictionary(x => x.Profile, _ => originPosition);
|
|
||||||
|
|
||||||
// まず順番に整列させる
|
|
||||||
nodeArr = nodeArr.OrderBy(x => x.Profile.Name).ToArray();
|
|
||||||
var nodeGrid = new NodeGrid(alignParam.nodeWidth, alignParam.nodeHeight, alignParam.basicDistance, nodeArr.Length);
|
|
||||||
for (var i = 0; i < nodeArr.Length; i++) {
|
|
||||||
posDict[nodeArr[i].Profile] += nodeGrid.GridCenterPositions()[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ばねによる整列
|
|
||||||
var tryCount = alignParam.tryCount;
|
|
||||||
while (tryCount-- > 0) {
|
|
||||||
foreach (var node in nodeArr) {
|
|
||||||
var target = posDict[node.Profile];
|
|
||||||
var force = Vector2.zero;
|
|
||||||
foreach (var innerNode in nodeArr) {
|
|
||||||
var other = posDict[innerNode.Profile];
|
|
||||||
// ばねの計算
|
|
||||||
if (node.IsConnectedTo(innerNode.Profile)) {
|
|
||||||
force += alignParam.接続したノード同士はばねによって引き合う(target, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
force += alignParam.全ノードは互いに斥力が発生する(target, other);
|
|
||||||
}
|
|
||||||
|
|
||||||
posDict[node.Profile] = target + force * 1.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 接続数に応じて左右に移動させる
|
|
||||||
// ref to が多いものが左に、ref by が多いものが右に
|
|
||||||
const float factor = 60.0F;
|
|
||||||
foreach (var dep in nodeArr) {
|
|
||||||
var score = (dep.Sources.Count - dep.Destinations.Count) * factor;
|
|
||||||
var p = posDict[dep.Profile];
|
|
||||||
posDict[dep.Profile] = new Vector2(p.x + score, p.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
return posDict.Select(x => new SortedNode { Profile = x.Key, Position = x.Value });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5ebdb87d853042fd96657c9f78cec1a9
|
|
||||||
timeCreated: 1605793928
|
|
@ -1,30 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using UnityEditor.Graphs;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode.Sort {
|
|
||||||
public static class DependencyNodeExtensions {
|
|
||||||
public static bool IsSourceEmpty(this IDependencyNode node) {
|
|
||||||
return !node.Sources.Any();
|
|
||||||
}
|
|
||||||
public static bool IsDestinationEmpty(this IDependencyNode node) {
|
|
||||||
return !node.Destinations.Any();
|
|
||||||
}
|
|
||||||
public static bool IsEmptyDependency(this IDependencyNode node) {
|
|
||||||
return node.IsSourceEmpty() && node.IsDestinationEmpty();
|
|
||||||
}
|
|
||||||
public static int CountDependencies(this IDependencyNode node) {
|
|
||||||
return node.Sources.Count + node.Destinations.Count;
|
|
||||||
}
|
|
||||||
public static bool ContainsSelfReference(this IDependencyNode node) {
|
|
||||||
return node.Sources.Any(x => x == node.Profile) ||
|
|
||||||
node.Destinations.Any(x => x == node.Profile);
|
|
||||||
}
|
|
||||||
public static IEnumerable<NodeProfile> ConnectedNodes(this IDependencyNode node) {
|
|
||||||
return node.Sources.Concat(node.Destinations);
|
|
||||||
}
|
|
||||||
public static bool IsConnectedTo(this IDependencyNode node, NodeProfile nodeProfile) {
|
|
||||||
return node.Sources.Contains(nodeProfile) || node.Destinations.Contains(nodeProfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8d0cee1bf7d4c8c47a98a23879a257cb
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,7 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode.Sort {
|
|
||||||
public interface ISortStrategy {
|
|
||||||
IEnumerable<SortedNode> Sort(IEnumerable<IDependencyNode> nodes);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3e2c63741aae4306aa49389ffdcb2e13
|
|
||||||
timeCreated: 1605459681
|
|
@ -1,31 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace AsmdefHelper.DependencyGraph.Editor.DependencyNode.Sort {
|
|
||||||
public class LinerSortStrategy : ISortStrategy {
|
|
||||||
readonly Vector2 originPosition;
|
|
||||||
readonly float basicDistance;
|
|
||||||
readonly float nodeWidth;
|
|
||||||
readonly float nodeHeight;
|
|
||||||
|
|
||||||
public LinerSortStrategy(Vector2 originPosition, float basicDistance, float nodeWidth, float nodeHeight) {
|
|
||||||
this.originPosition = originPosition;
|
|
||||||
this.basicDistance = basicDistance;
|
|
||||||
this.nodeWidth = nodeWidth;
|
|
||||||
this.nodeHeight = nodeHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerable<SortedNode> ISortStrategy.Sort(IEnumerable<IDependencyNode> nodes) {
|
|
||||||
var arr = nodes.ToArray();
|
|
||||||
var posDict = arr
|
|
||||||
.ToDictionary(x => x.Profile, _ => originPosition);
|
|
||||||
// 参照元がないNodeを原点に
|
|
||||||
var left = arr.FirstOrDefault(x => x.IsSourceEmpty());
|
|
||||||
posDict[left.Profile] = originPosition;
|
|
||||||
var right = arr.FirstOrDefault(x => x.Profile != left.Profile);
|
|
||||||
posDict[right.Profile] = new Vector2(nodeWidth / 2.0F + basicDistance, 0.0F) + originPosition;
|
|
||||||
return posDict.Select(x => new SortedNode { Profile = x.Key, Position = x.Value });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7d00de9a7b3041be922c457f9f53b1c0
|
|
||||||
timeCreated: 1605459871
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user