Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

update TapToPlaceParent for holotoolkit

how can i use the same functionality of TapToPlaceParent on a personal project using holotoolkit

thx

Best Answer

Answers

  • Options
    edited April 2016

    So i did this last week for a popup toolbar :). It was a little bit of a process for something that seems so mindless to tackle. But to be fair it was my first unity project ever.
    What i have written is a bit different then the hololens examples but i used galaxy explorer,240,210,211 code examples for help.

    This is a very high level overview.

    On My Main Toolbar Game Object

    From Hololens Toolkit
    Face Camera
    Gaze Manager
    Gesture Manager
    Then my custom class
    ToolbarPlacement:

    This is my toolbar placement class stripped down to only placement stuff
    //app state manager needs to understand the state of the toolbar.. "Get" should stay public..
    public bool IsToolbarPlaced { get; private set; }

    `
    void Start()
    {
    GestureManager.Instance.OverrideFocusedObject = this.gameObject;
    }
    void Update()
    {
    //If the toolbar is not placed follow the cursor
    if (IsToolbarPlaced == false)
    {
    transform.TransformDirection(ProposeTransformPosition());
    trackingPosition = transform.position;
    transform.position = Vector3.Lerp(transform.position, ProposeTransformPosition(), 0.2f);
    }
    }
    void PlaceToolbar()
    {
    IsToolbarPlaced = true;
    GestureManager.Instance.OverrideFocusedObject = null;
    }
    Vector3 ProposeTransformPosition()
    {
    // Put the anchor 2m in front of the user.
    Vector3 retval = Camera.main.transform.position + Camera.main.transform.forward * 2;
    //retval.y = retval.y - 1;
    return retval;
    }

    //This is called from GestureRecognizer it should call out to any object that has focus and the onselect method
    public void OnSelect()
    {
    //If the toolbar is not place place it on user click from the gazeselectiontarget
    if (!IsToolbarPlaced)
    {
    PlaceToolbar();
    }

    }`
    

    Thanks

    Calzaretta

  • Options

    any other suggestions ?

  • Options

    help!!!!

  • Options
    Not sure what you need help with. what are your troubles?
  • Options

    i have 4 buttons, 1st ,is play animation, 2nd, is pause, and 3rd, is reset position.
    So, what i want to do with the 4th is when i tap, the whole game object (buttons and all) will follow users gaze and stick to flat surfaces.
    when the user taps again it will stick to the surface it is on.

    pic of hierarchy

    Hopefully you understand now :smiley:

    1.PNG 93.8K
    2.PNG 6.6K
  • Options
    edited April 2016

    So on your gameobject place the face camera, gesture manager script and gaze manager script. The box collider is not enabled on my game object.. Not sure if this makes a different but just wanted to state that.

    Then on your button you want the gaze to follow your hologram you will need to have a script like i pasted above to move the position of the hologram on update

    Hope this helps

    Let me know if you have any more questions.

    Thanks

    Calzaretta

  • Options

    kk ill try
    but one more question ,whats face camera script?
    i can't find it in the kit.

    thx

  • Options

    @Calzaretta said:
    So on your gameobject place the face camera, gesture manager script and gaze manager script. The box collider is not enabled on my game object.. Not sure if this makes a different but just wanted to state that.

    Then on your button you want the gaze to follow your hologram you will need to have a script like i pasted above to move the position of the hologram on update

    Hope this helps

    Let me know if you have any more questions.

    Thanks

    Calzaretta

    is a sphere collider ok?

  • Options

    I think if i remember correct the face Camera was included in the Galaxy Explorer project.
    As i was building a toolbar i kind of cloned what the Galaxy Explorer does and expanded on it.

    The face camera script makes it so
    " the object will face the camera while maintaining a world up"
    or
    " the object will face the camera while maintaining a camera up."

  • Options

    I dont know. I done use the sphere collider.

  • Options

    wow you are quite a pro

  • Options

    so face camera is like billboard.cs?

  • Options
    edited April 2016

    Had to look. I have not used this class. But ya it looks like it however the face camera looks to have code to always make an axis follow you

  • Options

    holotookit

  • Options

    so your script moves the parent too?

  • Options
    edited April 2016

    Ya ToolbarPlacement will move the whole toolbar game object.
    ToolbarPlacement gameobject(ToolBar) acts as the controller. So it knows how to place the toolbar, the state of the toolbar ie:button/click action/submenu items etc...

  • Options

    so do i need to set a
    public GameObject example;

    ?

  • Options

    OK so now the situation is this,
    i have copied your script you gave me and put it on my button

    like so,

    and the other scripts on the gameobject

    but when i start the app the "move" button just floats with my gaze

    like so

    https://onedrive.live.com/redir?resid=3C36B519014C08CA!518&authkey=!AJycfcMzl_oCij8&ithint=file,mp4

    see my problem now :'(

    3.PNG 189.8K
    4.PNG 184.7K
  • Options

    @shukenmg should that Plase script be on GameObject instead of Share? Since you want the entire toolbox to move?

  • Options

    @shukenmg If you want the whole toolbar to move you should move that plase script on the game object. The script above "Toolbar Placement" is on my toolbar game object which allows the whole toolbar to move prior to placement

  • Options

    Okaaaay I'll try it soon I am not beside my computer now
    I'll inform you of it works
    Thx

  • Options
    shukenmgshukenmg
    edited April 2016

    ok so i put the script on my button and is follows me :)

    BUT

    i cant click again on the button

    https://onedrive.live.com/redir?resid=3C36B519014C08CA!535&authkey=!AHDcTKydwt-G-Rk&ithint=file,mp4

    i also edited your script:

    using UnityEngine;
    using HoloToolkit.Unity;

    public class plase : MonoBehaviour
    {
    //app state manager needs to understand the state of the toolbar.. "Get" should stay public..
    public bool IsToolbarPlaced = true;
    public Vector3 trackingPosition;
    public GameObject lol;

    void Start()
    {
        GestureManager.Instance.OverrideFocusedObject = lol.gameObject;
    }
    void Update()
    {
        //If the toolbar is not placed follow the cursor
        if (IsToolbarPlaced == false)
        {
            lol.transform.TransformDirection(ProposeTransformPosition());
            trackingPosition = lol.transform.position;
            lol.transform.position = Vector3.Lerp(lol.transform.position, ProposeTransformPosition(), 0.2f);
        }
        if (IsToolbarPlaced == true)
        {
            PlaceToolbar();
        }
    }
    void PlaceToolbar()
    {
        GestureManager.Instance.OverrideFocusedObject = null;
    }
    Vector3 ProposeTransformPosition()
    {
        // Put the anchor 2m in front of the user.
        Vector3 retval = Camera.main.transform.position + Camera.main.transform.forward * 2;
        //retval.y = retval.y - 1;
        return retval;
    }
    
    //This is called from GestureRecognizer it should call out to any object that has focus and the onselect method
    void OnSelect()
    {
        //If the toolbar is not place place it on user click from the gazeselectiontarget
    
        IsToolbarPlaced = !IsToolbarPlaced;
    }
    

    }

    see if you can find the problem

    thx :smile:

  • Options
    edited April 2016
    I would ask first did The toolbar place?
    the "Istoolbarplaced" is false in your on select method

    Review the onselect and placetoolbar code in the script I pasted above

    Let me know if you have any questions

    Thanks
    Calzaretta
  • Options

    well

    void OnSelect()
    {
    //If the toolbar is not place place it on user click from the gazeselectiontarget

    IsToolbarPlaced = !IsToolbarPlaced; // this is a toggle if i click it goes in to placing mode i click again it places 
    

    }

  • Options

    i'm sorry if i bother you i am just a newbie at c#

    srry

  • Options

    No worries we have all been at that point.. I am the same with Unity..
    Do you have gazeselectiontarget script in the toolkit? Not sure if that script is in the toolkit

  • Options

    So i was just able to check. it does have the HoloToolkit.Unity namespace however i want to say i copied this file from the Galaxy Explorer toolbar and just added it to the toolkit

  • Options
    edited April 2016

    Here is what my button class(Script) declaration on my toolbar button is like.

    public class ButtonSpatialMapping : GazeSelectionTarget, IFadeTarget

  • Options

    @Calzaretta said:
    Here is what my button class(Script) declaration on my toolbar button is like.

    public class ButtonSpatialMapping : GazeSelectionTarget, IFadeTarget

    ok so what if i want the whole game object to stick to flat surfaces , and not just float 2 meters away ?

    a bit like placable.cs in the spatial mapping course .

    thx

This discussion has been closed.