x


Custom score texture

I was just wondering if anyone has used a texture to display the score. What I want is to design my own numbers 0 - 9 and use this texture as the font display instead of a GUI font. Has anyone used this technique before. It's just a rough idea I was just wondering if there were any examples out there?

Thanks

more ▼

asked Dec 08 '10 at 01:10 PM

.hooligan gravatar image

.hooligan
257 46 49 57

I am a programmer and I am pretty much clueless about this kind of stuff, but can you not just use another font instead of the existing one? I do know ttf and higher using B_curves makes them just as pretty when zoomed in or out and a.f.a.i.k. that does not work for textures

Dec 08 '10 at 01:24 PM Proclyon

Just do it with a ttf, doing it your way is more complicated than it should/has to be, and it would look uneven and sloppy... Why try to do something pretty much pointless when you can do something that people have documented, and the results would look better... Just my opinion though...

Dec 08 '10 at 01:25 PM Justin Warner
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

To design textures fonts:

  1. Design 0 - 9 like you mentioned

  2. An array of Texture2D and them in, index 0 for 0 and so on till 9

  3. For the score you're setting, store it as a numeral as per normal

  4. When you want to display the score, convert it to string and parse each character as an integer and use the parsed integers as indexes for your textures.

    public Texture2D[] myArray; // slot in your textures on the editor.

    int myScore = 10000; // Put any number int textureDimension = 50;

    void OnGUI(){

       string myStringScore = myScore.ToString();
    
    
      for (int i =0 ; i < myStringScore.Length ; i++)
            GUI.drawTexture(new Rect(i * textureDimension , 0, textureDimension ,textureDimension  ) ,   myArray[int.Parse(myStringScore[i] ) ] );
    

    }

more ▼

answered Dec 08 '10 at 01:25 PM

denewbie gravatar image

denewbie
717 3 3 17

Something went wrong with the html formatting. I set the code properly but it just didnt turn out right...

Dec 08 '10 at 01:29 PM denewbie

I havent tested the code out cause I dont have unity with me but I hope you can get the idea.

Dec 08 '10 at 01:30 PM denewbie

Hey denewbie, thanks heaps for this. Makes perfect sense! I haven't tested it yet but it looks like it will work. I'll let you know how it goes. Thanks again

Dec 09 '10 at 01:10 AM .hooligan

No prob. This is definately a workable solution. If there's any trouble its probably just a few minor bugs. If there's any trouble just come back to me.

Dec 09 '10 at 05:36 PM denewbie

Can't seem to get this to work. Anyone had any luck?

Jan 06 '12 at 09:25 AM POLYGAMe
(comments are locked)
10|3000 characters needed characters left

Can you convert that to JS?

more ▼

answered Jan 26 '12 at 04:39 AM

jeriitan gravatar image

jeriitan
1

If you want a conversion done for you, post a different question instead of cluttering this one.

Jan 26 '12 at 04:40 AM syclamoth
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2196
x240
x199

asked: Dec 08 '10 at 01:10 PM

Seen: 1813 times

Last Updated: Jan 26 '12 at 04:40 AM