Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Arachnos · Jun 19, 2011 at 12:35 AM · javascriptlevels

Displaying Current Level

Hey,

I'm working on a space shooter and I just want to know how to display a simple text at the bottom left of the screen that says "Level: " and then whatever level the player is on. I'm not sure how to do this using javascript because I'm fairly new to it.

Any help is appreciated and the more detail the better.

Thanks

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 aldonaletto · Jun 19, 2011 at 12:54 AM 0
Share

I posted my answer before it was ready. Now it's edited to show the whole trick.

1 Reply

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

Answer by aldonaletto · Jun 19, 2011 at 12:40 AM

Use Application.loadedLevelName to get the name and use a GUIText to display it.
Create a GUIText in the Hierarchy window, then set its properties as follows:

 Position:  X=1, Y=0, Z=0
 Text:  none (clear the "Gui Text" original)
 Anchor:  lower right
 Alignment: right

Adjust also the Font, Size and Style, then create a script like this and assign it to the GUIText:

 function Start(){
   guiText.text = Application.loadedLevelName;
 }
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 Arachnos · Jun 19, 2011 at 01:13 AM 0
Share

Awesome thank you! Very Helpful

Can I make this into a prefab to put this on all my levels easily?

avatar image aldonaletto · Jun 19, 2011 at 01:25 AM 0
Share

No problem - I used this several times. Just create a Prefab and assign the GUIText you've prepared like above to it. One more hint: if you want the text in a different color/transparency, set it in the Start function:

 function Start(){
   guiText.material.color = Color(0.5,0.5,0,0.8);
   ...

 

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

2 People are following this question.

avatar image avatar image

Related Questions

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Storing level data 3 Answers

Simple save/load scripting for multi level iOS game. 1 Answer

How to correctly shorten this script using arrays and iterations 2 Answers

Displaying Level 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