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.
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
0
Best Answer
This discussion has been closed.
Answers
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
any other suggestions ?
help!!!!
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
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
kk ill try
but one more question ,whats face camera script?
i can't find it in the kit.
thx
is a sphere collider ok?
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."
I dont know. I done use the sphere collider.
wow you are quite a pro
so face camera is like billboard.cs?
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
holotookit
so your script moves the parent too?
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...
so do i need to set a
public GameObject example;
?
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
@shukenmg should that Plase script be on GameObject instead of Share? Since you want the entire toolbox to move?
@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
Okaaaay I'll try it soon I am not beside my computer now
I'll inform you of it works
Thx
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;
}
see if you can find the problem
thx
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
well
void OnSelect()
{
//If the toolbar is not place place it on user click from the gazeselectiontarget
}
i'm sorry if i bother you i am just a newbie at c#
srry
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
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
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
TapToPlace is now part of the HoloToolkit.