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 /
This question was closed Apr 24, 2014 at 03:09 PM by robertbu for the following reason:

Multiple technical issues/too broad

avatar image
0
Question by ysleungrockman · Apr 24, 2014 at 02:47 PM · imagescorenumberhealth

Using images to show numbers

I have images of 0 to 9 numbers. I want to use them to show numbers like score and health, etc. The system will calculate the score and health and then show. To show it as image, I think the system needs to find out the number of each unit of a number. Then combine the numbers to form score or health. But how can I do that by C# script?

Comment
Add comment · Show 1
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 robertbu · Apr 24, 2014 at 03:08 PM 0
Share

This question is too broad, involving multiple technical issues...and boarders on asking someone to write a script for you. Unity Answers focuses on answering questions about single, specific technical issues to help you write your own code. The starting point for your problem is to figure out how to change a game object's visible texture. There are multiple approaches...some more efficient than others...some more complex than others.

As you break your problem down to specific issues, we welcome your single specific technical questions.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by KevLoughrey · Apr 24, 2014 at 03:03 PM

It'd probably be easiest to make your images 1 - 9 into a font and draw that to the GUI.

Otherwise, you'd need to do something like breaking the score (for example, an int) into its component digits by converting it to a string, then to a charArray, then map each element of that array to the corresponding number image.

Comment
Add comment · Show 2 · 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 ysleungrockman · Apr 24, 2014 at 03:16 PM 0
Share

If I want to use the second one, what method can I use to break the score?

avatar image KevLoughrey · Apr 24, 2014 at 03:21 PM 0
Share

Off the top of my head, to convert the string to an array of characters you'll need something like: int.ToString().ToCharArray() Then you can access each element of the array and map it to an image. For example, if you name your images like "0.png", "1.png", etc. You can call them using something like:

for (int i = 0; i < array.Count() - 1; i++) {

//Pseudocode - can't remember the exact draw syntax

GUI.Draw(array[0] + ".png");

}

Obviously that code's not going to work. Can't remember any of the syntax off the top of my head, but it's the right idea. I'd still recommend making a custom font though! There are plenty of free font generators online.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Creating a Lifebar with simple GUI in C# 3 Answers

Healthy Floating Numbers 3 Answers

Health to come above enemy when clicked 1 Answer

How to add score/health ? 2 Answers

Score that ticks up 1 Answer


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