mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-10-01 07:11:02 -05:00
UniGLTF のメニューを整理
This commit is contained in:
27
Assets/UniGLTF/Editor/AssetMenu.cs
Normal file
27
Assets/UniGLTF/Editor/AssetMenu.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/UniGLTF/Editor/AssetMenu.cs.meta
Normal file
3
Assets/UniGLTF/Editor/AssetMenu.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddb68b5016b643edb75db97123f2b6b9
|
||||
timeCreated: 1638961746
|
||||
69
Assets/UniGLTF/Editor/TopMenu.cs
Normal file
69
Assets/UniGLTF/Editor/TopMenu.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
/// <summary>
|
||||
/// 機能をどのようにトップメニューに表示するかどうかだけを記述する.
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
/// <summary>
|
||||
/// Menuは一か所で管理する
|
||||
/// </summary>
|
||||
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<BoneMeshEraserWizard>("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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/UniGLTF/Editor/TopMenuImplementation.cs.meta
Normal file
3
Assets/UniGLTF/Editor/TopMenuImplementation.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 173b43f1467d4054921297a5c2e55d05
|
||||
timeCreated: 1638961414
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user