Skip to content

Commit

Permalink
[Gesture Manager 3.9.3] Release~
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackStartx committed Nov 23, 2024
1 parent f9148ca commit ea52537
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 122 deletions.
Binary file added .markdown/Debug/AnimatorDebug.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .v3rsion
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
3.9.2
https://github.com/BlackStartx/VRC-Gesture-Manager/releases/tag/v3.9.2
3.9.3
https://github.com/BlackStartx/VRC-Gesture-Manager/releases/tag/v3.9.3
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ You can switch between OSC Messages and OSC bundles by clicking the "Bundle" or

![img.png](.markdown/3.8/SendOsc.png)

# Animator Debugging

While testing your avatar you can control and preview the flow of your animators in the "Animator" window
of the Unity Editor and gain information on why the avatar is not behaving how you would expect.

Getting the preview of any Animator is very easy:

> Select your Avatar > Double-Click the Playable Layer
The Unity Animator window should open, and you can now preview the flow of the selected
Playable Layer, and dig up the reason on why things are not working as expected~

![img.gif](.markdown/Debug/AnimatorDebug.gif)

### Knew Issues
♥ All the knew issues since the release of 3.0 has been addressed! ♥

Expand Down
1 change: 1 addition & 0 deletions Scripts/Editor/Data/GestureManagerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private static void SimulationSettings(GestureManager manager)
GUILayout.Label("Default Parameters", GestureManagerStyles.ToolSubHeader);
GUILayout.Label("Set the initial states of the default parameters!", GestureManagerStyles.SettingsText);
using (new GUILayout.HorizontalScope()) DefaultParametersSettings(manager);
manager.settings.isOnFriendsList = GmgLayoutHelper.Toggle("IsOnFriendList: ", manager.settings.isOnFriendsList, manager);
}

private static void BlendShapeSettings(string label = "Blend-Shapes Clamping: ")
Expand Down
3 changes: 2 additions & 1 deletion Scripts/Editor/GestureManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public override VisualElement CreateInspectorGUI()
private void TryInitialize()
{
if (!Manager.enabled || !Manager.gameObject.activeInHierarchy || Manager.Module != null) return;
Manager.StartCoroutine(TryInitializeRoutine(ModuleHelper.GetModuleFor(Manager.settings.favourite)));
var enumerator = TryInitializeRoutine(ModuleHelper.GetModuleFor(Manager.settings.favourite));
Manager.StartCoroutine(enumerator);
}

private IEnumerator TryInitializeRoutine(ModuleBase module)
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Editor/Library/GmgLayoutHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static bool SettingsGearLabel(string text, bool active, int pixels = 25)
}
}

