mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-12 05:24:14 -05:00
require Title & Author when export
This commit is contained in:
parent
3e9bd61601
commit
6def0c706d
|
|
@ -12,13 +12,19 @@ namespace VRM
|
|||
public VRMExporter(glTF_VRM gltf) : base(gltf)
|
||||
{ }
|
||||
|
||||
public static glTF Export(GameObject go, string path = null)
|
||||
public static glTF Export(GameObject go, string path = null, Action<glTF_VRM> callback=null)
|
||||
{
|
||||
var gltf = new glTF_VRM();
|
||||
gltf.asset.generator = "Unity VRM Exporter";
|
||||
using (var exporter = new VRMExporter(gltf))
|
||||
{
|
||||
_Export(gltf, exporter, go);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback(gltf);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
exporter.WriteTo(path);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using UnityEditor;
|
|||
using UnityEngine;
|
||||
using UniGLTF;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
|
|
@ -12,6 +13,11 @@ namespace VRM
|
|||
const string EXTENSION = ".vrm";
|
||||
|
||||
public GameObject Target;
|
||||
VRMMeta m_meta;
|
||||
|
||||
public string Title;
|
||||
|
||||
public string Author;
|
||||
|
||||
public bool ForceTPose;
|
||||
|
||||
|
|
@ -30,24 +36,50 @@ namespace VRM
|
|||
wiz.ForceTPose = true;
|
||||
wiz.PoseFreeze = true;
|
||||
}
|
||||
|
||||
var meta = wiz.Target.GetComponent<VRMMeta>();
|
||||
if (meta != null && meta.Meta != null)
|
||||
{
|
||||
wiz.Title = meta.Meta.Title;
|
||||
wiz.Author = meta.Meta.Author;
|
||||
}
|
||||
else
|
||||
{
|
||||
wiz.Title = wiz.Target.name;
|
||||
}
|
||||
}
|
||||
|
||||
static string m_dir = Path.GetFullPath(Application.dataPath);
|
||||
string m_dir;
|
||||
string Dir
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_dir == null)
|
||||
{
|
||||
m_dir = Path.GetFullPath(Application.dataPath); ;
|
||||
}
|
||||
return m_dir;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_dir = value;
|
||||
}
|
||||
}
|
||||
|
||||
void OnWizardCreate()
|
||||
{
|
||||
// save dialog
|
||||
Debug.LogFormat("OnWizardCreate: {0}", m_dir);
|
||||
Debug.LogFormat("OnWizardCreate: {0}", Dir);
|
||||
var path = EditorUtility.SaveFilePanel(
|
||||
"Save vrm",
|
||||
m_dir,
|
||||
Dir,
|
||||
Target.name + EXTENSION,
|
||||
EXTENSION.Substring(1));
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_dir = Path.GetDirectoryName(path);
|
||||
Dir = Path.GetDirectoryName(path);
|
||||
|
||||
// export
|
||||
var target = Target;
|
||||
|
|
@ -60,7 +92,12 @@ namespace VRM
|
|||
Undo.PerformUndo();
|
||||
}
|
||||
|
||||
VRMExporter.Export(target, path);
|
||||
VRMExporter.Export(target, path, gltf => {
|
||||
|
||||
gltf.extensions.VRM.meta.title = Title;
|
||||
gltf.extensions.VRM.meta.author = Author;
|
||||
|
||||
});
|
||||
|
||||
if (Target!=target)
|
||||
{
|
||||
|
|
@ -75,8 +112,26 @@ namespace VRM
|
|||
|
||||
void OnWizardUpdate()
|
||||
{
|
||||
helpString = @"select humanoid root(require Animator with valid humanoid avatar).
|
||||
";
|
||||
isValid = true;
|
||||
var helpBuilder = new StringBuilder();
|
||||
var errorBuilder = new StringBuilder();
|
||||
|
||||
helpBuilder.Append("select humanoid root(require Animator with valid humanoid avatar).\n");
|
||||
|
||||
if (string.IsNullOrEmpty(Title))
|
||||
{
|
||||
isValid = false;
|
||||
errorBuilder.Append("input vrm Title\n");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Author))
|
||||
{
|
||||
isValid = false;
|
||||
errorBuilder.Append("input vrm Author\n");
|
||||
}
|
||||
|
||||
helpString = helpBuilder.ToString();
|
||||
errorString = errorBuilder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ namespace VRM
|
|||
public static class VRMVersion
|
||||
{
|
||||
public const int MAJOR = 0;
|
||||
public const int MINOR = 27;
|
||||
public const int MINOR = 28;
|
||||
|
||||
public const string VERSION = "0.27";
|
||||
public const string VERSION = "0.28";
|
||||
|
||||
public const string DecrementMenuName = "VRM/Version(0.27) Decrement";
|
||||
public const string IncrementMenuName = "VRM/Version(0.27) Increment";
|
||||
public const string DecrementMenuName = "VRM/Version(0.28) Decrement";
|
||||
public const string IncrementMenuName = "VRM/Version(0.28) Increment";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user