diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cdaa33..4a7ceb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Specify zh-* font to make the font normal ### Changed +- In ParameterProvider, the parameter type of PhysBone Contact Receiver is now the type corresponding to the receiver type. (#209) ### Removed diff --git a/Editor/VRChat/ParameterIntrospection/VRChatProviders/ContactParameterProvider.cs b/Editor/VRChat/ParameterIntrospection/VRChatProviders/ContactParameterProvider.cs index b2721d5..6b57bfa 100644 --- a/Editor/VRChat/ParameterIntrospection/VRChatProviders/ContactParameterProvider.cs +++ b/Editor/VRChat/ParameterIntrospection/VRChatProviders/ContactParameterProvider.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using System.Collections.Immutable; using VRC.SDK3.Dynamics.Contact.Components; +using VRC.Dynamics; +using UnityEngine; #endregion @@ -26,7 +28,7 @@ public IEnumerable GetSuppliedParameters(BuildContext context return new[] { new ProvidedParameter(_component.parameter, ParameterNamespace.Animator, _component, - VRChatBuiltinProviderPlugin.Instance, null) + VRChatBuiltinProviderPlugin.Instance, _component.receiverType == ContactReceiver.ReceiverType.Proximity ? AnimatorControllerParameterType.Float : AnimatorControllerParameterType.Bool) { IsAnimatorOnly = true, WantSynced = false, @@ -40,4 +42,4 @@ public IEnumerable GetSuppliedParameters(BuildContext context // no-op } } -} \ No newline at end of file +} diff --git a/UnitTests~/ParameterIntrospection/VRChatBindingsTest.cs b/UnitTests~/ParameterIntrospection/VRChatBindingsTest.cs index b222e22..5e7607b 100644 --- a/UnitTests~/ParameterIntrospection/VRChatBindingsTest.cs +++ b/UnitTests~/ParameterIntrospection/VRChatBindingsTest.cs @@ -4,6 +4,7 @@ using nadena.dev.ndmf; using NUnit.Framework; using UnityEngine; +using VRC.Dynamics; using VRC.SDK3.Avatars.Components; using VRC.SDK3.Avatars.ScriptableObjects; using VRC.SDK3.Dynamics.Contact.Components; @@ -78,10 +79,12 @@ public void VRCParams() Assert.AreEqual(1, parameters["syncedBool"].BitUsage); Assert.AreEqual(ParameterNamespace.Animator, parameters["syncedBool"].Namespace); Assert.IsTrue(parameters["syncedBool"].WantSynced); - } - - [Test] - public void TestContact() + } + + [TestCase(ContactReceiver.ReceiverType.Constant, AnimatorControllerParameterType.Bool)] + [TestCase(ContactReceiver.ReceiverType.OnEnter, AnimatorControllerParameterType.Bool)] + [TestCase(ContactReceiver.ReceiverType.Proximity, AnimatorControllerParameterType.Float)] + public void TestContact(ContactReceiver.ReceiverType receiverType, AnimatorControllerParameterType parameterType) { var root = CreateRoot("avatar"); var desc = root.GetComponent(); @@ -89,6 +92,7 @@ public void TestContact() var obj = CreateChild(root, "foo"); var contact = obj.AddComponent(); + contact.receiverType = receiverType; var parameters = ParameterInfo.ForUI.GetParametersForObject(obj) .ToImmutableDictionary(p => p.EffectiveName, p => p); @@ -100,7 +104,7 @@ public void TestContact() Assert.AreEqual(1, parameters.Count); var param = parameters["abc"]; - Assert.AreEqual(null, param.ParameterType); + Assert.AreEqual(parameterType, param.ParameterType); Assert.AreEqual(0, param.BitUsage); Assert.AreEqual(ParameterNamespace.Animator, param.Namespace); Assert.IsFalse(param.WantSynced);