Skip to content

Commit

Permalink
ContactParameterProvider ParameterType (#209)
Browse files Browse the repository at this point in the history
* ContactParameterProvider ParameterType

* test

* changelog
  • Loading branch information
Narazaka committed Mar 26, 2024
1 parent 1359f7a commit 79e7f08
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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

Expand Down
Expand Up @@ -4,6 +4,8 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using VRC.SDK3.Dynamics.Contact.Components;
using VRC.Dynamics;
using UnityEngine;

#endregion

Expand All @@ -26,7 +28,7 @@ public IEnumerable<ProvidedParameter> 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,
Expand All @@ -40,4 +42,4 @@ public IEnumerable<ProvidedParameter> GetSuppliedParameters(BuildContext context
// no-op
}
}
}
}
14 changes: 9 additions & 5 deletions UnitTests~/ParameterIntrospection/VRChatBindingsTest.cs
Expand Up @@ -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;
Expand Down Expand Up @@ -78,17 +79,20 @@ 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<VRCAvatarDescriptor>();
desc.expressionParameters = ScriptableObject.CreateInstance<VRCExpressionParameters>();

var obj = CreateChild(root, "foo");
var contact = obj.AddComponent<VRCContactReceiver>();
contact.receiverType = receiverType;

var parameters = ParameterInfo.ForUI.GetParametersForObject(obj)
.ToImmutableDictionary(p => p.EffectiveName, p => p);
Expand All @@ -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);
Expand Down

0 comments on commit 79e7f08

Please sign in to comment.