UI Text all Black

I’m still playing around with different capabilities but I’m have a great deal of difficulty with the UI system. I’m very familiar with Unity and have used the UI system extensively for the Android platform. On the 5.4.b16 install that I’m using I cannot change the fonts to any other color other than black.

I have installed the UI script as instructed here: Unity UI on the HoloLens - Unity Engine - Unity Discussions

And thanks to that code, the gaze functionality works like a mouse pointer, it’s able to “mouse-over” and click buttons, etc. Which is really great work.

I’m not sure why the UI will only allow black text. The color picker in the inspector for the item shows allows me to change the color as reported in the inspector, it’s just that the text never actually gets updated and when deployed to the Hololens, it’s still black - which is problematic as black is invisible and you have to make sure something bright exists behind it to see anything.

I’ve tried deleting and creating new UI elements but it’s the same problem.

Other UI elements allow me to change the color without issue. I’ve added a new UI material and this doesn’t fix anything. I’ve added a new .ttf file and switched the fontface but this also doesn’t allow any other color than black.

Make sure to put a “Font Material” on the Text element of the UI.

5 Likes

Thanks. But the new UI material that I put on the object is a “Font Material” - that’s didn’t work.

I’ve never had to create a new material for the textual elements. This seems like a true bug.

Was it here, in the text element, not its parent, that you added it ? All you have to do is select the circle next to the box and select Font Material from the dialog box that appears. This held me up for a few hours, the exact error you are talking about, turned out to be a really simple fix.

8 Likes

Hmm… I created my own UI Font material and that didn’t work. I didn’t realize that they have created a default "Font Material’ but not put it on Text elements by Default.

Thanks - working now. This is crazy - when did this change?

i “think” this is a bug, but manually dragging the font material from the imported font seems to fix the issue for me too.

Hello everyone,

Just a quick tip on the UI gaze control, the lose script from forum post : http://forum.unity3d.com/threads/unity-ui-on-the-hololens.394629/ is not longer needed. we have integrated into unity. You can now add the HoloLens Input Module as a component yo help with gaze, it will also work with UI buttons sliders, etc…

Looking into the issue with the UI still

Thank you,
Wesley

The stickied “Unity UI on the HoloLens” post has been updated to reflect that you no longer need to download the formerly attached component (and instructions altered to point out that you no longer need to replace Standalone Input Module with HoloLens Input Module, they can and should sit next to each other now). Sorry about any confusion!

Also, I tried reproducing the text-color issue being pointed out here with and without using that script that used to be attached in Unity UI on the HoloLens - Unity Engine - Unity Discussions, and wasn’t able to repro either way. Just to make sure, you’re saying you’re not able to change the color using the field above where you set the material on the text as pointed out in Subere023’s screen-cap? Were you able to get the color to show up correctly without replacing the material?

Correct,
I create a new Scene. Then go to GameObject | UI | Text which creates the Canvas with a child Text gameObject and an EventSystem gameObject. in the hierarchy.

The Text component of the Text object does not update color unless the material is changed to “Font Material” - deleting the material after it is applied turns the text black again.

changing the material to “Font Material” effectively fixes the problem. WIth this fix, there is not problem but it sure was frustrating until I got the fix.

Hello,

Could you please file a bug on the issue with a repro project so we can see the issue.

Please include Detailed Repro steps and Description of the issue.

Thank you,
Wesley

Same problem with me. I created a new project to test with Hololens and everything works fine except changing color of a UI Text. Adding a “Font Material” as mentioned above did not work for me, I don’t see why i would need to do this if I had never needed to do this in Unity ever before.

Hello,

Can you please file a bug with a working repro project so we can see the issue

Thank you,
Wesley

Same problem here, text only shows in black and I can’t change the colour. Tried both with and without “Font Material” and neither works.

If I create a fresh unity scene without changing the settings for hololens then the font colours work fine. Once I set up the project for hololens then build for VS I lose the ability to change font colours.
It might also worth noting that If I have a blank UI Image (white) in a canvas that works fine its just the text element that doesn’t.

i was playing around with shaders, as the font material shader uses az older (i’m guessing IMGUI) shader which doesn’t zwrite and/or ztest and so looks bad on worldspace ui-s, and i copy-pasted a custom uitext shader from the builtin shaders, and somehow it started working (you can change text colors, tested in b18/b20), altough i dunno why, as it is the same as the UI-Default/UI-DefaultFont shaders.

shader code

