microsoft / MixedRealityDesignLabs_Unity

Mixed Reality Design Labs share experimental samples, explorations and learning from Windows Mixed Reality Design group. If you are looking for official toolkit, please use Mixed Reality Toolkit
MIT License
408 stars 110 forks source link

ToolBar Glyphs corrupted #64

Closed Tachoron closed 6 years ago

Tachoron commented 7 years ago

Hey MRDesignLabs-Team,

Really cool HoloLens-Utility you build there thumbsup :-)

But in my case the Toolbar-Glyphs are corrupted: grafik

This also occurs the first time if i use the Unity Preview function. After that the Preview-Function works with the correct icons, but the HoloLens have the corrupted one (also after install/uninstall).

I also found the Issue No. 3: https://github.com/Microsoft/MRDesignLabs_Unity/issues/3. But also after reselect it will not work properly.

Best Regards Tachoron

Tachoron commented 7 years ago

Edit: In the Example it seems to work correctly, but if i copy the Toolbar in another Scene(or use the Prefab) then this effect occur.

Same effect on HoloLens and Emulator.

Railboy commented 7 years ago

This is unfortunately due to a common font glitch in Unity which we've attempted to mitigate (with limited success). Some causes are fairly deterministic but others are mysterious.

Tachoron commented 7 years ago

Oh, thanks for your response. Didn't know that :)

Zod- commented 7 years ago

I'll repost what I've said on the PR in the MRToolkit here: For me, this corruption occurs when enabling/disabling buttons multiple times and I've managed to get it fixed today. Here's a little clip of the behavior: https://puu.sh/xIL06/0c20ded28c.webm

This ended up solving it for me but it's more of a workaround than an actual fix:

private void OnEnable()
{
    if (Application.isPlaying)
    {
        ClearInstancedAssets();
    }

    StartCoroutine(RefreshIcon());
}

private IEnumerator RefreshIcon()
{
    SetIconName(iconName);
    yield return new WaitForEndOfFrame();
    SetIconName(iconName); // UVRect of the icon atlas will be broken without this, but why??
}

Instead of: https://github.com/Microsoft/MRDesignLabs_Unity_Tools/blob/ec32b17034e2950784d084f838bd2b858bdc7b23/HUX/Scripts/Buttons/CompoundButtonIcon.cs#L205-L213

Also a tip for debugging it: You can trigger the fix by selecting the button object in the hierarchy because that triggers setting the icon again from the property drawer.

Railboy commented 7 years ago

Thanks for the workaround. I agree, it would be nice to know the cause of the glitch so we can deliberately avoid it, rather than 'fix' it with methods like this. But it's good to have in the meantime.