-
Notifications
You must be signed in to change notification settings - Fork 421
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
TryGetComponent に書き換え #2380
Conversation
@@ -137,7 +137,7 @@ public static IEnumerable<Validation> Validate_TPose(GameObject ExportRoot) | |||
{ | |||
getBoneTransform = humanoid.GetBoneTransform; | |||
} | |||
else if (ExportRoot.GetComponent<Animator>() is Animator animator) | |||
else if (ExportRoot.GetComponent<Animator>() is Animator animator && animator != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
とりあえずこれで直るのだけど、他の場所にもありそう・・・
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この目的なら TryGetComponent<T>
が良いと思われます
https://docs.unity3d.com/2021.3/Documentation/ScriptReference/Component.TryGetComponent.html
間違えた、Request Changes です |
ついでなので、他の場所も TryGetComponent に書き換えます。 |
TryGetComponent GetComponentOrThrow(拡張関数) GetComponentOrNull(拡張関数) sample と test は据え置き
Animator.GetBoneTransform のために GetComponent しているところの Export Error を修正するついでに、 Animator.GetBoneTransform と Humanoid.GetBoneTransform 両対応とした(vrm-0.x と vrm-1.0 両方)。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
if (vrmMeta == null) | ||
if (root.TryGetComponent<Vrm10Instance>(out var vrmController)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
リファクタ系の PullReq はリファクタだけにしてもらえると、 diff を読む時間をかなり減らせてうれしいです
エラー
attach されていない場合でも is 演算子が true になって後続で例外になる
再現手順。
vrm-1.0 の seed-san vrm の拡張子を glb に変える。
glb として import して、prefab をシーンに展開。
VRM-1.0 の export dialog に投入する。
備考
UnityのGetCompornent()でNull条件演算子が使えない
に類似する問題と思われる。
#2319 と現象が似ている。
Validation で繰り返し例外が発生してしまう。