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

Object Manipulator with XR Socket Interactor #11797

Closed
GennaroBaratta opened this issue Nov 11, 2023 Discussed in #11785 · 2 comments
Closed

Object Manipulator with XR Socket Interactor #11797

GennaroBaratta opened this issue Nov 11, 2023 Discussed in #11785 · 2 comments
Labels

Comments

@GennaroBaratta
Copy link

Discussed in #11785

Originally posted by crusher1025 September 29, 2023
Does the Object Manipulator script with the XR Socket Interactor script in Unity XRI? I was able to get XR Socket Interactor to work with the XR Grab Interactable but not Object Manupulator.

Hi all, has anyone been able to get the XR Socket Interactor to work with the ObjectManipulator?
I'm using Unity 2022.3.12f1 with MRTK3

SocketInteractor

The cube doesn't snap to the attachTransform, as if the socket doesn't exist

@github-actions github-actions bot added the MRTK3 label Nov 11, 2023
@GennaroBaratta
Copy link
Author

I found the problem.
XRSocketInteractor's StartSocketSnapping method is limited to accepting only the XRGrabInteractable type, which unfortunaly is not designed as an interface.

protected override void OnHoverEntered(HoverEnterEventArgs args)
{
    base.OnHoverEntered(args);
    if (!CanHoverSnap(args.interactableObject))
    {
        return;
    }

    if (args.interactableObject is XRGrabInteractable grabInteractable)
        StartSocketSnapping(grabInteractable);
}
protected virtual bool StartSocketSnapping(XRGrabInteractable grabInteractable)
{
    // If we've already started socket snapping this interactable, do nothing
    var interactablesSocketedCount = m_InteractablesWithSocketTransformer.Count;
    if (interactablesSocketedCount >= socketSnappingLimit ||
        m_InteractablesWithSocketTransformer.Contains(grabInteractable))
        return false;

    if (interactablesSocketedCount > 0 && ejectExistingSocketsWhenSnapping)
    {
        // Be sure to eject any existing grab interactable from the snap grab socket
        foreach (var interactable in m_InteractablesWithSocketTransformer.AsList())
        {
            interactable.RemoveSingleGrabTransformer(m_SocketGrabTransformer);
        }
        m_InteractablesWithSocketTransformer.Clear();
    }

    grabInteractable.AddSingleGrabTransformer(m_SocketGrabTransformer);
    m_InteractablesWithSocketTransformer.Add(grabInteractable);
    return true;
}

@AMollis
Copy link
Member

AMollis commented Nov 13, 2023

@morksvart .... MRTK3 is no longer supported in this repository. Please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity

However, issue is already known, see the following:

This is being fixed this with this PR:

@AMollis AMollis closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants