From 80d09837abf0834d03bff98ecd082bc4432a045a Mon Sep 17 00:00:00 2001 From: bd_ Date: Sun, 15 Sep 2024 23:13:26 -0400 Subject: [PATCH] fix: parameter introspection did not ignore EditorOnly objects (#399) Closes: #383 --- CHANGELOG.md | 1 + .../ParameterIntrospection/ParameterInfo.cs | 5 ++++ .../ParameterIntrospectionTest.cs | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2687998b..22446ed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/Editor/VRChat/ParameterIntrospection/ParameterInfo.cs b/Editor/VRChat/ParameterIntrospection/ParameterInfo.cs index 3c6e051d..37ea7272 100644 --- a/Editor/VRChat/ParameterIntrospection/ParameterInfo.cs +++ b/Editor/VRChat/ParameterIntrospection/ParameterInfo.cs @@ -228,6 +228,11 @@ private IEnumerable 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) diff --git a/UnitTests~/ParameterIntrospection/ParameterIntrospectionTest.cs b/UnitTests~/ParameterIntrospection/ParameterIntrospectionTest.cs index 8ed3402d..c0db51ee 100644 --- a/UnitTests~/ParameterIntrospection/ParameterIntrospectionTest.cs +++ b/UnitTests~/ParameterIntrospection/ParameterIntrospectionTest.cs @@ -62,6 +62,34 @@ public void SimpleUsage() Assert.IsEmpty(parameters); } + [Test] + public void EditorOnly() + { + var av = CreateRoot("avatar"); + + var desc = av.GetComponent(); + desc.expressionParameters = ScriptableObject.CreateInstance(); + + var obj1 = CreateChild(av, "obj1"); + var obj2 = CreateChild(av, "obj2"); + + var tc = obj1.AddComponent(); + var p1 = new ProvidedParameter("p1", ParameterNamespace.Animator, tc, InternalPasses.Instance, + AnimatorControllerParameterType.Bool); + ParamTestComponentProvider.SetParameters(tc, p1); + + var tc2 = obj2.AddComponent(); + 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() {