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
1
Question by ClockParadoX · Oct 15, 2011 at 11:19 PM · materialmaterialsalphaguitextfont

Modifying the Arial material for fading GUITexts

Seems like a really simple problem, but I can't seem to find an answer to this after digging in Unity and searching here for a day or so.

I have a fade script that will fade the alpha of a GUIText prefab. The GUIText is using the Arial default font with NONE as the material.

 public class FadeGUITexts : MonoBehaviour
 {
     public float fadeDuration = 1.0f; 
 
     private void Start () 
     {
         StartCoroutine(StartFading());
     }
 
     private IEnumerator StartFading()
     {
         yield return StartCoroutine(Fade(0.0f, 1.0f, fadeDuration));    // Fade in at start
         //yield return StartCoroutine(Fade(1.0f, 0.0f, fadeDuration));
         //Destroy(gameObject);
     }
  
     private IEnumerator Fade (float startLevel, float endLevel, float time) 
     { 
             float speed = 1.0f/time;     
         
     for (float t = 0.0f; t < 1.0; t += Time.deltaTime*speed) 
     { 
         float a = Mathf.Lerp(startLevel, endLevel, t);
         
         guiText.font.material.color = new Color(guiText.font.material.color.r,     
         guiText.font.material.color.g,     
         guiText.font.material.color.b, a);    
     yield return 0;
     }
 }

This fade script works beautifully, but the problem I am having is that ALL the GUITexts in the scene are fading at the same time because I'm modifying the alpha on the single GUIText material (which is the Arial font material.)

I've tried adding other materials to each GUIText prefab, but anything other than NONE turns the font into gibberish. I don't see any option in the material browser to select the actual ARIAL material or texture for modification.

So, is the Arial font material accessible in some way? Or would I be better served using a different font that generates it's own materials/textures?

Or am I just doing this wrong and shouldn't be trying to modify the material.color directly?

Thanks in advance!

Comment
Add comment
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

1 Reply

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

Answer by Eric5h5 · Oct 16, 2011 at 01:39 AM

Use guiText.material instead. That way it will make a unique material for each GUIText at runtime, and not touch the actual font asset.

Comment
Add comment · Show 1 · 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 ClockParadoX · Oct 16, 2011 at 07:31 PM 0
Share

That did it! $$anonymous$$any thanks!

I tried to upvote your answer, but the site won't let me yet (for some unknown reason)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How do I get the current alpha value of a material? 2 Answers

Text not reverting back to original properties after gameplay 1 Answer

Changing font material alpha for just one clone 0 Answers

Material alpha is 1 but still see through 0 Answers

Editing the alpha of one GUItext edits the alpha of them all 1 Answer


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