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

"OnGUI()" and "GUI.DrawTexture(...)" not working on HoloLens

edited August 2017 in Questions And Answers

Hello Hololens Community,

I am using the following lines of code inside my Unity Project:

private void OnGUI(){
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, alpha);
GUI.depth = drawDepth; // Draw on Top
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
}

However inside Unity Editor the code works fine, but after deploying the project to the Hololens the drawn texture wont display.

I already found this thread (https://forums.hololens.com/discussion/1649/how-to-draw-a-texture) with a similar problem, but I did not know how to realize this answer:

"Do not use OnGUI or the old unity GUI, its horrendous. Use the new UnityGUI .. canvas/panel/image/text etc."

How can I get "GUI.DrawTexture(...)" to work on HoloLens?

Thanks for any help!

Tagged:

Answers

  • Options

    I'm also having issues with OnGUI.

    I'm using OnGUI to draw a rectangle to handle fading. The code runs display fine in many Unity projects for Vive, Cardboard, Daydream. It does not function on the HoloLens.

  • Options

    I'm not sure why OnGUI would fail but I think there are better alternatives to fading a rectangle.

    You could create a plane (or if you want 2D space then a 2D Sprite) and add a white texture (or white box for the sprite). Scale it to the size you need. Then for the sprite set the color's alpha. And for the plane SetColor on the material's shader.

    DOTween is a free plugin that can do color fades on both of these for you if you just want to pass in the color/duration/ease/etc.

    Taqtile

Sign In or Register to comment.