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 /
avatar image
0
Question by Louis-LCM · Nov 17, 2014 at 03:13 PM · scorescore systemscoringranking

Scoring help !

hello all

First I apologize for my bad English

Secondly I would like to know how I can do that when you collect 100 coins instead of displaying "Coins: 100" ... I want to show me something like "beginner". If I collected 200 coins "advanced" .... 300 "experienced"

Here is my script

 using UnityEngine;
 using System.Collections;
 
 public class CoinsTotalShow : MonoBehaviour {
 
     private int coins = 0;
     public Texture2D coinIconTexture;
 
     // Use this for initialization
     void Start () {
         coins = PlayerPrefs.GetInt("Coins", coins);
     
     }
 
 
     // Update is called once per frame
     void Update () {
     
     }
 
     void FixedUpdate (){
         PlayerPrefs.SetInt("Coins",coins);
     }
 
     void DisplayCoinsCount()
     {
         Rect coinIconRect = new Rect(10, 10, 32, 32);
         GUI.DrawTexture(coinIconRect, coinIconTexture);                         
         
         GUIStyle style = new GUIStyle();
         style.fontSize = 30;
         style.fontStyle = FontStyle.Bold;
         style.normal.textColor = Color.yellow;
         
         Rect labelRect = new Rect(coinIconRect.xMax, coinIconRect.y, 60, 32);
         GUI.Label(labelRect, coins.ToString(), style);
     }
 
     void OnGUI()
     {
         DisplayCoinsCount();
 
     }
 }
 

 
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Sir-Irk · Nov 17, 2014 at 04:03 PM

Edit: If you haven't used if() statements before then here is a video. Learning all the concepts on that page will help you solve the majority of problems in scripting.

Edit2: I've made the code closer to what you want. But please watch the videos as this is a very rudimentary programming problem.

I'm unsure of the specifics of what you want but this should get you started:

 string skillLevel = coins.ToString() + " ";
     
 if(coins >= 300){
     skillLevel += "Experienced";
 }
 else if(coins >= 200){
     skillLevel += "Advanced";
 }
 else if(coins >= 100){
     skillLevel += "Beginner";
 }

 Rect labelRect = new Rect(coinIconRect.xMax, coinIconRect.y, 60, 32)
 GUI.Label(labelRect, skillLevel, style);


Modify the if() logic however you need.

Comment
Add comment · Show 12 · 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 Louis-LCM · Nov 17, 2014 at 06:03 PM 0
Share

It does nothing ... :(

avatar image Sir-Irk · Nov 17, 2014 at 06:29 PM 0
Share

Sorry for delayed response. $$anonymous$$y comment keeps disappearing.

Can you post the new code so I can see how you implemented it? Also, do you mean that the label is showing no text? If so make sure coins goes above or equal to 100.

avatar image Sir-Irk · Nov 17, 2014 at 06:34 PM 0
Share

I've also edited my answer to include a video that should help you with if() statements.

avatar image meat5000 ♦ · Nov 17, 2014 at 06:35 PM 1
Share

Bit vague there Louis.

I believe Irk was illustrating the method rather than handing you some completed code

this should get you started

His method is a most useful one and is a simple answer to a simple problem.

avatar image meat5000 ♦ · Nov 17, 2014 at 07:03 PM 1
Share

I think thats the unofficial Unity Slogan :D~

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

I want my score to reset back to 0 but keep my highscore saved 3 Answers

Scoring System 3 Answers

Letter Ranking System, Checking Higher Rank 1 Answer

How to save score for survival time? 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