Hololens Menu Centered?

Hey guys,

I am working on creating an app in hololens however I am having trouble get the menu centered. We have it setup to where the user can either walk or use a Xbox controller. The issue is that the button used to enable/disable the menu doesn’t always place it in the screen center. I fear that since we have the camera is the child of the empty game object that is used to move the camera, that it is causing issues with the alignment.

I am thinking of attempting to it create when pressed very similar to the TaptoPlace script and have it Destroy upon closing. I just need the menu to be centered when called upon. Any thoughts or advice would be amazing. Thank you for your time

The best result i have got so far is the following script:

                if (controllerInput.GetButton(ControllerButton.View))
                {
                    Menu.SetActive(true);
                    Menu.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, Camera.main.nearClipPlane + 0.5f));
                }

I don’t think that would make a difference in this case.

What might make a difference is if what you consider the “center” of the menu (your prefab) is not at (0,0,0) relative to the menu layout itself. If your menu has (0,0,0) at the lower left corner (for example), then the menu will always be up and to the right.

Is the error consistent? Is it slightly random?

Hey Kurt,

Now that you spelled it out like that, that may be the case. Whenever I turn the camera to the left the menu is a ways too the left (so far enough that it isnt in view) and vice versa for the right. I will double check it now. Thank you pinpoint that.

Just checked and every is indeed correct. Camera is (0,0,0) Canvas (0,0,0), empty game object is (0,0,0). What is strange is that in the unity editor it works perfectly however when I am actually in the HoloLens itself is when it is either to the left if i am turned left or vice versa.

Thanks guys, ended up getting it using the gamemanager as reference. Greatly appreciate the help

1 Like