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 amirabiri · Jun 23, 2012 at 08:42 PM · guitextgraphics

Low level text writing

I am using Unity's low-level Graphics/GL classes to do the in-game HUD instead of Unity's GUI due to performance reasons.

I've managed to get it to work and it's great, the only problem that remains is texts. We've managed to get most of them done by creating textures that represent characters and using Graphics.DrawTexture(). We've done this for numbers (score, hit points etc) but for other texts we've used a plain texture (i.e the word "Score" is a single texture).

So obviously this isn't ideal and now we have the problem of wanting to use different scales (score announcements in different sizes etc).

My question is: is there a low-level parallel of Graphics.DrawTexture() for writing texts in a given font? Or perhaps there is a way to do that from building blocks? I've looked for example at the texture in the imported font file but couldn't figure out how it's meant to be used.

Any ideas?

Comment
Add comment · Show 14
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 Fattie · Jun 23, 2012 at 08:54 PM 0
Share

PS "I am using Unity's low-level Graphics/GL classes to do the in-game HUD" totally awesome, you rock. any chance of a vid or something of how good it works

avatar image amirabiri · Jun 23, 2012 at 09:04 PM 1
Share

No vid yet but I can post a code snippet if you are interested. It is actually quite simple for images. But bear in $$anonymous$$d that by "HUD" I mean the non-interactive in-game HUD. When we need buttons and such we use Unity's normal GUI system (i.e for menus etc). But when the actual game is running, we don't need those.

avatar image amirabiri · Jun 23, 2012 at 09:22 PM 1
Share

Sure: http://pastebin.com/LmkshtFz

These are just examples but I think you get the drift from them. The HUD class uses a similar technique to the one displayed in the Cursor class to call the method you see there (i.e coroutine with WaitForEndOfFrame).

avatar image amirabiri · Jun 23, 2012 at 09:24 PM 1
Share

RE rotating images I haven't implemented something like that, I don't know if it's possible with Graphics.DrawTexture(). I'll have to think about it.

avatar image Eric5h5 · Jun 23, 2012 at 10:30 PM 1
Share

You might have a look at FlyingText3D, which creates meshes from TrueType fonts. (The text doesn't have to be actual 3D as in extruded, it can happily be flat 2D text. Although still technically 3D, which means it's vector-based and fully resolution-independent.)

Show more comments

1 Reply

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

Answer by Fattie · Jun 23, 2012 at 08:53 PM

I'm fairly sure there is NOT a way to do this. It's my "most wanted thing"

In short NO, SADLY, YOU MUST USE DIFFERENT SIZE LETTERS FOR DIFFERENT SCREENS.

The standard solution at the moment is either A or B:

A include different sizes for the different screens it will be running on

B include only the "largest" size, and scale down for the "smaller" sizes (wastes a little space)

or I guess C include only the small size, and scale up (results in blurry)

I urge you to get 2dToolkit which completely handles font-like textures. (they are just textures .. with "letters on them") I'd guess that in combination with your system would be ideal. if you get it now you'll be smiling in 30 minutes. (But you still have to choose A B or C, to be clear.)

I spend about 90% of my life emailing people like the makers of the various GUI kits, 2dToolkot, and Unity, whining that they should

BUT ..

.
it looks like Unity4, in fact, finally has dynamic fonts. This is HUGE, HUGE news.

it would be utterly pointless implementing anything at this point, since, U4 will be here soon enough.

I hope this helps in some way. You have stumbled on to the hugest most annoyingest problem in Unity But it looks like they fixed it in 4.

I feel really bad for anyone who was hand-building a proper dynamic font maker - which would have been a mega-money-maker on the asset store.


Just FTR if you hassle all the folks who make gui-replacement-kits, N-d toolkits and the like, they, also, suggest precisely "A" and "B" above ... unfortunately that's about it.

Comment
Add comment · Show 5 · 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 amirabiri · Jun 23, 2012 at 09:11 PM 0
Share

I can't even begin to describe how much I've cursed and spat blood over the GUI over the past months. Perhaps sometime I will post the code I've written that wraps Unity's immediate mode GUI in a retained widget like API.

I often thought about starting an open source project of a full replacement GUI system for Unity (I was thinking of integrating CEGUI). However the knowledge that the new GUI system is "just around the corner" always stopped me.

Anyway, water under the bridge now. We'll ship our game soon and our next project hopefully will be based on Unity 4 and we'll forget all about the nightmares we had with the GUI in the past...

avatar image whydoidoit · Jun 23, 2012 at 09:35 PM 0
Share

Funny isn't it - here I am with my RetainedGUI class I was thinking of pushing out there as well :)

@Fattie - huge news! Fantastic!

avatar image Fattie · Jun 23, 2012 at 09:46 PM 0
Share

The whole GUI situation is a ####ing joke. #### Unity and the ####ing donkey they rode in on. ####ing ####ers.

A ####ing 10-year old would realize you need to capture ####ing events off ####ing buttons and that you can't have ####ing performance problems in a ####ing gui layer in a ####ing product we all pay $1500 a seat for every couple ####ing years and it can't even do ####ing hel-####ing-vetica dynamically given the whole ####ing idea of the ####ing product is that it makes ####ing games on many DIFFERENT ####ing platforms. #### !!!!

they're ###ing ####holes.

avatar image amirabiri · Jun 23, 2012 at 10:03 PM 1
Share

I've lost count of the number of times I had a post like this ready in the forums and deleted it... yes, they really dropped the ball with the GUI. Amir's golden rule #1 (learned the hard way): Never ever architect to syntax! But no one can build a perfect system, they've done a terrific job all around, there were bound to be a few slips.

avatar image Eric5h5 · Jun 23, 2012 at 10:32 PM 0
Share

Unity already has dynamic fonts and has had them for some time, the only thing is they don't work on mobile platforms (yet).

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

GUI text font change 3 Answers

Limit on GUI Components? 0 Answers

Using "fonts" that are actually images for a multi-outline effect. 2 Answers

Dialouge text. 1 Answer

iphone album art how? 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