Author Topic: 3D Text and UILabel  (Read 15979 times)

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
3D Text and UILabel
« on: October 09, 2013, 03:03:05 AM »
Hello!

Is it possible to use a UILabel to display the text in the game 3d world (as 3d text)?
I needed to use custom fonts in 3D text.
I saw on the web about the use of custom fonts in Unity with scripts http://wiki.unity3d.com/index.php?title=SaveFontTexture and http://wiki.unity3d.com/index.php?title=TexturedFont, but in the output texture is very little space between the characters and it is difficult to add a nice outline effect.
If ngui it does not, then I think i need to write own importer of fonts and mesh generator for 3D text?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D Text and UILabel
« Reply #1 on: October 09, 2013, 08:27:48 AM »
NGUI's geometry is just that -- geometry. Which camera draws it -- whether it's your UI camera or your game camera -- doesn't matter. So yes, you can certainly do that. Easiest way to do it is to create a game object, attach UIPanel to it, and then ALT+SHIFT+L with it selected to create a child label underneath. You will want to scale the panel though as it will likely be too big.

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
Re: 3D Text and UILabel
« Reply #2 on: October 09, 2013, 11:00:55 PM »
Excellent!

I need to change the color of the font, but outline should be fixed color.
Example: http://tinypic.com/view.php?pic=24zat4x&s=5#.UlZzDVA0zfQ
I tried to add text in a 3D world as you advise, but for dynamic font was a problem with the fact that it shows through my 3D objects.
I understand that you need to do something like that? http://wiki.unity3d.com/index.php?title=3DText
And the outline effect (distance x = 3, y = 3) looks rough.

Or is it better for these purposes to use bitmap font? If so, how to do stained only the font without staining of the full font texture and without outline?

And another question, will it work for the batching of many such panels, for example, I need to show some 50 labels in the 3D world at the same time in different positions (сards prices). But as far as I understand it for dynamic font batching not be, and everything will be different drawcalls.
« Last Edit: October 10, 2013, 09:55:09 PM by broken »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D Text and UILabel
« Reply #3 on: October 10, 2013, 07:26:11 AM »
If you have 1 panel and many widgets, they will be batched. If you have many panels, they won't be. Each panel can only batch what's inside of it.

The text will show through your 3D objects if those objects don't write to depth (ie: transparent objects). Without writing to depth there is no way to determine what is in front of what. GUI shaders also don't write to depth.

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
Re: 3D Text and UILabel
« Reply #4 on: October 10, 2013, 09:43:16 PM »
How do I solve this problem then? Attach image - labels (dynamic font with outline) are shown through 3D object (mountain), camera orthographic.
Probably need to do so, as shown in this example?
http://wiki.unity3d.com/index.php?title=3DText
But if on a standard 3D text it works, then ngui I can not do such a thing :(
If the outline effect works for bitmap fonts in ngui it is better to do then bitmap font, and then everything will appear normal, right?

UPD: Done with the use of bitmap font + outline effect.
« Last Edit: October 10, 2013, 10:44:09 PM by broken »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D Text and UILabel
« Reply #5 on: October 11, 2013, 08:06:01 AM »
Might be due to the fact that NGUI just used the GUI/Text shader before. The latest Pro version actually has a custom shader for GUI text that behaves the same way as Unlit/Transparent Colored in terms of render queues.

kasparlund

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: 3D Text and UILabel
« Reply #6 on: May 23, 2014, 02:18:40 PM »
SOLVED: I got 3D text to work in the following way in a game with signposts in the terrain:
uipanel
  -UIsprint
      -UIlabel
      -Quad unity-primitive behind the label

Explanation:
-The Quad primitive closes the transparency.
- The UIPanel is, for some reason i do not understand, required in order to avoid flicking of the label when you approach or move backwards from the label.

NGUI is really a valuable tool - thanks

The UIPanel will not work by itself because when you move around in 3D then the panel ordering will eventually show the depth in the wrong order.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D Text and UILabel
« Reply #7 on: May 23, 2014, 05:29:55 PM »
UIPanel is what draws things. Widgets can't exist without it.