自動生成などでsubParametersがnullのメニューアセットを指定した場合にエラるのを回避 (#263)

* 自動生成などでsubParametersがnullのメニューアセットを指定した場合にエラるのを回避

* chore: add test for null subparameter field issue

---------

Co-authored-by: bd_ <bd_@nadena.dev>
This commit is contained in:
Narazaka 2023-04-10 20:18:59 +09:00 committed by GitHub
parent 00c683dd23
commit 00054c1a52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 4 deletions

View File

@ -0,0 +1,24 @@
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using UnityEngine;
using VRC.SDK3.Avatars.Components;
using VRC.SDK3.Avatars.ScriptableObjects;
namespace modular_avatar_tests
{
public class NullSubparameterTest : TestBase
{
[Test]
public void TestNullSubparametersField()
{
VRCExpressionsMenu menu = ScriptableObject.CreateInstance<VRCExpressionsMenu>();
var root = CreateRoot("root");
var avatar = root.GetComponent<VRCAvatarDescriptor>();
avatar.expressionsMenu = menu;
// This should not throw an exception
ParameterPolicy.ProbeParameters(root);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: af0baf421bd9450d974871db9d25c2c4
timeCreated: 1681041544

View File

@ -171,11 +171,14 @@ namespace nadena.dev.modular_avatar.core.editor
AddParam(control.parameter.name);
}
foreach (var subParam in control.subParameters)
if (control.subParameters != null)
{
if (!string.IsNullOrWhiteSpace(subParam.name))
foreach (var subParam in control.subParameters)
{
AddParam(subParam.name);
if (!string.IsNullOrWhiteSpace(subParam.name))
{
AddParam(subParam.name);
}
}
}
@ -314,4 +317,4 @@ namespace nadena.dev.modular_avatar.core.editor
parameters = newParams;
}
}
}
}