Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by marioslokas · Jun 13, 2019 at 09:14 AM · textcanvasworldspacedirtyfloating-text

Disappearing world space text after setting its text value

Hi, I have identified my problem and looking for a workaround, if anyone knows. What happens is that as soon as I set the text value of a world space text, the text disappears. The value is there properly and can be seen in the editor, but is invisible in the game view.

I have a world space canvas that constantly looks at the camera, that contains some game bars and a title that pulses (scales up and down constantly). It works great as an announcement board for my game. Now I wanted to add some simple floating texts for things like + score, + health etc.

I am using a text prefab with a script that has a coroutine for making the text move up the Y axis slowly. This is the coroutine that shows that I first change the text, then start the coroutine for making the text fly upwards.

 private IEnumerator ShowAssistObjectResults(float energy)
         {
                 floatingTexts[0].SetText("Energy",energy);
                 floatingTexts[0].PlayFloatText();
                 yield return new WaitForSeconds(breakTime);
         }

This is my SetText method:

 public void SetText(string text, float value)
     {
         floatingText.text = value > 0 ? text+ " + " + value : text + myValue;
         floatingText.color = value > 0 ? positiveColor : negativeColor;
     }

And finally the FloatText Coroutine:

 public void PlayFloatText()
 {
         StartCoroutine(FloatAndDisable());
  }

 IEnumerator FloatAndDisable()
     {
         t = 0f;
         
         while (t < flyDuration)
         {
             t += Time.deltaTime;
             y = _rectTransform.anchoredPosition3D.y;
             _rectTransform.anchoredPosition3D = new Vector3(x,y + floatingSpeed*t ,z);
             yield return null;
         }
         
         _rectTransform.anchoredPosition3D = startPosition;
         floatingText.text = "";
 
         
 
     }

I have tried setting the text to random values in the code (e.g. "test" ) and the floating text works as intended. For some specific reason, using the one line ifs I have above or passing another value makes the text go invisible. I am using Unity 2018.3.0f2.

I suspect it has something to do with setting the text to be "dirty" even though I am not really familiar with the definition of that.

Comment
Add comment · Show 9
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 Kennai · Jun 13, 2019 at 09:27 AM 0
Share

maybe text borders is too small to show your long text? It may explain why it worked fine with small texts like random numbers and "test" text

avatar image marioslokas Kennai · Jun 13, 2019 at 09:39 AM 0
Share

Nope, tried editing that in the editor and it showed the text without problem

avatar image Doctor_ED marioslokas · Jun 13, 2019 at 10:28 AM 2
Share

Hmm... How about color? Is there a chance that during setting color it is set to be transparent?

Show more comments
Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by centralinfo · Jun 13, 2019 at 11:38 AM

Hi,

Try setting the Sorting Layer drop down box on the canvas, as well as the Layer drop down at the top of the inspector. This will set the sorting layer for your game objects.

Chris

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

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

122 People are following this question.

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

Related Questions

Heya, does anyone know how to make WorldSpace canvas Text less blurry/pixelated 2 Answers

Canvas UI Priority layers 1 Answer

World space buttons and preventing UI touch passthrough 0 Answers

3rd party UI - World Canvas or Screen Space Camera? 0 Answers

World Space Canvas not rendering in front of Overlay Canvas 0 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