Shader "UI/Default Font Fixed"
{
    Properties
    {
        [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
        _Color ("Tint", Color) = (1,1,1,1)
    
        _StencilComp ("Stencil Comparison", Float) = 8
        _Stencil ("Stencil ID", Float) = 0
        _StencilOp ("Stencil Operation", Float) = 0
        _StencilWriteMask ("Stencil Write Mask", Float) = 255
        _StencilReadMask ("Stencil Read Mask", Float) = 255

        _ColorMask ("Color Mask", Float) = 15

        [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
    }

    SubShader
    {
        Tags
        {
            "Queue"="Transparent"
            "IgnoreProjector"="True"
            "RenderType"="Transparent"
            "PreviewType"="Plane"
            "CanUseSpriteAtlas"="True"
        }
    
        Stencil
        {
            Ref [_Stencil]
            Comp [_StencilComp]
            Pass [_StencilOp]
            ReadMask [_StencilReadMask]
            WriteMask [_StencilWriteMask]
        }

        Cull off
        Lighting Off
        ZWrite Off
        ZTest [unity_GUIZTestMode]
        Blend SrcAlpha OneMinusSrcAlpha
        ColorMask [_ColorMask]

        Pass
        {
        CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma target 2.0

            #include "UnityCG.cginc"
            #include "UnityUI.cginc"

            #pragma multi_compile __ UNITY_UI_ALPHACLIP
        
            struct appdata_t
            {
                float4 vertex   : POSITION;
                float4 color    : COLOR;
                float2 texcoord : TEXCOORD0;
            };

            struct v2f
            {
                float4 vertex   : SV_POSITION;
                fixed4 color    : COLOR;
                half2 texcoord  : TEXCOORD0;
                float4 worldPosition : TEXCOORD1;
            };
        
            fixed4 _Color;
            fixed4 _TextureSampleAdd;
            float4 _ClipRect;

            v2f vert(appdata_t IN)
            {
                v2f OUT;
                OUT.worldPosition = IN.vertex;
                OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);

                OUT.texcoord = IN.texcoord;
            
                #ifdef UNITY_HALF_TEXEL_OFFSET
                OUT.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1) * OUT.vertex.w;
                #endif
            
                OUT.color = IN.color * _Color;
                return OUT;
            }

            sampler2D _MainTex;

            fixed4 frag(v2f IN) : SV_Target
            {
                half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
                            
                color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);

                #ifdef UNITY_UI_ALPHACLIP
                clip (color.a - 0.001);
                #endif

                return color;
            }
        ENDCG
        }
    }
}

i’m also including the .mat file, as the parameters it contains from other shaders before i set this one may be of relevance to the devs.

.mat file (yaml)

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
  serializedVersion: 6
  m_ObjectHideFlags: 0
  m_PrefabParentObject: {fileID: 0}
  m_PrefabInternal: {fileID: 0}
  m_Name: UIText
  m_Shader: {fileID: 4800000, guid: fe61b015b2c4be54eb75b46a0c7be657, type: 3}
  m_ShaderKeywords: _EMISSION
  m_LightmapFlags: 1
  m_CustomRenderQueue: 3000
  stringTagMap: {}
  m_SavedProperties:
    serializedVersion: 2
    m_TexEnvs:
    - first:
        name: _BumpMap
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - first:
        name: _DetailAlbedoMap
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - first:
        name: _DetailMask
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - first:
        name: _DetailNormalMap
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - first:
        name: _EmissionMap
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - first:
        name: _MainTex
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - first:
        name: _MetallicGlossMap
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - first:
        name: _OcclusionMap
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    - first:
        name: _ParallaxMap
      second:
        m_Texture: {fileID: 0}
        m_Scale: {x: 1, y: 1}
        m_Offset: {x: 0, y: 0}
    m_Floats:
    - first:
        name: _BumpScale
      second: 1
    - first:
        name: _ColorMask
      second: 15
    - first:
        name: _Cutoff
      second: 0.5
    - first:
        name: _DetailNormalMapScale
      second: 1
    - first:
        name: _DstBlend
      second: 0
    - first:
        name: _GlossMapScale
      second: 1
    - first:
        name: _Glossiness
      second: 0.5
    - first:
        name: _GlossyReflections
      second: 1
    - first:
        name: _Metallic
      second: 0
    - first:
        name: _Mode
      second: 0
    - first:
        name: _OcclusionStrength
      second: 1
    - first:
        name: _Parallax
      second: 0.02
    - first:
        name: _SmoothnessTextureChannel
      second: 0
    - first:
        name: _SpecularHighlights
      second: 1
    - first:
        name: _SrcBlend
      second: 1
    - first:
        name: _Stencil
      second: 0
    - first:
        name: _StencilComp
      second: 8
    - first:
        name: _StencilOp
      second: 0
    - first:
        name: _StencilReadMask
      second: 255
    - first:
        name: _StencilWriteMask
      second: 255
    - first:
        name: _UVSec
      second: 0
    - first:
        name: _UseUIAlphaClip
      second: 0
    - first:
        name: _ZWrite
      second: 1
    m_Colors:
    - first:
        name: _Color
      second: {r: 1, g: 1, b: 1, a: 1}
    - first:
        name: _EmissionColor
      second: {r: 0, g: 0, b: 0, a: 1}
1 Like

Awesome I just added in that Shader and now I can edit the colour.

Thanks!

Right click on the font , and re import . This fixed the issue for me.

1 Like

Just a FYI that this is still an issue. I can’t change the font colour either and I have no default “Font Material”.

Having this problem, any idea ?

Thank you! I couldn’t figure out why the text went dark after clicking the play button to test my button…a great time saver!

So I had the issue with black text only…if you are using multiple monitors, the palette for this was coming up on another monitor (main, I have 3, but I use the main one for help searches and instructional video) under other windows that were open. Worth a check if nothing else is working.