Not sure if this is an easy thing to do or an impossible thing to do but it can;t hurt to ask…
So, what I want is a white font with a black border around it. (Or yellow with black… or red with… you get the idea) I have read about people using textured fonts but not sure what that means. It sounds like it could work for my purposes but does that mean that I have to create my own font using the tools I found on this forum and then simply go color them in with a color in the center?
I was under the impression that once Unity (and in fact all apps that use fonts) loads a font, it becomes like a mask and the color assigned to it is what is visible through the mask. If this is the case, how do I do a border around text?
It just means making a font as a texture. Since fonts in Unity end up as a texture anyway, there’s no difference in how they’re used. Since it’s a texture instead of a vector font, you can make it rainbow-hued if you want, or make a colored outline, etc. The only problem is that this is usable with GUIText only; OnGUI stuff seems to need the vector font.
Does this mean that I just have to use the font once in a GUIStyle so it creates the texture, then open the texture in PhotoShop and texture it as I like?
Once I modified the texture by coloring it as a rainbow, then will the GUIText not overwrite it with a color when displayed?
How DO I use it with the OnGUI?
To be exact, what I want to do with it is as follows:
When the player hits an object I want the awarded score to appear above the character and slowly move upwards. For this I assume I will need to use 3d text, completely free from the GUI
Permanently display general stats like remaining bullets, current level obtained etc
Dialogue…
Number 2 can be done using GUIText, but number 1 is 3d text and number 3, the text needs to be displayed on top of the themed background so I think OnGui would be most convenient…
Any ideas on how to use it in OnGUI?
Thanks once again for your help
Yes, if there was a way to get the font texture out of Unity, which I don’t think there is…there are a couple of topics about that around here somewhere. However, you can use something like this instead.
You’d be using the texture you save as the font texture, so there’s nothing to overwrite. You can still tint the font texture as desired, though depending on how colorful it is to begin with, that might not look so great. Normally you’d leave the color as white (untinted), so your colors in the font appear as-is.
I don’t think you can.
Actually you can use a GUIText for that instead of 3D text; that would be more typical, so the text is always the same size no matter how far away the object is. In any case, multicolored fonts will work with both.
That’s trivial to do with GUIText; in fact for this sort of thing, I find GUIText easier to work with than OnGUI.
This sort of thing, on the other hand, is much easier with OnGUI. Although, I don’t think you’d want to use a multicolored textured font for dialogue anyway.
Firstly, as far as dialogue is concerned, fonts have been the single greatest mystery to me thus far (next to level design ) in terms of there are so many thousands that exist, yet they all have the basic shapes (A can only be written in so many ways before it starts looking like another letter after all) so how to decide on a font to use? I finally came up with 2 criteria, the latter being the most important:
In keeping with the theme and feel of the game in terms of shape and color
Readability
For readability I have found that you either need a background to display the text on, or a border around your text to prevent your text and the game’s visuals melding into each other or both. I then looked at the text in RPGs on the PS2 and PSP and found they mostly use a plain Arial font in white with a black border. The simplest font there is in the most basics of colors and for years it has served us all well. I believe it will do the same for me.
Next, you managed to answer one of my main concerns earlier: A color tints the font texture, white keeps it the same so when selecting the font color select white and my texture will show up as it should. Thanks.
Lastly, I noticed that even in the documentation it also states that
This led me to believe that GUIText is now officially dead and dated and might in future versions of Unity be completely removed. Am I wrong in this train of thought?
Should I find a way of using the new stuff instead of the old or just use what is there and… actually, when I put it that way it kinda answers itself, doesn’t it?
This is very true. Computer RPGs seem to go the route of having a background for dialog, which is mostly what I’m used to. Consoles have traditionally been used on relatively blurry TV screens, so text needs all the help it can get to be readable.
It’s indeed been implied that GUIText and GUITextures are going away, but IMO this would be a big mistake. I use both GUIElements and OnGUI…there’s a lot to be said for simply attaching scripts to 2D objects and having Unity manage them for you, just like with 3D objects, which is completely impossible with OnGUI. But on the other hand OnGUI is far easier to implement for complex user-interface stuff. These are two quite different realms and I haven’t any idea why UT would want to remove a good and useful feature, but it’s their app. I can only hope they reconsider.
In any case, I’m pretty sure that multicolored text can’t be done with OnGUI at the moment, with no indication of if/when it will be possible. Meanwhile it’s definitely possible with GUIText. So yeah…might as well use what’s there.