Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContactParameterProvider ParameterType #209

Merged
merged 3 commits into from Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

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