mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-22 06:57:25 -05:00
tpose button on humanoid tab
This commit is contained in:
parent
0474d586b7
commit
29cbf879e2
|
|
@ -2,11 +2,22 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UniGLTF;
|
||||
using UniGLTF.M17N;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM
|
||||
namespace UniGLTF
|
||||
{
|
||||
public enum EnableTPose
|
||||
{
|
||||
[LangMsg(Languages.ja, "このボタンで自動で T-Pose にできます。手動で T-Pose にしたり、ボタンの後で手直ししてもOKです。")]
|
||||
[LangMsg(Languages.en, "T-Pose can be made automatically with this button, or you can make the model as T-Pose manually. Adjusting T-Pose manually after applying this function is also OK")]
|
||||
ENALBE_TPOSE_BUTTON,
|
||||
|
||||
[LangMsg(Languages.ja, "このボタンで自動で T-Pose にできます。prefab には実行できません。")]
|
||||
[LangMsg(Languages.en, "T-Pose can be made automatically with this button. It cannot be run on prefabs.")]
|
||||
DISABLE_TPOSE_BUTTON,
|
||||
}
|
||||
|
||||
public static class InternalTPose
|
||||
{
|
||||
struct TRS
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 42e52c1a93301da4eb0435ed00bdf8c4
|
||||
guid: 5af5e8f17a650a849bb2cde54c4cd8a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -2,10 +2,6 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UniGLTF;
|
||||
using UniGLTF.M17N;
|
||||
|
||||
namespace VRM
|
||||
|
|
@ -86,14 +82,6 @@ namespace VRM
|
|||
[LangMsg(Languages.en, "Vertex color will not be exported")]
|
||||
REMOVE_VERTEX_COLOR,
|
||||
|
||||
[LangMsg(Languages.ja, "このボタンで自動で T-Pose にできます。手動で T-Pose にしたり、ボタンの後で手直ししてもOKです。")]
|
||||
[LangMsg(Languages.en, "T-Pose can be made automatically with this button, or you can make the model as T-Pose manually. Adjusting T-Pose manually after applying this function is also OK")]
|
||||
ENALBE_TPOSE_BUTTON,
|
||||
|
||||
[LangMsg(Languages.ja, "このボタンで自動で T-Pose にできます。prefab には実行できません。")]
|
||||
[LangMsg(Languages.en, "T-Pose can be made automatically with this button. It cannot be run on prefabs.")]
|
||||
DISABLE_TPOSE_BUTTON,
|
||||
|
||||
[LangMsg(Languages.ja, "T-Pose にする")]
|
||||
[LangMsg(Languages.en, "Make T-Pose")]
|
||||
DO_TPOSE,
|
||||
|
|
@ -119,48 +107,6 @@ namespace VRM
|
|||
GUILayout.Space(20);
|
||||
var settings = (VRMExportSettings)target;
|
||||
var root = settings.Root;
|
||||
var backup = GUI.enabled;
|
||||
GUI.enabled = root.scene.IsValid();
|
||||
if (GUI.enabled)
|
||||
{
|
||||
EditorGUILayout.HelpBox(Options.ENALBE_TPOSE_BUTTON.Msg(), MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox(Options.DISABLE_TPOSE_BUTTON.Msg(), MessageType.Warning);
|
||||
}
|
||||
|
||||
//
|
||||
// T-Pose
|
||||
//
|
||||
if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg()))
|
||||
{
|
||||
if (settings.Root != null)
|
||||
{
|
||||
// fallback
|
||||
Undo.RecordObjects(settings.Root.GetComponentsInChildren<Transform>(), "tpose");
|
||||
VRMBoneNormalizer.EnforceTPose(settings.Root);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg() + "(unity internal)"))
|
||||
{
|
||||
if (settings.Root != null)
|
||||
{
|
||||
Undo.RecordObjects(settings.Root.GetComponentsInChildren<Transform>(), "tpose.internal");
|
||||
if (InternalTPose.TryMakePoseValid(settings.Root))
|
||||
{
|
||||
// done
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = backup;
|
||||
GUILayout.Space(20);
|
||||
|
||||
// ToDo: 任意の BlendShapeClip を適用する
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ namespace VRM
|
|||
{
|
||||
Meta,
|
||||
Mesh,
|
||||
Humanoid,
|
||||
BlendShape,
|
||||
ExportSettings,
|
||||
}
|
||||
|
|
@ -225,6 +226,52 @@ namespace VRM
|
|||
m_meshesInspector.OnInspectorGUI();
|
||||
break;
|
||||
|
||||
case Tabs.Humanoid:
|
||||
{
|
||||
var backup = GUI.enabled;
|
||||
GUI.enabled = State.ExportRoot.scene.IsValid();
|
||||
if (GUI.enabled)
|
||||
{
|
||||
EditorGUILayout.HelpBox(EnableTPose.ENALBE_TPOSE_BUTTON.Msg(), MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox(EnableTPose.DISABLE_TPOSE_BUTTON.Msg(), MessageType.Warning);
|
||||
}
|
||||
|
||||
//
|
||||
// T-Pose
|
||||
//
|
||||
if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg()))
|
||||
{
|
||||
if (State.ExportRoot != null)
|
||||
{
|
||||
// fallback
|
||||
Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren<Transform>(), "tpose");
|
||||
VRMBoneNormalizer.EnforceTPose(State.ExportRoot);
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button(VRMExportSettingsEditor.Options.DO_TPOSE.Msg() + "(unity internal)"))
|
||||
{
|
||||
if (State.ExportRoot != null)
|
||||
{
|
||||
Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren<Transform>(), "tpose.internal");
|
||||
if (InternalTPose.TryMakePoseValid(State.ExportRoot))
|
||||
{
|
||||
// done
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = backup;
|
||||
}
|
||||
break;
|
||||
|
||||
case Tabs.BlendShape:
|
||||
if (State.ExportRoot)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UniGLTF;
|
||||
using UniGLTF.M17N;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VrmLib;
|
||||
|
|
@ -25,6 +26,7 @@ namespace UniVRM10
|
|||
{
|
||||
Meta,
|
||||
Mesh,
|
||||
Humanoid,
|
||||
ExportSettings,
|
||||
}
|
||||
Tabs _tab;
|
||||
|
|
@ -134,34 +136,6 @@ namespace UniVRM10
|
|||
yield return meta.Validate;
|
||||
}
|
||||
|
||||
// private void OnGUI()
|
||||
// {
|
||||
// {
|
||||
// var path = SaveFileDialog.GetPath("Save vrm1", $"{State.ExportRoot.name}.vrm", "vrm");
|
||||
// if (!string.IsNullOrEmpty(path))
|
||||
// {
|
||||
// // export
|
||||
// Export(State.ExportRoot, path);
|
||||
// // close
|
||||
// Close();
|
||||
// GUIUtility.ExitGUI();
|
||||
// }
|
||||
// }
|
||||
// GUI.enabled = true;
|
||||
|
||||
// GUILayout.EndHorizontal();
|
||||
// }
|
||||
// GUILayout.EndVertical();
|
||||
// }
|
||||
|
||||
// GUILayout.Space(8);
|
||||
|
||||
// if (modified)
|
||||
// {
|
||||
// State.Invalidate();
|
||||
// }
|
||||
// }
|
||||
|
||||
protected override bool DoGUI()
|
||||
{
|
||||
if (m_tmpMeta == null)
|
||||
|
|
@ -196,6 +170,52 @@ namespace UniVRM10
|
|||
case Tabs.Mesh:
|
||||
// m_meshesInspector.OnInspectorGUI();
|
||||
break;
|
||||
|
||||
case Tabs.Humanoid:
|
||||
{
|
||||
//
|
||||
// T-Pose
|
||||
//
|
||||
// if (GUILayout.Button("T-Pose"))
|
||||
// {
|
||||
// if (State.ExportRoot != null)
|
||||
// {
|
||||
// // fallback
|
||||
// Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren<Transform>(), "tpose");
|
||||
// VRMBoneNormalizer.EnforceTPose(State.ExportRoot);
|
||||
// }
|
||||
// }
|
||||
|
||||
var backup = GUI.enabled;
|
||||
GUI.enabled = State.ExportRoot.scene.IsValid();
|
||||
if (GUI.enabled)
|
||||
{
|
||||
EditorGUILayout.HelpBox(EnableTPose.ENALBE_TPOSE_BUTTON.Msg(), MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox(EnableTPose.DISABLE_TPOSE_BUTTON.Msg(), MessageType.Warning);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("T-Pose" + "(unity internal)"))
|
||||
{
|
||||
if (State.ExportRoot != null)
|
||||
{
|
||||
Undo.RecordObjects(State.ExportRoot.GetComponentsInChildren<Transform>(), "tpose.internal");
|
||||
if (InternalTPose.TryMakePoseValid(State.ExportRoot))
|
||||
{
|
||||
// done
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = backup;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user