Skip to content

Commit

Permalink
fix: parameter introspection did not ignore EditorOnly objects (#399)
Browse files Browse the repository at this point in the history
Closes: #383
  • Loading branch information
bdunderscore authored Sep 16, 2024
1 parent 09001c1 commit 80d0983
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#397] `ComputeContext.FlushInvalidates` API

### Fixed
- [#399] Fix: Parameter introspection did not skip EditorOnly objects
- [#397] Fix: issues where `ComputeContext` flushes might not be processed at all
- [#398] Fix: NullReferenceError in `GetParameterRemappingsAt`

Expand Down
5 changes: 5 additions & 0 deletions Editor/VRChat/ParameterIntrospection/ParameterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ private IEnumerable<RegisteredParameter> GetParametersForObject(GameObject root,

foreach (Transform childTransform in root.transform)
{
if (childTransform.gameObject.CompareTag("EditorOnly"))
{
continue;
}

var childParams = GetParametersForObject(childTransform.gameObject, onConflict, remaps);

foreach (var rp in childParams)
Expand Down
28 changes: 28 additions & 0 deletions UnitTests~/ParameterIntrospection/ParameterIntrospectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,34 @@ public void SimpleUsage()
Assert.IsEmpty(parameters);
}

[Test]
public void EditorOnly()
{
var av = CreateRoot("avatar");

var desc = av.GetComponent<VRCAvatarDescriptor>();
desc.expressionParameters = ScriptableObject.CreateInstance<VRCExpressionParameters>();

var obj1 = CreateChild(av, "obj1");
var obj2 = CreateChild(av, "obj2");

var tc = obj1.AddComponent<ParamTestComponent>();
var p1 = new ProvidedParameter("p1", ParameterNamespace.Animator, tc, InternalPasses.Instance,
AnimatorControllerParameterType.Bool);
ParamTestComponentProvider.SetParameters(tc, p1);

var tc2 = obj2.AddComponent<ParamTestComponent>();
var p2 = new ProvidedParameter("p2", ParameterNamespace.Animator, tc2, InternalPasses.Instance,
AnimatorControllerParameterType.Bool);
ParamTestComponentProvider.SetParameters(tc2, p2);

obj1.tag = "EditorOnly";

var parameters = ParameterInfo.ForUI.GetParametersForObject(av).ToList();
Assert.AreEqual(1, parameters.Count());
Assert.AreEqual(p2, parameters[0]);
}

[Test]
public void SimpleRemap()
{
Expand Down

0 comments on commit 80d0983

Please sign in to comment.