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
0
Question by Gennadios · May 21, 2012 at 07:02 AM · guitextmobilewebplayer

GUI: non-static text won't display on Mobile/Web player

Hello, my project uses GUI labels floating in a circular pattern around the player to display the relative directions of points of interest, kind of like a compass/radar display. For now the only element on display is the _name of the object, which is pulled and assigned randomly from a rather large text file.

 GUI.Label(new Rect(x,y,Screen.width/5,Screen.height/5), _name);

The labels and attached text are all displaying without a hitch in the editor and the Windows build. The problem is that Web Player and Android will not render the text and over the past 9 hours I've tried all (of the very few) workarounds I could find on google without success.

The frustrating thing is that hard coded GUI elements are rendering without any problems:

 GUI.Button (new Rect (0,Screen.height - Screen.height/5,Screen.width/5,Screen.height/5), "Dock")

All I've learned is that mobile doesn't support dynamic text, but I have no way of predicting which names will be generated so I can't set them before runtime.

Does anyone know of a possible solution short of stitching together alphabet textures to form a name based on the string value?

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

2 Replies

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

Answer by whydoidoit · May 21, 2012 at 08:16 AM

It sounds to me like you need to install a font on the device. If you are using the default font it will work fine in the editor, but will not work on the device.

The whole thing about dynamic fonts is that you cannot change the size of a font on the phone, but you can change the text just fine.

Create a font for each point size you need and then switch between then.

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 Gennadios · May 21, 2012 at 08:39 AM 0
Share

Hum, the fonts weren't the issue as all the standard text fields displayed properly, and replace _name with "Text" would display all the the labels and "Test" across all 3 platforms.

What you said about installing the font on the device got me thinking though, I'm getting my _names from a text file that's currently in my assets/resources folder.

I was under the impression that it would be compiled and added to the .apk that way, but it's possible that it's not being found by the device and all the strings are in fact null, that's why they're not showing.

I'll give you answer cred for the inspiration and pursue that train of thought in the morning, thank you.

avatar image
0

Answer by Gennadios · May 22, 2012 at 06:36 AM

For the benefit of anyone that might be having these problems in the future, I have a working script that should be cross platform, tested on windows, web player, and Android:

 void GenNames()
 {
     int rand = 0;

     TextAsset textAsset = (TextAsset)Resources.Load("altplanetnames", typeof(TextAsset));
     string ta = textAsset.ToString();
     string[] names = ta.Split('\n');
     
     foreach(Planet p in planets)
     {
         rand = Random.Range(rand, names.GetLength(0));
         p.SetName(names[rand]);
     }
     
 }

I experimented with a few input reader types and Regex, none of them worked, TextAsset.ToString() and string.Split() got the job done.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Blurry Text using Textmesh Pro on android device 2 Answers

Speed of Gui Text vs 3D Text Mobile 1 Answer

Avoid auto device capitalization for textfields on mobile 1 Answer

How to make GUI text look good? 0 Answers

Problem Displaying Score on GUI text 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