2025-04-25 21:14:54 +09:00

140 lines
5.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using UnityEditor;
using UniGLTF;
using UniGLTF.M17N;
using System.Collections.Generic;
using System.Linq;
namespace UniVRM10
{
public class Vrm10MeshUtilityDialog : UniGLTF.MeshUtility.MeshUtilityDialog
{
public new const string MENU_NAME = "VRM 1.0 MeshUtility";
public new static void OpenWindow()
{
var window =
(Vrm10MeshUtilityDialog)EditorWindow.GetWindow(typeof(Vrm10MeshUtilityDialog));
window.titleContent = new GUIContent(MENU_NAME);
window.Show();
}
protected override void Validate()
{
base.Validate();
if (_exportTarget.GetComponent<Vrm10Instance>() == null)
{
_validations.Add(Validation.Error("target is not vrm1"));
return;
}
}
Vrm10MeshUtility _meshUtil;
Vrm10MeshUtility Vrm10MeshUtility
{
get
{
if (_meshUtil == null)
{
_meshUtil = new Vrm10MeshUtility();
}
return _meshUtil;
}
}
protected override UniGLTF.MeshUtility.GltfMeshUtility MeshUtility => Vrm10MeshUtility;
Vrm10MeshIntegrationTab _integrationTab;
protected override UniGLTF.MeshUtility.MeshIntegrationTab MeshIntegration
{
get
{
if (_integrationTab == null)
{
_integrationTab = new Vrm10MeshIntegrationTab(this, Vrm10MeshUtility);
}
return _integrationTab;
}
}
protected override bool MeshIntegrateGui()
{
var firstPerson = ToggleIsModified("FirstPerson == AUTO の生成", ref MeshUtility.GenerateMeshForFirstPersonAuto);
var mod = base.MeshIntegrateGui();
return firstPerson || mod;
}
List<VRM10Expression> _clips;
protected override void WriteAssets(string assetFolder, GameObject instance,
List<UniGLTF.MeshUtility.MeshIntegrationResult> results)
{
_clips = Vrm10ExpressionUpdater.Update(assetFolder, instance, results).Values.ToList();
// write mesh
base.WriteAssets(assetFolder, instance, results);
}
protected override string WritePrefab(string assetFolder,
GameObject instance)
{
var prefabPath = base.WritePrefab(assetFolder, instance);
// PostProcess
// update prefab reference of BlendShapeClip
var prefabReference = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
foreach (var clip in _clips)
{
var so = new SerializedObject(clip);
so.Update();
var prop = so.FindProperty("m_prefab");
prop.objectReferenceValue = prefabReference;
so.ApplyModifiedProperties();
}
return prefabPath;
}
protected override void DialogMessage()
{
EditorGUILayout.HelpBox(Message.MESH_UTILITY.Msg(), MessageType.Info);
}
enum Message
{
[LangMsg(Languages.ja, @"(VRM-1.0専用) 凍結 > 統合 > 分割 という一連の処理を実行します。
[凍結]
- Mesh
- BlendShape Mesh
- VRM-1.0
- VRM-1.0
- HumanoidAvatar
- Expression, SpringBone, Constraint
[統合]
- MeshRenderer SkinnedMeshRenderer SkinnedMeshRenderer
- VRM FirstPerson (BOTH, FirstPerson, ThirdPerson)
- FirstPerson=AUTO
- Mesh ThirdPerson FirstPersonOnly
[分割]
- BlendShape
- BOTH, FirstPerson, ThirdPerson x 2 6Mesh 3Mesh
[Scene と Prefab]
Scene Prefab
(Scene/Runtime)
- UNDO可能
- Asset Unityを再起動すると Mesh Asset
(Prefab/Editor)
- prefab Asset
- Asset
- Undo
")]
[LangMsg(Languages.en, @"TODO
")]
MESH_UTILITY,
}
}
}