Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by 1337GameDev · May 15, 2012 at 10:35 PM · colorchangetransparentprogress bar

Changing text color based on background to make readable

I want to simulate a progress bar, but have text over it, similar to homeworld 2's style. How would i do this? Here is an example: Notice how the text changes as the status bar grows over the text, compare both status bars for the build queue:

Image

Comment
Add comment · Show 10
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · May 15, 2012 at 11:30 PM 0
Share

I'm no shader expert, so I'd just say, this sounds like a shader issue. I can't really give you an answer, but you need something that does blending like the Pro shader "Hidden/Blend$$anonymous$$odesOverlay". Something that would XOR with the existing color would also give you a similar effect.

avatar image syclamoth · May 15, 2012 at 11:34 PM 0
Share

Give me a moment, I'll mix one up for you!

avatar image syclamoth · May 16, 2012 at 12:57 AM 0
Share

There you go! Took a bit longer than I expected :P

avatar image 1337GameDev · May 16, 2012 at 02:42 AM 0
Share

Hmm, i cant get my 3d text game object to show any text. i put z offset to 0, and transform.position is all zero. How do specify my text location?

avatar image syclamoth · May 16, 2012 at 03:50 AM 0
Share

The transform position shouldn't matter at all (except for placement). You need to set up the 'text' field in the text$$anonymous$$esh component to show what text you need, and the renderer needs to have the correct material.

Is anything showing up? It is possible that the 'font size' is too small (in fact, you should increase this to about 100 so that you have smooth text, and then use transform scaling to manage the actual size).

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by syclamoth · May 16, 2012 at 12:56 AM

Here's a shader you can use on a 3dText object! It won't work on UnityGUI, of course.

 Shader "GUI/ReverseFont" {
 Properties {
    _MainTex ("Font Texture", 2D) = "white" {}
    _Color ("Text Color", Color) = (1,1,1,1)
 }
 
 SubShader {
    Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
    Lighting Off Cull Off ZWrite Off Fog { Mode Off }
    
    Pass {
       Color [_Color]
       AlphaTest Greater 0.5
       Blend SrcColor DstColor
       BlendOp Sub
       SetTexture [_MainTex] {
          combine previous, texture * primary
       }
    }
 }
 }
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image 1337GameDev · May 16, 2012 at 01:37 AM 0
Share

How would I use this? Just make a 3d text obj then assign this shader as the texture? Is there a nice tutorial for shaders i can try and learn?

avatar image syclamoth · May 16, 2012 at 01:44 AM 0
Share

Nice tutorial for shaders? I haven't found one. In this case, just make a new shader asset in the project view, and copy-paste this whole thing into it. To connect it to an actual text object is a bit less straightforward- you can't actually do it on the default font (because you can't access the font texture). Just get a nice font from somewhere, and then make a new material, set its shader to this one, change its texture to the font texture, and then you can use the material as a font material with a 3dText object (assu$$anonymous$$g that object is using the same font, of course).

avatar image syclamoth · May 16, 2012 at 01:53 AM 0
Share

Now that I think about it, this won't work against 62% grey. Just thought I should warn you.

avatar image whydoidoit · May 16, 2012 at 08:10 AM 0
Share

Nice, thanks for that - I really must learn some shader program$$anonymous$$g :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why Shuriken "Color Over Lifetime" doesn't affect transparent materials? 2 Answers

On Touch change color 2 Answers

Is changing the color of GUIText unavailable in the Free Edition? 1 Answer

Android build weird color changes 1 Answer

Material doesn't have a color property '_Color' 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges