Skip to content

Commit

Permalink
Merge pull request #2184 from ousttrue/fix_menu_name
Browse files Browse the repository at this point in the history
menu 名と dialog 名を整理
  • Loading branch information
ousttrue authored Nov 15, 2023
2 parents 3f7a1fa + b216a5b commit a700798
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@

namespace UniGLTF
{
public static class TopMenuImplementation
public static class GltfImportMenu
{
public static void ExportGameObjectToGltfFile()
{
var window = (GltfExportWindow)GltfExportWindow.GetWindow(typeof(GltfExportWindow));
window.titleContent = new GUIContent("Gltf Exporter");
window.Show();
}

public const string MENU_NAME = "Import glTF... (*.gltf|*.glb|*.zip)";
public static void ImportGltfFileToGameObject()
{
var path = EditorUtility.OpenFilePanel("open glb", "",
var path = EditorUtility.OpenFilePanel(MENU_NAME + ": open glb", "",
#if UNITY_EDITOR_OSX
// https://github.com/vrm-c/UniVRM/issues/1837
"glb"
Expand Down Expand Up @@ -98,11 +92,5 @@ public static void ImportGltfFileToGameObject()
var asset = unitypath.LoadAsset<GameObject>();
Selection.activeObject = asset;
}

public static void GenerateSerializationCode()
{
SerializerGenerator.GenerateSerializer();
DeserializerGenerator.GenerateSerializer();
}
}
}
11 changes: 11 additions & 0 deletions Assets/UniGLTF/Editor/GltfImportMenu.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Assets/UniGLTF/Editor/MeshUtility/MeshUtilityDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ namespace UniGLTF.MeshUtility
{
public class MeshUtilityDialog : EditorWindow
{
const string TITLE = "Mesh Utility Window";

public const string MENU_NAME = "glTF MeshUtility";
enum MeshProcessDialogTabs
{
MeshSeparator,
Expand All @@ -35,7 +34,7 @@ public static void OpenWindow()
{
var window =
(MeshUtilityDialog)EditorWindow.GetWindow(typeof(MeshUtilityDialog));
window.titleContent = new GUIContent(TITLE);
window.titleContent = new GUIContent(MENU_NAME);
window.Show();
}

Expand Down
30 changes: 17 additions & 13 deletions Assets/UniGLTF/Editor/TopMenu.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.IO;
using UnityEditor;
using UnityEngine;

namespace UniGLTF
{
Expand All @@ -12,27 +10,33 @@ public static class TopMenu
private const string UserGltfMenuPrefix = UniGLTFVersion.MENU;
private const string DevelopmentMenuPrefix = UniGLTFVersion.MENU + "/Development";


[MenuItem(UserGltfMenuPrefix + "/Version: " + UniGLTFVersion.UNIGLTF_VERSION, validate = true)]
private static bool ShowVersionValidation() => false;

[MenuItem(UserGltfMenuPrefix + "/Version: " + UniGLTFVersion.UNIGLTF_VERSION, priority = 0)]
private static void ShowVersion() { }

[MenuItem(UserGltfMenuPrefix + "/Export to GLB", priority = 1)]
private static void ExportGameObjectToGltf() => TopMenuImplementation.ExportGameObjectToGltfFile();

[MenuItem(UserGltfMenuPrefix + "/Import from GLTF (*.gltf|*.glb|*.zip)", priority = 2)]
private static void ImportGltfFile() => TopMenuImplementation.ImportGltfFileToGameObject();
[MenuItem(UserGltfMenuPrefix + "/" + GltfExportWindow.MENU_NAME, priority = 1)]
private static void ExportGameObjectToGltf() => GltfExportWindow.ExportGameObjectToGltfFile();

[MenuItem(UserGltfMenuPrefix + "/MeshUtility Wizard", priority = 10)]
private static void OpenMeshProcessingWindow() => MeshUtility.MeshUtilityDialog.OpenWindow();

#if VRM_DEVELOP
[MenuItem(DevelopmentMenuPrefix + "/Generate Serialization Code", priority = 20)]
private static void GenerateSerializationCode() => TopMenuImplementation.GenerateSerializationCode();
[MenuItem(UserGltfMenuPrefix + "/" + GltfImportMenu.MENU_NAME, priority = 2)]
private static void ImportGltfFile() => GltfImportMenu.ImportGltfFileToGameObject();


[MenuItem(DevelopmentMenuPrefix + "/Generate UniJSON ConcreteCast", priority = 21)]
[MenuItem(UserGltfMenuPrefix + "/" + MeshUtility.MeshUtilityDialog.MENU_NAME, priority = 3)]
private static void OpenMeshProcessingWindow() => MeshUtility.MeshUtilityDialog.OpenWindow();

#if VRM_DEVELOP
[MenuItem(DevelopmentMenuPrefix + "/Generate Serialization Code", priority = 40)]
private static void GenerateSerializationCode()
{
SerializerGenerator.GenerateSerializer();
DeserializerGenerator.GenerateSerializer();
}

[MenuItem(DevelopmentMenuPrefix + "/Generate UniJSON ConcreteCast", priority = 41)]
private static void GenerateUniJsonConcreteCastCode() => UniJSON.ConcreteCast.GenerateGenericCast();
#endif
}
Expand Down
3 changes: 0 additions & 3 deletions Assets/UniGLTF/Editor/TopMenuImplementation.cs.meta

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ namespace UniGLTF
{
public class GltfExportWindow : ExportDialogBase
{

public const string MENU_NAME = "Export glTF...";
public static void ExportGameObjectToGltfFile()
{
var window = (GltfExportWindow)GltfExportWindow.GetWindow(typeof(GltfExportWindow));
window.titleContent = new GUIContent(MENU_NAME);
window.Show();
}

enum Tabs
{
Expand Down
1 change: 1 addition & 0 deletions Assets/UniGLTF/Runtime/UniGLTF/PackageVersionPartial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,6 @@ public struct Version

public const string VRM_VERSION = "UniVRM-" + VERSION;
public const string MENU = "VRM0";
public const string MENU_NAME = "Version: " + PackageVersion.VRM_VERSION;
}
}
3 changes: 2 additions & 1 deletion Assets/VRM/Editor/Format/VRMExporterWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ namespace VRM
{
public class VRMExporterWizard : ExportDialogBase
{
public const string MENU_NAME = "Export VRM 0.x...";
public static void OpenExportMenu()
{
var window = (VRMExporterWizard)GetWindow(typeof(VRMExporterWizard));
window.titleContent = new GUIContent("VRM Exporter");
window.titleContent = new GUIContent(MENU_NAME);
window.Show();
}

Expand Down
1 change: 1 addition & 0 deletions Assets/VRM/Editor/Format/VRMHumanoidNormalizerMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace VRM
{
public static class VRMHumanoidNormalizerMenu
{
public const string MENU_NAME = "VRM 0.x Freeze T-Pose";
public static bool NormalizeValidation()
{
var root = Selection.activeObject as GameObject;
Expand Down
3 changes: 2 additions & 1 deletion Assets/VRM/Editor/Format/VRMImporterMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ namespace VRM
{
public static class VRMImporterMenu
{
public const string MENU_NAME = "Import VRM 0.x...";
public static void OpenImportMenu()
{
var path = EditorUtility.OpenFilePanel("open vrm", "", "vrm");
var path = EditorUtility.OpenFilePanel(MENU_NAME + ": open vrm", "", "vrm");
if (string.IsNullOrEmpty(path))
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace VRM
{
public class VrmMeshIntegratorWizard : ScriptableWizard
{
public const string MENU_NAME = "VRM 0.x MeshUtility";
const string ASSET_SUFFIX = ".mesh.asset";

enum HelpMessage
Expand Down Expand Up @@ -95,7 +96,7 @@ public class ExcludeItem

public static void CreateWizard()
{
ScriptableWizard.DisplayWizard<VrmMeshIntegratorWizard>("MeshIntegratorWizard", "Integrate and close window", "Integrate");
ScriptableWizard.DisplayWizard<VrmMeshIntegratorWizard>(MENU_NAME, "Integrate and close window", "Integrate");
}

private void OnEnable()
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRM/Editor/SpringBone/VRMSpringBoneUtilityEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace VRM
internal static class VRMSpringBoneUtilityEditor
{
#region save

public const string SAVE_MENU_NAME = "VRM 0.x Save SpringBone to JSON...";
public static bool SaveSpringBoneToJsonValidation()
{
var root = Selection.activeObject as GameObject;
Expand Down Expand Up @@ -57,7 +57,7 @@ public static void SaveSpringBoneToJson()
#endregion

#region load

public const string LOAD_MENU_NAME = "VRM 0.x Load SpringBone from JSON...";
public static bool LoadSpringBoneFromJsonValidation()
{
var root = Selection.activeObject as GameObject;
Expand Down
44 changes: 23 additions & 21 deletions Assets/VRM/Editor/VrmTopMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,53 @@ public static class VrmTopMenu
private const string UserMenuPrefix = PackageVersion.MENU;
private const string DevelopmentMenuPrefix = PackageVersion.MENU + "/Development";

[MenuItem(UserMenuPrefix + "/Version: " + PackageVersion.VRM_VERSION, validate = true)]
private static bool ShowVersionValidation() => false;

[MenuItem(UserMenuPrefix + "/Version: " + PackageVersion.VRM_VERSION, priority = 0)]
[MenuItem(UserMenuPrefix + "/" + PackageVersion.MENU_NAME, true, 0)]
private static bool ShowVersionValidation() => false;
[MenuItem(UserMenuPrefix + "/" + PackageVersion.MENU_NAME, false, 0)]
private static void ShowVersion() { }

[MenuItem(UserMenuPrefix + "/Export to VRM 0.x", priority = 1)]

[MenuItem(UserMenuPrefix + "/" + VRMExporterWizard.MENU_NAME, false, 1)]
private static void ExportToVrmFile() => VRMExporterWizard.OpenExportMenu();

[MenuItem(UserMenuPrefix + "/Import from VRM 0.x", priority = 2)]

[MenuItem(UserMenuPrefix + "/" + VRMImporterMenu.MENU_NAME, false, 2)]
private static void ImportFromVrmFile() => VRMImporterMenu.OpenImportMenu();

[MenuItem(UserMenuPrefix + "/Freeze T-Pose", validate = true)]
private static bool FreezeTPoseValidation() => VRMHumanoidNormalizerMenu.NormalizeValidation();

[MenuItem(UserMenuPrefix + "/Freeze T-Pose", priority = 20)]
[MenuItem(UserMenuPrefix + "/" + VrmMeshIntegratorWizard.MENU_NAME, false, 3)]
private static void OpenMeshIntegratorWizard() => VrmMeshIntegratorWizard.CreateWizard();


[MenuItem(UserMenuPrefix + "/" + VRMHumanoidNormalizerMenu.MENU_NAME, true, 51)]
private static bool FreezeTPoseValidation() => VRMHumanoidNormalizerMenu.NormalizeValidation();
[MenuItem(UserMenuPrefix + "/" + VRMHumanoidNormalizerMenu.MENU_NAME, false, 52)]
private static void FreezeTPose() => VRMHumanoidNormalizerMenu.Normalize();

[MenuItem(UserMenuPrefix + "/MeshIntegratorWizard", priority = 21)]
private static void OpenMeshIntegratorWizard() => VrmMeshIntegratorWizard.CreateWizard();

[MenuItem(UserMenuPrefix + "/Save SpringBone to JSON", validate = true)]
[MenuItem(UserMenuPrefix + "/" + VRMSpringBoneUtilityEditor.SAVE_MENU_NAME, true, 53)]
private static bool SaveSpringBoneToJsonValidation() => VRMSpringBoneUtilityEditor.SaveSpringBoneToJsonValidation();

[MenuItem(UserMenuPrefix + "/Save SpringBone to JSON", priority = 22)]
[MenuItem(UserMenuPrefix + "/" + VRMSpringBoneUtilityEditor.SAVE_MENU_NAME, false, 53)]
private static void SaveSpringBoneToJson() => VRMSpringBoneUtilityEditor.SaveSpringBoneToJson();

[MenuItem(UserMenuPrefix + "/Load SpringBone from JSON", validate = true)]
private static bool LoadSpringBoneFromJsonValidation() => VRMSpringBoneUtilityEditor.LoadSpringBoneFromJsonValidation();

[MenuItem(UserMenuPrefix + "/Load SpringBone from JSON", priority = 23)]
private static void LoadSpringBoneFromJson() => VRMSpringBoneUtilityEditor.LoadSpringBoneFromJson();
[MenuItem(UserMenuPrefix + "/" + VRMSpringBoneUtilityEditor.LOAD_MENU_NAME, true, 54)]
private static bool LoadSpringBoneFromJsonValidation() => VRMSpringBoneUtilityEditor.LoadSpringBoneFromJsonValidation();
[MenuItem(UserMenuPrefix + "/" + VRMSpringBoneUtilityEditor.LOAD_MENU_NAME, false, 54)]


#if VRM_DEVELOP
[MenuItem(DevelopmentMenuPrefix + "/Generate Serialization Code", priority = 30)]
[MenuItem(DevelopmentMenuPrefix + "/Generate Serialization Code", false, 91)]
private static void GenerateSerializer() => VRMAOTCodeGenerator.GenerateCode();

[MenuItem(DevelopmentMenuPrefix + "/Version Dialog", priority = 32)]
[MenuItem(DevelopmentMenuPrefix + "/Version Dialog", false, 92)]
private static void ShowVersionDialog() => VRMVersionMenu.ShowVersionDialog();

[MenuItem(DevelopmentMenuPrefix + "/Build dummy for CI", priority = 33)]
[MenuItem(DevelopmentMenuPrefix + "/Build dummy for CI", false, 93)]
private static void BuildDummyForCi() => BuildClass.Build();

[MenuItem(DevelopmentMenuPrefix + "/Create UnityPackage", priority = 34)]
[MenuItem(DevelopmentMenuPrefix + "/Create UnityPackage", false, 94)]
private static void CreateUnityPackage() => VRMExportUnityPackage.CreateUnityPackageWithoutBuild();
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRM10/Editor/Components/VRM10Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace UniVRM10
/// </summary>
public class VRM10Window : EditorWindow
{
public const string WINDOW_TITLE = "VRM1.0 Model Editor";
public const string MENU_NAME = "VRM 1.0 Window";

public static VRM10Window Open()
{
var window = (VRM10Window)GetWindow(typeof(VRM10Window));
window.titleContent = new GUIContent(WINDOW_TITLE);
window.titleContent = new GUIContent(MENU_NAME);
window.Show();
window.Root = UnityEditor.Selection.activeTransform?.GetComponent<Vrm10Instance>();
return window;
Expand Down
2 changes: 1 addition & 1 deletion Assets/VRM10/Editor/MeshUtility/MeshIntegrationTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int Selected
public MeshIntegrationTab(EditorWindow editor, Vrm10MeshUtility meshUtility)
{
_meshUti = meshUtility;
_splitter = new VerticalSplitter(editor, 50, 50);
_splitter = new VerticalSplitter(editor, 200, 50);

_groupList = new ReorderableList(_meshUti.MeshIntegrationGroups, typeof(MeshIntegrationGroup));
_groupList.drawHeaderCallback = (Rect rect) =>
Expand Down
5 changes: 3 additions & 2 deletions Assets/VRM10/Editor/MeshUtility/Vrm10MeshUtilityDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace UniVRM10
{
public class Vrm10MeshUtilityDialog : EditorWindow
{
const string TITLE = "Vrm10 Mesh Utility Window";
public const string MENU_NAME = "VRM 1.0 MeshUtility";

enum Tabs
{
Freeze,
Expand All @@ -22,7 +23,7 @@ public static void OpenWindow()
{
var window =
(Vrm10MeshUtilityDialog)EditorWindow.GetWindow(typeof(Vrm10MeshUtilityDialog));
window.titleContent = new GUIContent(TITLE);
window.titleContent = new GUIContent(MENU_NAME);
window.Show();
}

Expand Down
6 changes: 4 additions & 2 deletions Assets/VRM10/Editor/Vrm10ExportDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ namespace UniVRM10
{
public class VRM10ExportDialog : ExportDialogBase
{
public const string MENU_NAME = "Export VRM 1.0...";

public static void Open()
{
var window = GetWindow<VRM10ExportDialog>("VRM-1.0 Exporter");
var window = GetWindow<VRM10ExportDialog>(MENU_NAME);
window.Show();
}

Expand Down Expand Up @@ -279,7 +281,7 @@ protected override void ExportPath(string path)
var exporter = new UniVRM10.Vrm10Exporter(new EditorTextureSerializer(), m_settings.MeshExportSettings);
var option = new VrmLib.ExportArgs
{
sparse = m_settings.MorphTargetUseSparse,
sparse = m_settings.MorphTargetUseSparse,
};
exporter.Export(root, model, converter, option, Vrm ? Vrm.Meta : m_tmpObject.Meta);

Expand Down
2 changes: 1 addition & 1 deletion Assets/VRM10/Editor/Vrm10InstanceEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public override void OnInspectorGUI()
if (instance.Vrm != null)
{
EditorGUILayout.HelpBox("SpringBone gizmo etc...", MessageType.Info);
if (GUILayout.Button("Open " + VRM10Window.WINDOW_TITLE))
if (GUILayout.Button("Open " + VRM10Window.MENU_NAME))
{
VRM10Window.Open();
}
Expand Down
14 changes: 8 additions & 6 deletions Assets/VRM10/Editor/Vrm10TopMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ public static class Vrm10TopMenu
private const string DevelopmentMenuPrefix = VRM10SpecVersion.MENU + "/Development";
private const string ExperimentalMenuPrefix = VRM10SpecVersion.MENU + "/Experimental";

[MenuItem(UserMenuPrefix + "/Export VRM-1.0", priority = 1)]

[MenuItem(UserMenuPrefix + "/" + VRM10ExportDialog.MENU_NAME, priority = 1)]
private static void OpenExportDialog() => VRM10ExportDialog.Open();

[MenuItem(UserMenuPrefix + "/MeshUtility", priority = 2)]
[MenuItem(UserMenuPrefix + "/" + Vrm10MeshUtilityDialog.MENU_NAME, priority = 2)]
private static void OpenMeshUtility() => Vrm10MeshUtilityDialog.OpenWindow();

[MenuItem(ExperimentalMenuPrefix + "/Convert BVH to VRM-Animation", priority = 100)]

[MenuItem(ExperimentalMenuPrefix + "/" + VrmAnimationMenu.MENU_NAME, priority = 21)]
private static void ConvertVrmAnimation() => VrmAnimationMenu.BvhToVrmAnimationMenu();

#if VRM_DEVELOP
[MenuItem(UserMenuPrefix + "/VRM1 Window", false, 2)]
[MenuItem(ExperimentalMenuPrefix + "/" + VRM10Window.MENU_NAME, false, 22)]
private static void OpenWindow() => VRM10Window.Open();

[MenuItem(DevelopmentMenuPrefix + "/Generate from JsonSchema")]
[MenuItem(DevelopmentMenuPrefix + "/Generate from JsonSchema", false, 100)]
private static void Generate() => Vrm10SerializerGenerator.Run(false);

[MenuItem(DevelopmentMenuPrefix + "/Generate from JsonSchema(debug)")]
[MenuItem(DevelopmentMenuPrefix + "/Generate from JsonSchema(debug)", false, 101)]
private static void Parse() => Vrm10SerializerGenerator.Run(true);
#endif
}
Expand Down
Loading

0 comments on commit a700798

Please sign in to comment.