add error messages for export validation

This commit is contained in:
PoChangSu
2020-06-29 13:24:34 +09:00
parent f20072e543
commit e7928df229
2 changed files with 33 additions and 19 deletions

View File

@@ -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

View File

@@ -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)
{