mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-11 13:29:41 -05:00
VRMExporterWizard use VRMMetaObjectEditor
This commit is contained in:
@@ -213,11 +213,11 @@ namespace VRM
|
||||
ExportOnlyBlendShapePosition = settings.OnlyBlendshapePosition,
|
||||
RemoveVertexColor = settings.RemoveVertexColor
|
||||
});
|
||||
vrm.extensions.VRM.meta.title = settings.Title;
|
||||
vrm.extensions.VRM.meta.version = settings.Version;
|
||||
vrm.extensions.VRM.meta.author = settings.Author;
|
||||
vrm.extensions.VRM.meta.contactInformation = settings.ContactInformation;
|
||||
vrm.extensions.VRM.meta.reference = settings.Reference;
|
||||
// vrm.extensions.VRM.meta.title = settings.Title;
|
||||
// vrm.extensions.VRM.meta.version = settings.Version;
|
||||
// vrm.extensions.VRM.meta.author = settings.Author;
|
||||
// vrm.extensions.VRM.meta.contactInformation = settings.ContactInformation;
|
||||
// vrm.extensions.VRM.meta.reference = settings.Reference;
|
||||
|
||||
var bytes = vrm.ToGlbBytes(settings.UseExperimentalExporter ? SerializerTypes.Generated : SerializerTypes.UniJSON);
|
||||
File.WriteAllBytes(path, bytes);
|
||||
|
||||
@@ -16,32 +16,32 @@ namespace VRM
|
||||
/// </summary>
|
||||
public GameObject Source;
|
||||
|
||||
#region Meta
|
||||
/// <summary>
|
||||
/// エクスポート名
|
||||
/// </summary>
|
||||
public string Title;
|
||||
// #region Meta
|
||||
// /// <summary>
|
||||
// /// エクスポート名
|
||||
// /// </summary>
|
||||
// public string Title;
|
||||
|
||||
/// <summary>
|
||||
/// エクスポートバージョン(エクスポートするModelのバージョン)
|
||||
/// </summary>
|
||||
public string Version;
|
||||
// /// <summary>
|
||||
// /// エクスポートバージョン(エクスポートするModelのバージョン)
|
||||
// /// </summary>
|
||||
// public string Version;
|
||||
|
||||
/// <summary>
|
||||
/// 作者
|
||||
/// </summary>
|
||||
public string Author;
|
||||
// /// <summary>
|
||||
// /// 作者
|
||||
// /// </summary>
|
||||
// public string Author;
|
||||
|
||||
/// <summary>
|
||||
/// 作者連絡先
|
||||
/// </summary>
|
||||
public string ContactInformation;
|
||||
// /// <summary>
|
||||
// /// 作者連絡先
|
||||
// /// </summary>
|
||||
// public string ContactInformation;
|
||||
|
||||
/// <summary>
|
||||
/// 作品引用
|
||||
/// </summary>
|
||||
public string Reference;
|
||||
#endregion
|
||||
// /// <summary>
|
||||
// /// 作品引用
|
||||
// /// </summary>
|
||||
// public string Reference;
|
||||
// #endregion
|
||||
|
||||
#region Settings
|
||||
/// <summary>
|
||||
@@ -189,18 +189,18 @@ namespace VRM
|
||||
yield return Validation.Warning("There is a bone with the same name in the hierarchy. If exported, these bones will be automatically renamed.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Title))
|
||||
{
|
||||
yield return Validation.Error("Require Title. ");
|
||||
}
|
||||
if (string.IsNullOrEmpty(Version))
|
||||
{
|
||||
yield return Validation.Error("Require Version. ");
|
||||
}
|
||||
if (string.IsNullOrEmpty(Author))
|
||||
{
|
||||
yield return Validation.Error("Require Author. ");
|
||||
}
|
||||
// if (string.IsNullOrEmpty(Title))
|
||||
// {
|
||||
// yield return Validation.Error("Require Title. ");
|
||||
// }
|
||||
// if (string.IsNullOrEmpty(Version))
|
||||
// {
|
||||
// yield return Validation.Error("Require Version. ");
|
||||
// }
|
||||
// if (string.IsNullOrEmpty(Author))
|
||||
// {
|
||||
// yield return Validation.Error("Require Author. ");
|
||||
// }
|
||||
|
||||
if (ReduceBlendshape && Source.GetComponent<VRMBlendShapeProxy>() == null)
|
||||
{
|
||||
@@ -331,19 +331,19 @@ namespace VRM
|
||||
// Meta
|
||||
//
|
||||
var meta = Source == null ? null : go.GetComponent<VRMMeta>();
|
||||
if (meta != null && meta.Meta != null)
|
||||
{
|
||||
Title = meta.Meta.Title;
|
||||
Version = string.IsNullOrEmpty(meta.Meta.Version) ? "0.0" : meta.Meta.Version;
|
||||
Author = meta.Meta.Author;
|
||||
ContactInformation = meta.Meta.ContactInformation;
|
||||
Reference = meta.Meta.Reference;
|
||||
}
|
||||
else
|
||||
{
|
||||
Title = go.name;
|
||||
Version = "0.0";
|
||||
}
|
||||
// if (meta != null && meta.Meta != null)
|
||||
// {
|
||||
// Title = meta.Meta.Title;
|
||||
// Version = string.IsNullOrEmpty(meta.Meta.Version) ? "0.0" : meta.Meta.Version;
|
||||
// Author = meta.Meta.Author;
|
||||
// ContactInformation = meta.Meta.ContactInformation;
|
||||
// Reference = meta.Meta.Reference;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Title = go.name;
|
||||
// Version = "0.0";
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,29 @@ namespace VRM
|
||||
/// </summary>
|
||||
public class VRMExporterWizard : EditorWindow
|
||||
{
|
||||
[SerializeField]
|
||||
public VRMExportSettings m_settings = new VRMExportSettings();
|
||||
|
||||
VRMMetaObject m_meta;
|
||||
VRMMetaObject Meta
|
||||
{
|
||||
get { return m_meta; }
|
||||
set
|
||||
{
|
||||
if (m_meta == value) return;
|
||||
if (m_meta != null)
|
||||
{
|
||||
UnityEditor.Editor.DestroyImmediate(m_metaEditor);
|
||||
}
|
||||
m_meta = value;
|
||||
if (m_meta != null)
|
||||
{
|
||||
m_metaEditor = Editor.CreateEditor(m_meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Editor m_metaEditor;
|
||||
Editor m_Inspector;
|
||||
|
||||
private string m_HelpString = "";
|
||||
@@ -26,6 +49,7 @@ namespace VRM
|
||||
private void OnDestroy()
|
||||
{
|
||||
UnityEditor.Editor.DestroyImmediate(m_Inspector);
|
||||
Meta = null;
|
||||
}
|
||||
|
||||
private void InvokeWizardUpdate()
|
||||
@@ -118,11 +142,17 @@ namespace VRM
|
||||
|
||||
protected virtual bool DrawWizardGUI()
|
||||
{
|
||||
if (m_Inspector == null)
|
||||
if (m_metaEditor != null)
|
||||
{
|
||||
m_Inspector = Editor.CreateEditor(this);
|
||||
m_metaEditor.OnInspectorGUI();
|
||||
}
|
||||
{
|
||||
if (m_Inspector == null)
|
||||
{
|
||||
m_Inspector = Editor.CreateEditor(this);
|
||||
}
|
||||
m_Inspector.OnInspectorGUI();
|
||||
}
|
||||
m_Inspector.OnInspectorGUI();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -251,12 +281,8 @@ namespace VRM
|
||||
|
||||
const string EXTENSION = ".vrm";
|
||||
|
||||
VRMMeta m_meta;
|
||||
|
||||
private static string m_lastExportDir;
|
||||
|
||||
public VRMExportSettings m_settings = new VRMExportSettings();
|
||||
|
||||
public static void CreateWizard()
|
||||
{
|
||||
var wiz = VRMExporterWizard.DisplayWizard<VRMExporterWizard>(
|
||||
@@ -326,6 +352,21 @@ namespace VRM
|
||||
|
||||
helpString = helpBuilder.ToString();
|
||||
errorString = errorBuilder.ToString();
|
||||
|
||||
if (m_settings.Source == null)
|
||||
{
|
||||
Meta = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var meta = m_settings.Source.GetComponent<VRMMeta>();
|
||||
if (meta != null)
|
||||
{
|
||||
Meta = meta.Meta;
|
||||
}
|
||||
}
|
||||
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user