mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-10 04:49:28 -05:00
Merge pull request #775 from ichi-23/ichi/fix_export_root_animation
ExportRoot を animate する Animation を Export するときの挙動を修正
This commit is contained in:
3
Assets/UniGLTF/Editor/Animation.meta
Normal file
3
Assets/UniGLTF/Editor/Animation.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31c3691403d341e2a9b49d6eb895e013
|
||||
timeCreated: 1615194750
|
||||
57
Assets/UniGLTF/Editor/Animation/AnimationValidator.cs
Normal file
57
Assets/UniGLTF/Editor/Animation/AnimationValidator.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MeshUtility;
|
||||
using MeshUtility.M17N;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF.Animation
|
||||
{
|
||||
public static class AnimationValidator
|
||||
{
|
||||
private enum ExporterValidatorMessages
|
||||
{
|
||||
[LangMsg(Languages.ja, "ExportRootをanimateすることはできません")]
|
||||
[LangMsg(Languages.en, "ExportRoot cannot be animated")]
|
||||
ROOT_ANIMATED,
|
||||
}
|
||||
|
||||
public static IEnumerable<Validation> Validate(GameObject root)
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var animationClips = new List<AnimationClip>();
|
||||
var animator = root.GetComponent<Animator>();
|
||||
var animation = root.GetComponent<UnityEngine.Animation>();
|
||||
if (animator != null)
|
||||
{
|
||||
animationClips = AnimationExporter.GetAnimationClips(animator);
|
||||
}
|
||||
else if (animation != null)
|
||||
{
|
||||
animationClips = AnimationExporter.GetAnimationClips(animation);
|
||||
}
|
||||
|
||||
if (!animationClips.Any())
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var animationClip in animationClips)
|
||||
{
|
||||
foreach (var editorCurveBinding in AnimationUtility.GetCurveBindings(animationClip))
|
||||
{
|
||||
// is root included in animation?
|
||||
if (string.IsNullOrEmpty(editorCurveBinding.path))
|
||||
{
|
||||
yield return Validation.Error(ExporterValidatorMessages.ROOT_ANIMATED.Msg());
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f8cc79b14e847b6a9f12c3ff2631661
|
||||
timeCreated: 1615188291
|
||||
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using MeshUtility.M17N;
|
||||
using UniGLTF.Animation;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -123,6 +123,7 @@ namespace UniGLTF
|
||||
IEnumerable<MeshUtility.Validator> ValidatorFactory()
|
||||
{
|
||||
yield return MeshUtility.Validators.HierarchyValidator.ValidateRoot;
|
||||
yield return AnimationValidator.Validate;
|
||||
if (!m_state.ExportRoot)
|
||||
{
|
||||
yield break;
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace UniGLTF
|
||||
{
|
||||
var current = self;
|
||||
|
||||
var split = path.Split('/');
|
||||
var split = path.Split(new [] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (var childName in split)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user