From f158d08818e2574ddc0b3e1c25f3a07ffa032270 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Wed, 8 Dec 2021 20:26:12 +0900 Subject: [PATCH] =?UTF-8?q?UniGLTF=20=E3=81=AE=E3=83=A1=E3=83=8B=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=82=92=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/UniGLTF/Editor/AssetMenu.cs | 27 ++++++ Assets/UniGLTF/Editor/AssetMenu.cs.meta | 3 + Assets/UniGLTF/Editor/TopMenu.cs | 69 +++++++++++++++ .../Editor/{Menu.cs.meta => TopMenu.cs.meta} | 0 .../{Menu.cs => TopMenuImplementation.cs} | 87 ++++--------------- .../Editor/TopMenuImplementation.cs.meta | 3 + .../VRM/IO/Editor/ShaderPropMenu.cs | 2 +- 7 files changed, 121 insertions(+), 70 deletions(-) create mode 100644 Assets/UniGLTF/Editor/AssetMenu.cs create mode 100644 Assets/UniGLTF/Editor/AssetMenu.cs.meta create mode 100644 Assets/UniGLTF/Editor/TopMenu.cs rename Assets/UniGLTF/Editor/{Menu.cs.meta => TopMenu.cs.meta} (100%) rename Assets/UniGLTF/Editor/{Menu.cs => TopMenuImplementation.cs} (58%) create mode 100644 Assets/UniGLTF/Editor/TopMenuImplementation.cs.meta diff --git a/Assets/UniGLTF/Editor/AssetMenu.cs b/Assets/UniGLTF/Editor/AssetMenu.cs new file mode 100644 index 000000000..3bf83de32 --- /dev/null +++ b/Assets/UniGLTF/Editor/AssetMenu.cs @@ -0,0 +1,27 @@ +using UnityEditor; +using UnityEngine; + +namespace UniGLTF +{ + public static class AssetMenu + { + [MenuItem("Assets/SaveAsPng", true)] + [MenuItem("Assets/SaveAsPngLinear", true)] + static bool IsTextureAsset() + { + return Selection.activeObject is Texture2D; + } + + [MenuItem("Assets/SaveAsPng")] + static void SaveAsPng() + { + MeshUtility.EditorChangeTextureType.SaveAsPng(true); + } + + [MenuItem("Assets/SaveAsPngLinear")] + static void SaveAsPngLinear() + { + MeshUtility.EditorChangeTextureType.SaveAsPng(false); + } + } +} \ No newline at end of file diff --git a/Assets/UniGLTF/Editor/AssetMenu.cs.meta b/Assets/UniGLTF/Editor/AssetMenu.cs.meta new file mode 100644 index 000000000..29afbd7e8 --- /dev/null +++ b/Assets/UniGLTF/Editor/AssetMenu.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ddb68b5016b643edb75db97123f2b6b9 +timeCreated: 1638961746 \ No newline at end of file diff --git a/Assets/UniGLTF/Editor/TopMenu.cs b/Assets/UniGLTF/Editor/TopMenu.cs new file mode 100644 index 000000000..285e187ee --- /dev/null +++ b/Assets/UniGLTF/Editor/TopMenu.cs @@ -0,0 +1,69 @@ +using System.IO; +using UnityEditor; +using UnityEngine; + +namespace UniGLTF +{ + /// + /// 機能をどのようにトップメニューに表示するかどうかだけを記述する. + /// + public static class TopMenu + { + private const string UserGltfMenuPrefix = UniGLTFVersion.MENU; + private const string UserMeshUtilityPrefix = UniGLTFVersion.MENU + "/Mesh Utility"; + private const string DevelopmentMenuPrefix = UniGLTFVersion.MENU + "/Development"; + private const int UserGltfMenuPriority = 0; + private const int UserMeshUtilityMenuPriority = 10; + private const int DevelopmentMenuPriority = 30; + + #region USER + [MenuItem( + UserGltfMenuPrefix + "/Version: " + UniGLTFVersion.UNIGLTF_VERSION, + validate = true)] + private static bool ShowVersionValidation() => false; + + [MenuItem( + UserGltfMenuPrefix + "/Version: " + UniGLTFVersion.UNIGLTF_VERSION, + priority = UserGltfMenuPriority + 0)] + private static void ShowVersion() + { + } + + [MenuItem( + UserGltfMenuPrefix + "/Export to GLB", + priority = UserGltfMenuPriority + 1)] + private static void ExportGameObjectToGltf() => TopMenuImplementation.ExportGameObjectToGltfFile(); + + [MenuItem( + UserGltfMenuPrefix + "/Import from GLTF (*.gltf|*.glb|*.zip)", + priority = UserGltfMenuPriority + 2)] + private static void ImportGltfFile() => TopMenuImplementation.ImportGltfFileToGameObject(); + #endregion + + #region MESH_UTILITY + + [MenuItem( + UserMeshUtilityPrefix + "/MeshProcessing Wizard", + priority = UserMeshUtilityMenuPriority + 0)] + private static void OpenMeshProcessingWindow() => TopMenuImplementation.OpenMeshProcessingWindow(); + + [MenuItem( + UserMeshUtilityPrefix + "/Open Documents", + priority = UserMeshUtilityMenuPriority + 1)] + private static void MeshUtilityDocs() => Application.OpenURL("https://vrm.dev/en/docs/univrm/gltf/mesh_utility/"); + #endregion + + #region DEVELOPMENT + [MenuItem( + DevelopmentMenuPrefix + "/Generate Serialization Code", + priority = DevelopmentMenuPriority + 1)] + private static void GenerateSerializationCode() => TopMenuImplementation.GenerateSerializationCode(); + + + [MenuItem( + DevelopmentMenuPrefix + "/Generate UniJSON ConcreteCast", + priority = DevelopmentMenuPriority + 2)] + private static void GenerateUniJsonConcreteCastCode() => UniJSON.ConcreteCast.GenerateGenericCast(); + #endregion + } +} diff --git a/Assets/UniGLTF/Editor/Menu.cs.meta b/Assets/UniGLTF/Editor/TopMenu.cs.meta similarity index 100% rename from Assets/UniGLTF/Editor/Menu.cs.meta rename to Assets/UniGLTF/Editor/TopMenu.cs.meta diff --git a/Assets/UniGLTF/Editor/Menu.cs b/Assets/UniGLTF/Editor/TopMenuImplementation.cs similarity index 58% rename from Assets/UniGLTF/Editor/Menu.cs rename to Assets/UniGLTF/Editor/TopMenuImplementation.cs index 3fc3f1fd3..a9ec44f1f 100644 --- a/Assets/UniGLTF/Editor/Menu.cs +++ b/Assets/UniGLTF/Editor/TopMenuImplementation.cs @@ -1,17 +1,19 @@ -using System.IO; +using System.IO; using UnityEditor; using UnityEngine; namespace UniGLTF { - /// - /// Menuは一か所で管理する - /// - public static class Menu + public static class TopMenuImplementation { - #region UniGLTF - [MenuItem(UniGLTFVersion.MENU + "/Import(gltf, glb, zip)", priority = 1)] - public static void ImportMenu() + public static void ExportGameObjectToGltfFile() + { + var window = (GltfExportWindow) GltfExportWindow.GetWindow(typeof(GltfExportWindow)); + window.titleContent = new GUIContent("Gltf Exporter"); + window.Show(); + } + + public static void ImportGltfFileToGameObject() { var path = EditorUtility.OpenFilePanel("open glb", "", "gltf,glb,zip"); if (string.IsNullOrEmpty(path)) @@ -90,72 +92,19 @@ namespace UniGLTF Selection.activeObject = asset; } - [MenuItem(UniGLTFVersion.MENU + "/Export " + UniGLTFVersion.UNIGLTF_VERSION, false, 0)] - private static void ExportFromMenu() + public static void OpenMeshProcessingWindow() { - var window = (GltfExportWindow)GltfExportWindow.GetWindow(typeof(GltfExportWindow)); - window.titleContent = new GUIContent("Gltf Exporter"); - window.Show(); - } - - [MenuItem(UniGLTFVersion.MENU + "/GLTF: Generate Deserializer")] - static void GenerateDeserializer() - { - DeserializerGenerator.GenerateSerializer(); - } - - [MenuItem(UniGLTFVersion.MENU + "/GLTF: Generate Serializer")] - static void GenerateSerializer() - { - DeserializerGenerator.GenerateSerializer(); - } - #endregion - - #region MeshUtility - // [MenuItem(MeshUtility.MENU_PARENT + "BoneMeshEraser Wizard", priority = 31)] - // static void CreateWizard() - // { - // ScriptableWizard.DisplayWizard("BoneMeshEraser", "Erase triangles by bone", "Erase"); - // } - const string MESH_UTILITY_DICT = "UniGLTF/Mesh Utility/"; - [MenuItem(MESH_UTILITY_DICT + "MeshProcessing Wizard", priority = 30)] - static void MeshProcessFromMenu() - { - var window = (MeshUtility.MeshProcessDialog)EditorWindow.GetWindowWithRect(typeof(MeshUtility.MeshProcessDialog), new Rect(0, 0, 650, 500)); + var window = + (MeshUtility.MeshProcessDialog) EditorWindow.GetWindowWithRect(typeof(MeshUtility.MeshProcessDialog), + new Rect(0, 0, 650, 500)); window.titleContent = new GUIContent("Mesh Processing Window"); window.Show(); } - [MenuItem(MESH_UTILITY_DICT + "MeshUtility Docs", priority = 32)] - public static void MeshUtilityDocs() + public static void GenerateSerializationCode() { - Application.OpenURL("https://vrm.dev/en/docs/univrm/gltf/mesh_utility/"); - } - - [MenuItem("Assets/SaveAsPng", true)] - [MenuItem("Assets/SaveAsPngLinear", true)] - static bool IsTextureAsset() - { - return Selection.activeObject is Texture2D; - } - - [MenuItem("Assets/SaveAsPng")] - static void SaveAsPng() - { - MeshUtility.EditorChangeTextureType.SaveAsPng(true); - } - - [MenuItem("Assets/SaveAsPngLinear")] - static void SaveAsPngLinear() - { - MeshUtility.EditorChangeTextureType.SaveAsPng(false); - } - #endregion - - [MenuItem("UniGLTF/UniJSON/Generate ConcreteCast")] - static void GenerateConcreteCast() - { - UniJSON.ConcreteCast.GenerateGenericCast(); + SerializerGenerator.GenerateSerializer(); + DeserializerGenerator.GenerateSerializer(); } } -} +} \ No newline at end of file diff --git a/Assets/UniGLTF/Editor/TopMenuImplementation.cs.meta b/Assets/UniGLTF/Editor/TopMenuImplementation.cs.meta new file mode 100644 index 000000000..1024de137 --- /dev/null +++ b/Assets/UniGLTF/Editor/TopMenuImplementation.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 173b43f1467d4054921297a5c2e55d05 +timeCreated: 1638961414 \ No newline at end of file diff --git a/Assets/VRMShaders/VRM/IO/Editor/ShaderPropMenu.cs b/Assets/VRMShaders/VRM/IO/Editor/ShaderPropMenu.cs index 0d5151696..3a949d10a 100644 --- a/Assets/VRMShaders/VRM/IO/Editor/ShaderPropMenu.cs +++ b/Assets/VRMShaders/VRM/IO/Editor/ShaderPropMenu.cs @@ -11,7 +11,7 @@ namespace UniGLTF public static class ShaderPropMenu { #if VRM_DEVELOP - [MenuItem("VRMShaders/PreExport ShaderProps")] + [MenuItem("VRMShaders/Development/PreExport ShaderProps")] #endif public static void PreExport() {