mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 02:35:06 +08:00
自動生成などで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:
parent
00c683dd23
commit
00054c1a52
24
Assets/_ModularAvatar/EditModeTests/NullSubparameterTest.cs
Normal file
24
Assets/_ModularAvatar/EditModeTests/NullSubparameterTest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af0baf421bd9450d974871db9d25c2c4
|
||||
timeCreated: 1681041544
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user