Skip to content

Commit

Permalink
NO_ACTIVE_MESH の判定方法を変更 vrm-c#511
Browse files Browse the repository at this point in the history
gameobject.activeSelf は prefab では false になる
  • Loading branch information
ousttrue committed Aug 17, 2020
1 parent 82254d5 commit f39618d
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ static Vector3 GetForward(Transform l, Transform r)
return Vector3.Cross(lr, Vector3.up);
}

static bool EnableRenderer(Renderer renderer)
{
if (renderer.transform.Ancestor().Any(x => !x.gameObject.activeSelf))
{
// 自分か祖先に !activeSelf がいる
return false;
}
if (!renderer.enabled)
{
return false;
}
return true;
}

/// <summary>
/// エクスポート可能か検証する
/// </summary>
Expand Down Expand Up @@ -167,7 +181,7 @@ public IEnumerable<Validation> Validate()
}

var renderers = ExportRoot.GetComponentsInChildren<Renderer>();
if (renderers.All(x => !x.gameObject.activeInHierarchy))
if (renderers.All(x => !EnableRenderer(x)))
{
yield return Validation.Error(Msg.NO_ACTIVE_MESH);
}
Expand Down Expand Up @@ -384,13 +398,13 @@ private void OnGUI()
Validation.Error(Msg.ROOT_WITHOUT_ROTATION_AND_SCALING_CHANGED).DrawGUI();
return;
}
if (!root.scene.IsValid())
{
// Prefab でシーンに出していないものを判定したい
// FIXME: もっと適切な判定があればそれに
Validation.Error(Msg.PREFAB_CANNOT_EXPORT).DrawGUI();
return;
}
// if (!root.scene.IsValid())
// {
// // Prefab でシーンに出していないものを判定したい
// // FIXME: もっと適切な判定があればそれに
// Validation.Error(Msg.PREFAB_CANNOT_EXPORT).DrawGUI();
// return;
// }
if (HasRotationOrScale(ExportRoot))
{
if (m_settings.PoseFreeze)
Expand Down

0 comments on commit f39618d

Please sign in to comment.