Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TryGetComponent に書き換え #2380

Merged
merged 8 commits into from
Jul 25, 2024
16 changes: 11 additions & 5 deletions Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,21 @@ public void Export(GameObject root, Model model, ModelExporter converter, Export
int? thumbnailIndex) ExportVrm(GameObject root, Model model, ModelExporter converter,
VRM10ObjectMeta vrmMeta, List<glTFNode> nodes, ITextureExporter textureExporter)
{
var vrmController = root?.GetComponentOrThrow<Vrm10Instance>();
if (root == null)
{
throw new System.ArgumentNullException("root");
}

if (vrmMeta == null)
if (root.TryGetComponent<Vrm10Instance>(out var vrmController))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

リファクタ系の PullReq はリファクタだけにしてもらえると、 diff を読む時間をかなり減らせてうれしいです

{
if (vrmController?.Vrm?.Meta == null)
if (vrmMeta == null)
{
throw new NullReferenceException("metaObject is null");
if (vrmController.Vrm?.Meta == null)
{
throw new NullReferenceException("metaObject is null");
}
vrmMeta = vrmController.Vrm.Meta;
}
vrmMeta = vrmController.Vrm.Meta;
}

var vrm = new UniGLTF.Extensions.VRMC_vrm.VRMC_vrm
Expand Down