mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-11 13:29:41 -05:00
Merge pull request #531 from ousttrue/fix/exporter_validation_nullcheck
Fix/exporter validation nullcheck
This commit is contained in:
@@ -706,6 +706,11 @@ namespace VRM
|
||||
m_validations.Clear();
|
||||
m_validations.AddRange(Validate());
|
||||
m_validations.AddRange(VRMSpringBoneValidator.Validate(ExportRoot));
|
||||
var firstPerson = ExportRoot.GetComponent<VRMFirstPerson>();
|
||||
if (firstPerson != null)
|
||||
{
|
||||
m_validations.AddRange(firstPerson.Validate());
|
||||
}
|
||||
var hasError = m_validations.Any(x => !x.CanExport);
|
||||
m_IsValid = !hasError && !MetaHasError;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace VRM
|
||||
[LangMsg(Languages.en, "Animator.avatar is not humanoid. Please change model's AnimationType to humanoid")]
|
||||
AVATAR_IS_NOT_HUMANOID,
|
||||
|
||||
[LangMsg(Languages.ja, "humanoid設定に顎が含まれている。FBX importer の rig 設定に戻って設定を解除することをおすすめします")]
|
||||
[LangMsg(Languages.ja, "humanoid設定に顎が含まれている。FBX importer の rig 設定で顎ボーンの割り当てを確認できます")]
|
||||
[LangMsg(Languages.en, "Jaw bone is included. It may not what you intended. Please check the humanoid avatar setting screen")]
|
||||
JAW_BONE_IS_INCLUDED,
|
||||
|
||||
|
||||
@@ -14,12 +14,26 @@ namespace VRM
|
||||
yield break;
|
||||
}
|
||||
|
||||
var hierarchy = root.GetComponentsInChildren<Transform>();
|
||||
|
||||
Dictionary<Transform, List<VRMSpringBone>> rootMap = new Dictionary<Transform, List<VRMSpringBone>>();
|
||||
|
||||
foreach (var sb in root.GetComponentsInChildren<VRMSpringBone>())
|
||||
{
|
||||
foreach (var springRoot in sb.RootBones)
|
||||
for (int i = 0; i < sb.RootBones.Count; ++i)
|
||||
{
|
||||
var springRoot = sb.RootBones[i];
|
||||
if (springRoot == null)
|
||||
{
|
||||
yield return Validation.Error($"{sb.name}.RootBones[{i}] is null");
|
||||
continue;
|
||||
}
|
||||
if (!hierarchy.Contains(springRoot))
|
||||
{
|
||||
yield return Validation.Error($"{sb.name}.RootBones[{i}] is out of hierarchy");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rootMap.TryGetValue(springRoot, out List<VRMSpringBone> list))
|
||||
{
|
||||
list = new List<VRMSpringBone>();
|
||||
@@ -27,6 +41,21 @@ namespace VRM
|
||||
}
|
||||
list.Add(sb);
|
||||
}
|
||||
|
||||
for (int i = 0; i < sb.ColliderGroups.Length; ++i)
|
||||
{
|
||||
var c = sb.ColliderGroups[i];
|
||||
if (c == null)
|
||||
{
|
||||
yield return Validation.Error($"{sb.name}.ColliderGroups[{i}] is null");
|
||||
continue;
|
||||
}
|
||||
if (!hierarchy.Contains(c.transform))
|
||||
{
|
||||
yield return Validation.Error($"{sb.name}.ColliderGroups[{i}] is out of hierarchy");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var kv in rootMap)
|
||||
|
||||
@@ -50,17 +50,23 @@ namespace VRM
|
||||
[SerializeField]
|
||||
public List<RendererFirstPersonFlags> Renderers = new List<RendererFirstPersonFlags>();
|
||||
|
||||
static IEnumerable<Transform> Traverse(Transform parent)
|
||||
public IEnumerable<Validation> Validate()
|
||||
{
|
||||
yield return parent;
|
||||
var hierarchy = GetComponentsInChildren<Transform>();
|
||||
|
||||
foreach (Transform child in parent)
|
||||
for (int i = 0; i < Renderers.Count; ++i)
|
||||
{
|
||||
foreach (var x in Traverse(child))
|
||||
var r = Renderers[i];
|
||||
if (r.Renderer == null)
|
||||
{
|
||||
yield return x;
|
||||
yield return Validation.Error($"{name}.Renderers[{i}].Renderer is null");
|
||||
}
|
||||
if (!hierarchy.Contains(r.Renderer.transform))
|
||||
{
|
||||
yield return Validation.Error($"{name}.Renderers[{i}].Renderer is out of hierarchy");
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
public void CopyTo(GameObject _dst, Dictionary<Transform, Transform> map)
|
||||
|
||||
Reference in New Issue
Block a user