public static bool UnityFieldEnterListener<T1, T2>(T1 initialText, T2 argument, Rect rect, Func<Rect, T1, T1> field, Action<T2, T1> onEscape, string controlName)
public static bool UnityFieldEnterListener<T1, T2>(T1 initialText, T2 argument, Rect rect, Func<Rect, T1, T1> field, Action<T2, T1, object> onEscape, string controlName)
{
if (_unityFieldEnterListenerName != controlName) _unityFieldEnterListenerData = null;
var isEnter = Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter;
Expand All @@ -86,7 +86,7 @@ public static bool UnityFieldEnterListener<T1, T2>(T1 initialText, T2 argument,
GUI.FocusControl(controlName);
_unityFieldEnterListenerData ??= initialText;
var t = field(rect, _unityFieldEnterListenerData is T1 d ? d : default);
if (isEnter) onEscape(argument, _unityFieldEnterListenerData is T1 data ? data : default);
if (isEnter) onEscape(argument, _unityFieldEnterListenerData is T1 data ? data : default, null);
else _unityFieldEnterListenerData = t;
if (!isEnter && !isEscape) return false;
_unityFieldEnterListenerData = null;
Expand Down
61 changes: 56 additions & 5 deletions Scripts/Editor/Modules/Vrc3/AvatarDynamics/AvatarDynamicReset.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#if VRC_SDK_VRCSDK3
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using VRC.Dynamics;
using VRC.SDK3.Avatars.Components;
using VRC.SDK3.Dynamics.Contact.Components;
using VRC.SDK3.Dynamics.PhysBone;

namespace BlackStartX.GestureManager.Editor.Modules.Vrc3.AvatarDynamics
Expand All @@ -10,21 +14,42 @@ public static class AvatarDynamicReset
private const string TriggerManagerName = "TriggerManager";
private const string PhysBoneManagerName = "PhysBoneManager";

public static void CheckSceneCollisions()
private const VRCAvatarDescriptor.ColliderConfig.State Disabled = VRCAvatarDescriptor.ColliderConfig.State.Disabled;

private static readonly Dictionary<HumanBodyBones, (System.Func<VRCAvatarDescriptor, VRCAvatarDescriptor.ColliderConfig>, string[])> Bones = new()
{
{ HumanBodyBones.Head, (vrc => vrc.collider_head, new[] { "Head" }) },
{ HumanBodyBones.Chest, (vrc => vrc.collider_torso, new[] { "Torso" }) },
{ HumanBodyBones.LeftFoot, (vrc => vrc.collider_footL, new[] { "Foot", "FootL" }) },
{ HumanBodyBones.RightFoot, (vrc => vrc.collider_footR, new[] { "Foot", "FootR" }) },
{ HumanBodyBones.LeftHand, (vrc => vrc.collider_handL, new[] { "Hand", "HandL" }) },
{ HumanBodyBones.RightHand, (vrc => vrc.collider_handR, new[] { "Hand", "HandR" }) },
{ HumanBodyBones.LeftRingProximal, (vrc => vrc.collider_fingerRingL, new[] { "Finger", "FingerL", "FingerRing", "FingerRingL" }) },
{ HumanBodyBones.RightRingProximal, (vrc => vrc.collider_fingerRingR, new[] { "Finger", "FingerR", "FingerRing", "FingerRingR" }) },
{ HumanBodyBones.LeftIndexProximal, (vrc => vrc.collider_fingerIndexL, new[] { "Finger", "FingerL", "FingerIndex", "FingerIndexL" }) },
{ HumanBodyBones.RightIndexProximal, (vrc => vrc.collider_fingerIndexR, new[] { "Finger", "FingerR", "FingerIndex", "FingerIndexR" }) },
{ HumanBodyBones.LeftLittleProximal, (vrc => vrc.collider_fingerLittleL, new[] { "Finger", "FingerL", "FingerLittle", "FingerLittleL" }) },
{ HumanBodyBones.RightLittleProximal, (vrc => vrc.collider_fingerLittleR, new[] { "Finger", "FingerR", "FingerLittle", "FingerLittleR" }) },
{ HumanBodyBones.LeftMiddleProximal, (vrc => vrc.collider_fingerMiddleL, new[] { "Finger", "FingerL", "FingerMiddle", "FingerMiddleL" }) },
{ HumanBodyBones.RightMiddleProximal, (vrc => vrc.collider_fingerMiddleR, new[] { "Finger", "FingerR", "FingerMiddle", "FingerMiddleR" }) }
};

public static void CheckOrRestartManagers()
{
if (!ContactManager.Inst) ResumeContactManager();
if (!PhysBoneManager.Inst) ResumePhysBoneManager();
if (!ContactManager.Inst) RestartContactManager();
if (!PhysBoneManager.Inst) RestartPhysBoneManager();
}

private static void RecreateComponent<T>(T original) where T : Component
{
var type = original.GetType();
var component = original.gameObject.AddComponent(type);
foreach (var field in type.GetFields()) field.SetValue(component, field.GetValue(original));
component.hideFlags = original.hideFlags;
Object.DestroyImmediate(original);
}

private static void ResumeContactManager()
private static void RestartContactManager()
{
Object.DestroyImmediate(GameObject.Find(TriggerManagerName));
var obj = new GameObject(TriggerManagerName);
Expand All @@ -33,7 +58,7 @@ private static void ResumeContactManager()
foreach (var contact in Resources.FindObjectsOfTypeAll<ContactBase>()) RecreateComponent(contact);
}

private static void ResumePhysBoneManager()
private static void RestartPhysBoneManager()
{
Object.DestroyImmediate(GameObject.Find(PhysBoneManagerName));
var obj = new GameObject(PhysBoneManagerName);
Expand All @@ -44,6 +69,32 @@ private static void ResumePhysBoneManager()
obj.AddComponent<PhysBoneGrabHelper>();
foreach (var physBone in Resources.FindObjectsOfTypeAll<VRCPhysBoneBase>()) RecreateComponent(physBone);
}

public static void ReinstallAvatarColliders(ModuleVrc3 module)
{
var sEnumerable = module.Avatar.GetComponentsInChildren<VRCContactSender>().Where(sender => sender.hideFlags == HideFlags.HideAndDontSave);
foreach (var sender in sEnumerable) Object.DestroyImmediate(sender);
foreach (var pair in Bones)
{
var transform = module.AvatarAnimator.GetBoneTransform(pair.Key);
var collider = pair.Value.Item1(module.AvatarDescriptor);
if (!transform || collider.state == Disabled) continue;
Install(transform, collider, pair.Value.Item2);
}
}

private static void Install(Transform transform, VRCAvatarDescriptor.ColliderConfig collider, string[] tags)
{
var sender = transform.gameObject.AddComponent<VRCContactSender>();
sender.shapeType = ContactBase.ShapeType.Capsule;
sender.hideFlags = HideFlags.HideAndDontSave;
sender.position = collider.position;
sender.rotation = collider.rotation;
sender.collisionTags.AddRange(tags);
sender.rootTransform = transform;
sender.height = collider.height;
sender.radius = collider.radius;
}
}
}
#endif
Loading

0 comments on commit ea52537

Please sign in to comment.