I’m looking to use a custom bitmap font with my desired effect, but I am unable to find how this could be done. I am familiar with the Create Editable Copy feature, but it has some big flaws for me that I can’t figure out how to fix.
Whenever I create an editable copy, Unity tries to put the characters in as small texture as possible. And that is what I would like to change.
Unity rotates the characters sideways, so whenever I would like to add an effect like drop shadow in photoshop, everything gets messed up, because the rotated characters get the shadow from a wrong angle. Is there a way to disallow the character flipping?
The characters are very tightly placed, so there is no room for effects like stroke, glow or drop shadow. Is there a way to add some kind of padding when creating the custom texture?
It would be a very useful tool if you could do the things i’ve mentioned above, but as is, it seems to be quite useless unless you only wish to fill the characters and color them.
So please respond if you know a way around, to create custom bitmap fonts or make the current method work.
If there is no such method, I think it should be high on the wish list, as it makes a huge difference as illustrated below
I actually worked myself closer to my goal and I think I could get things to work if only I knew how to change the Custom Font(the .fontsettings) file properties through a Unity Editor class.
The variables that I need to change through script are the Character Rects.
Is that even possible and if so, then how?
If someone can help me out with that then I might be able to give you guys an easy and incredibly comfortable way to create custom bitmap fonts.
And this font was made in under 5 minutes. Most of which was designing the font. Adjusting it to unity took about 30 seconds with the editor script I made.
If you need something like that yourself, let me know on this thread. If enough people want it I’ll make it available and create a short tutorial of how to use it.
E: This text was made with the default GUIText object.
Hey
Can you share your method?
I am trying to get an outline effect, and the closest I got is duplicating the text half dozen of times, I wonder if your method would be more efficient/resource friendly.
Create a c# script (right click in project window>create>c# script)
Create a GUIText in Scene window (GameObject>Create Other>GUI Text)
Drag and drop the script on the GUIText
Adjust it’s settings on the inspector window (For both GUIText and the script)
To use dynamically in-game create a prefab of the GUIText and Instantiate it, (search google on how to Instantiate prefabs)
Thanks for the script! It worked great, but the only problem I had was that it kept the old outline whenever I programmatically changed the text of my GUIText. To fix this, I just collected up all of the child objects in an ArrayList, and then set the text property to the text string of the object that it is attached to in the Update method.
using UnityEngine;
using System.Collections;
public class OutlineEffect : MonoBehaviour {
private int[] outlineX = {0,1,0,0,0,1,0,1};
private int[] outlineY = {0,0,1,0,0,1,1,0};
private ArrayList childArray;
private Vector3 tempPosition;
void Start () {
//make children and arrange them
tempPosition = gameObject.transform.position;
childArray = new ArrayList();
for (int i=0;i<(outlineX.Length)*2;i++) {
GameObject child = new GameObject("outlineChild");
child.AddComponent(typeof (GUIText));
child.transform.parent = transform;
child.guiText.text = guiText.text;
child.guiText.font = guiText.font;
child.guiText.fontSize = guiText.fontSize;
child.guiText.material.color = Color.black;
child.transform.position = tempPosition;
if(i<(outlineX.Length)) {
child.transform.guiText.pixelOffset = new Vector2(outlineX[i],outlineY[i]);
} else {
child.transform.guiText.pixelOffset = new Vector2(outlineX[i-outlineX.Length]*2,outlineY[i-outlineX.Length]*2);
}
child.transform.guiText.pixelOffset += guiText.pixelOffset;
childArray.Add (child);
}
}
void Update() {
int i;
for (i = 0; i < childArray.Count; i++) {
((GameObject) childArray[i]).guiText.text = gameObject.guiText.text;
}
}
}
I investigated your script a bit more and it appears it just duplicates the font to create a black outline. It’s nice but doesn’t really solve the problem of getting a custom font into Unity. I’m beginning to think nobody has solved this at all since Unity 4
I’ve started NGUI which looks pretty good, the outline sadly isn’t perfect as well, but I guess it is more performance friendly with all the animations and stuff. Hopefully the gui would solve it