This commit is contained in:
ousttrue 2023-10-23 19:28:47 +09:00
parent c1c894935a
commit d4f0bb2899
12 changed files with 36 additions and 50 deletions

View File

@ -15,20 +15,20 @@ namespace UniGLTF.MeshUtility
/// UnityEngine.Object を継承したクラスのフィールドに ユーザー定義 struct を配置する。
/// 持ち主の SerializedObject を経由して EditorGUILayout.PropertyField してる。
/// </summary>
[CustomEditor(typeof(MeshProcessDialog), true)]
class MeshProcessDialogEditor : Editor
[CustomEditor(typeof(MeshUtilityDialog), true)]
class BoneMeshEraserEditor : Editor
{
MeshProcessDialog _targetDialog;
MeshUtilityDialog _targetDialog;
SerializedProperty _skinnedMesh;
SerializedProperty _eraseBones;
void OnEnable()
{
_targetDialog = target as MeshProcessDialog;
_targetDialog = target as MeshUtilityDialog;
if (_targetDialog)
{
_skinnedMesh = serializedObject.FindProperty(nameof(MeshProcessDialog._skinnedMeshRenderer));
_eraseBones = serializedObject.FindProperty(nameof(MeshProcessDialog._eraseBones));
_skinnedMesh = serializedObject.FindProperty(nameof(MeshUtilityDialog._skinnedMeshRenderer));
_eraseBones = serializedObject.FindProperty(nameof(MeshUtilityDialog._eraseBones));
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 829a678062065f04582189619babae79
guid: 2021859c0d7255643bd93c95ab3fcf3d
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 04fa1873cf1c0374aab1670a24d741b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,9 +0,0 @@
namespace UniGLTF.MeshUtility
{
public enum MeshProcessDialogTabs
{
MeshSeparator,
MeshIntegrator,
BoneMeshEraser,
}
}

View File

@ -5,9 +5,16 @@ using System.Collections.Generic;
namespace UniGLTF.MeshUtility
{
public class MeshProcessDialog : EditorWindow
public class MeshUtilityDialog : EditorWindow
{
const string TITLE = "Mesh Processing Window";
const string TITLE = "Mesh Utility Window";
enum MeshProcessDialogTabs
{
MeshSeparator,
MeshIntegrator,
BoneMeshEraser,
}
MeshProcessDialogTabs _tab;
private GameObject _exportTarget;
@ -21,13 +28,13 @@ namespace UniGLTF.MeshUtility
[SerializeField]
public List<BoneMeshEraser.EraseBone> _eraseBones;
private MeshProcessDialogEditor _boneMeshEraserEditor;
private BoneMeshEraserEditor _boneMeshEraserEditor;
private Vector2 _scrollPos = new Vector2(0, 0);
public static void OpenWindow()
{
var window =
(MeshProcessDialog)EditorWindow.GetWindow(typeof(MeshProcessDialog));
(MeshUtilityDialog)EditorWindow.GetWindow(typeof(MeshUtilityDialog));
window.titleContent = new GUIContent(TITLE);
window.Show();
}
@ -36,7 +43,7 @@ namespace UniGLTF.MeshUtility
{
if (!_boneMeshEraserEditor)
{
_boneMeshEraserEditor = (MeshProcessDialogEditor)Editor.CreateEditor(this);
_boneMeshEraserEditor = (BoneMeshEraserEditor)Editor.CreateEditor(this);
}
}
@ -45,7 +52,7 @@ namespace UniGLTF.MeshUtility
_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
EditorGUIUtility.labelWidth = 200;
LanguageGetter.OnGuiSelectLang();
_exportTarget = (GameObject)EditorGUILayout.ObjectField(MeshProcessingMessages.TARGET_OBJECT.Msg(), _exportTarget, typeof(GameObject), true);
_exportTarget = (GameObject)EditorGUILayout.ObjectField(MeshUtilityMessages.TARGET_OBJECT.Msg(), _exportTarget, typeof(GameObject), true);
_tab = TabBar.OnGUI(_tab, "LargeButton", GUI.ToolbarButtonSize.Fixed);
var processed = false;
@ -53,7 +60,7 @@ namespace UniGLTF.MeshUtility
{
case MeshProcessDialogTabs.MeshSeparator:
{
EditorGUILayout.HelpBox(MeshProcessingMessages.MESH_SEPARATOR.Msg(), MessageType.Info);
EditorGUILayout.HelpBox(MeshUtilityMessages.MESH_SEPARATOR.Msg(), MessageType.Info);
if (TabMeshSeparator.TryExecutable(_exportTarget, out string msg))
{
processed = TabMeshSeparator.OnGUI(_exportTarget);
@ -67,8 +74,8 @@ namespace UniGLTF.MeshUtility
case MeshProcessDialogTabs.MeshIntegrator:
{
EditorGUILayout.HelpBox(MeshProcessingMessages.MESH_INTEGRATOR.Msg(), MessageType.Info);
_separateByBlendShape = EditorGUILayout.Toggle(MeshProcessingMessages.MESH_SEPARATOR_BY_BLENDSHAPE.Msg(), _separateByBlendShape);
EditorGUILayout.HelpBox(MeshUtilityMessages.MESH_INTEGRATOR.Msg(), MessageType.Info);
_separateByBlendShape = EditorGUILayout.Toggle(MeshUtilityMessages.MESH_SEPARATOR_BY_BLENDSHAPE.Msg(), _separateByBlendShape);
if (TabMeshIntegrator.TryExecutable(_exportTarget, out string msg))
{
if (GUILayout.Button("Process", GUILayout.MinWidth(100)))
@ -85,7 +92,7 @@ namespace UniGLTF.MeshUtility
case MeshProcessDialogTabs.BoneMeshEraser:
{
EditorGUILayout.HelpBox(MeshProcessingMessages.BONE_MESH_ERASER.Msg(), MessageType.Info);
EditorGUILayout.HelpBox(MeshUtilityMessages.BONE_MESH_ERASER.Msg(), MessageType.Info);
if (_boneMeshEraserEditor)
{
_boneMeshEraserEditor.OnInspectorGUI();

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 86cbd6470ebef2f4c976410efaf45638
guid: 1bdcb928351f92047a91c17c3d629853
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -2,7 +2,7 @@ using UniGLTF.M17N;
namespace UniGLTF.MeshUtility
{
public enum MeshProcessingMessages
public enum MeshUtilityMessages
{
[LangMsg(Languages.ja, "ターゲットオブジェクト")]
[LangMsg(Languages.en, "TargetObject")]

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 575d573f28f0e4a48a2a6509e69b7f6f
guid: abaf50b8dc367d4448cd5d7c99a4eea3
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -17,13 +17,13 @@ namespace UniGLTF.MeshUtility
{
if (root == null)
{
msg = MeshProcessingMessages.NO_GAMEOBJECT_SELECTED.Msg();
msg = MeshUtilityMessages.NO_GAMEOBJECT_SELECTED.Msg();
return false;
}
if (smr == null)
{
msg = MeshProcessingMessages.SELECT_SKINNED_MESH.Msg();
msg = MeshUtilityMessages.SELECT_SKINNED_MESH.Msg();
return false;
}

View File

@ -13,19 +13,19 @@ namespace UniGLTF.MeshUtility
// check
if (root == null)
{
msg = MeshProcessingMessages.NO_GAMEOBJECT_SELECTED.Msg();
msg = MeshUtilityMessages.NO_GAMEOBJECT_SELECTED.Msg();
return false;
}
if (HasVrm(root))
{
msg = MeshProcessingMessages.VRM_DETECTED.Msg();
msg = MeshUtilityMessages.VRM_DETECTED.Msg();
return false;
}
if (root.GetComponentsInChildren<SkinnedMeshRenderer>().Length == 0 && root.GetComponentsInChildren<MeshFilter>().Length == 0)
{
msg = MeshProcessingMessages.NO_MESH.Msg();
msg = MeshUtilityMessages.NO_MESH.Msg();
return false;
}

View File

@ -24,13 +24,13 @@ namespace UniGLTF.MeshUtility
{
if (root == null)
{
msg = MeshProcessingMessages.NO_GAMEOBJECT_SELECTED.Msg();
msg = MeshUtilityMessages.NO_GAMEOBJECT_SELECTED.Msg();
return false;
}
if (root.GetComponentsInChildren<SkinnedMeshRenderer>().Length == 0)
{
msg = MeshProcessingMessages.NO_SKINNED_MESH.Msg();
msg = MeshUtilityMessages.NO_SKINNED_MESH.Msg();
return false;
}

View File

@ -10,7 +10,6 @@ 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";
[MenuItem(UserGltfMenuPrefix + "/Version: " + UniGLTFVersion.UNIGLTF_VERSION, validate = true)]
@ -25,8 +24,8 @@ namespace UniGLTF
[MenuItem(UserGltfMenuPrefix + "/Import from GLTF (*.gltf|*.glb|*.zip)", priority = 2)]
private static void ImportGltfFile() => TopMenuImplementation.ImportGltfFileToGameObject();
[MenuItem(UserMeshUtilityPrefix + "/MeshProcessing Wizard", priority = 10)]
private static void OpenMeshProcessingWindow() => MeshUtility.MeshProcessDialog.OpenWindow();
[MenuItem(UserGltfMenuPrefix + "/MeshUtility Wizard", priority = 10)]
private static void OpenMeshProcessingWindow() => MeshUtility.MeshUtilityDialog.OpenWindow();
#if VRM_DEVELOP
[MenuItem(DevelopmentMenuPrefix + "/Generate Serialization Code", priority = 20)]