mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-10 12:59:17 -05:00
add error messages for export validation
This commit is contained in:
@@ -25,29 +25,36 @@ namespace UniGLTF
|
||||
private static void ExportFromMenu()
|
||||
{
|
||||
var go = Selection.activeObject as GameObject;
|
||||
var path = EditorUtility.SaveFilePanel(
|
||||
"Save glb",
|
||||
"",
|
||||
go.name + ".glb",
|
||||
"glb");
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var gltf = new glTF();
|
||||
using (var exporter = new gltfExporter(gltf))
|
||||
if (go.transform.position == Vector3.zero &&
|
||||
go.transform.rotation == Quaternion.identity &&
|
||||
go.transform.localScale == Vector3.one)
|
||||
{
|
||||
exporter.Prepare(go);
|
||||
exporter.Export();
|
||||
}
|
||||
var bytes = gltf.ToGlbBytes();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
var path = EditorUtility.SaveFilePanel(
|
||||
"Save glb", "", go.name + ".glb", "glb");
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.StartsWithUnityAssetPath())
|
||||
var gltf = new glTF();
|
||||
using (var exporter = new gltfExporter(gltf))
|
||||
{
|
||||
exporter.Prepare(go);
|
||||
exporter.Export();
|
||||
}
|
||||
var bytes = gltf.ToGlbBytes();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
|
||||
if (path.StartsWithUnityAssetPath())
|
||||
{
|
||||
AssetDatabase.ImportAsset(path.ToUnityRelativePath());
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetDatabase.ImportAsset(path.ToUnityRelativePath());
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("Error", "Root's Position, Rotation and Scale need to be Default values.", "ok");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -152,6 +152,13 @@ namespace VRM
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (Source.transform.position != Vector3.zero ||
|
||||
Source.transform.rotation != Quaternion.identity ||
|
||||
Source.transform.localScale != Vector3.one)
|
||||
{
|
||||
yield return Validation.Error("Root's Position, Rotation and Scale need to be Default values.");
|
||||
}
|
||||
|
||||
var animator = Source.GetComponent<Animator>();
|
||||
if (animator == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user