任意のasmdef作成
This commit is contained in:
parent
6bc8074751
commit
750b8ba765
@ -11,6 +11,7 @@ namespace AsmdefHelper.CompileLocker.Editor {
|
||||
const string menuPath = "Window/Asmdef Helper/Compile Lock";
|
||||
|
||||
[MenuItem("Window/Asmdef Helper/Compile Lock", false, 1)]
|
||||
[MenuItem("Assets/Asmdef Helper/Compile Lock", false, 1000)]
|
||||
static void Lock() {
|
||||
var isLocked = Menu.GetChecked(menuPath);
|
||||
if (isLocked) {
|
||||
|
@ -1,37 +1,66 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using AsmdefHelper.CustomCreate.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEditor.UIElements;
|
||||
|
||||
|
||||
public class AsmdefCustomCreateView : EditorWindow
|
||||
{
|
||||
[MenuItem("Window/Project/AsmdefCustomCreateView")]
|
||||
public static void ShowExample()
|
||||
{
|
||||
AsmdefCustomCreateView wnd = GetWindow<AsmdefCustomCreateView>();
|
||||
wnd.titleContent = new GUIContent("AsmdefCustomCreateView");
|
||||
// original: https://github.com/baba-s/UniAssemblyDefinitionCreator
|
||||
public class AsmdefCustomCreateView : EditorWindow {
|
||||
[MenuItem("Assets/Asmdef Helper/Create custom asmdef", false, 0)]
|
||||
public static void ShowWindow() {
|
||||
var window = GetWindow<AsmdefCustomCreateView>();
|
||||
window.titleContent = new GUIContent("AsmdefCustomCreateView");
|
||||
window.minSize = new Vector2(200,180);
|
||||
window.maxSize = new Vector2(2000,180);
|
||||
}
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
public void OnEnable() {
|
||||
// Each editor window contains a root VisualElement object
|
||||
VisualElement root = rootVisualElement;
|
||||
|
||||
// VisualElements objects can contain other VisualElement following a tree hierarchy.
|
||||
VisualElement label = new Label("Hello World! From C#");
|
||||
root.Add(label);
|
||||
|
||||
// Import UXML
|
||||
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/AsmdefHelper/CustomCreate/Editor/AsmdefCustomCreateView.uxml");
|
||||
var visualTree =
|
||||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
|
||||
"Assets/AsmdefHelper/CustomCreate/Editor/AsmdefCustomCreateView.uxml");
|
||||
VisualElement labelFromUXML = visualTree.Instantiate();
|
||||
root.Add(labelFromUXML);
|
||||
|
||||
// A stylesheet can be added to a VisualElement.
|
||||
// The style will be applied to the VisualElement and all of its children.
|
||||
var styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/AsmdefHelper/CustomCreate/Editor/AsmdefCustomCreateView.uss");
|
||||
VisualElement labelWithStyle = new Label("Hello World! With Style");
|
||||
labelWithStyle.styleSheets.Add(styleSheet);
|
||||
root.Add(labelWithStyle);
|
||||
// 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 OverrideReferencesToggle = root.Q<Toggle>(className: "OverrideReferencesToggle");
|
||||
var NoEngineReferencesToggle = root.Q<Toggle>(className: "NoEngineReferencesToggle");
|
||||
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;
|
||||
NameTextField.value = directory.Replace("Assets/", "").Replace('/', '.');
|
||||
|
||||
// .asmdefを作成して閉じる
|
||||
CreateButton.clickable.clicked += () => {
|
||||
var asmdefName = NameTextField.value;
|
||||
var asmdef = new AssemblyDefinitionJson {
|
||||
name = asmdefName,
|
||||
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();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,15 @@
|
||||
xmlns:editor="UnityEditor.UIElements"
|
||||
xsi:noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd"
|
||||
>
|
||||
<engine:Label text="Hello World! From UXML" />
|
||||
<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:Toggle class="AllowUnsafeToggle" label="Allow 'unsafe' Code" value="false"/>
|
||||
<engine:Toggle class="AutoReferencedToggle" label="Auto Referenced" value="true"/>
|
||||
<engine:Toggle class="OverrideReferencesToggle" label="Override Referenced" value="false"/>
|
||||
<engine:Toggle class="NoEngineReferencesToggle" label="No Engine References" value="false"/>
|
||||
<engine:Toggle class="IsEditorToggle" label="Is Editor" value="false"/>
|
||||
<engine:Button class="CreateButton" text="Create" />
|
||||
</engine:Box>
|
||||
</engine:UXML>
|
||||
|
@ -0,0 +1,15 @@
|
||||
namespace AsmdefHelper.CustomCreate.Editor {
|
||||
public class AssemblyDefinitionJson {
|
||||
public string name = string.Empty;
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0364ec00ec0f6a2448715767f1e1441f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -17,7 +17,7 @@ namespace AsmdefHelper.MultipleEdit.Editor {
|
||||
}
|
||||
|
||||
[MenuItem("Window/Asmdef Helper/Open selected asmdef inspector view")]
|
||||
[MenuItem("Assets/Asmdef Helper/Open selected asmdef inspector view")]
|
||||
[MenuItem("Assets/Asmdef Helper/Open selected asmdef inspector view", priority = 2000)]
|
||||
public static void Open() {
|
||||
var asmdefs = Selection.GetFiltered(typeof(AssemblyDefinitionAsset), SelectionMode.TopLevel);
|
||||
if (!asmdefs.Any()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user