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 JackJones · Jul 27, 2010 at 02:08 AM · guionmousedownstrings

How to put strings in a gui?

var MouseEnter : System.Boolean; var Name : String; var Level : String; var Damage : String; var Intelligence : String;

function OnMouseEnter() { MouseEnter = true; }

function OnMouseExit() { MouseEnter = false; }

function OnGUI() { if(MouseEnter == true) {

GUI.Box(Rect(200,100,150,200),Name); GUI.Label(Rect(205,150,100,100),"Level : ",Level); GUI.Label(Rect(205,200,100,100),"Damage : ",Damage); GUI.Label(Rect(205,250,100,100),"Intelligence : ",Intelligence);

}

}

here is my script how ever when it runs it says "Unable to find style '1' in skin 'GameSkin' repaint" but im just wanting the string that i type in the editor to pop up please help thanx :)

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 Eric5h5 · Jul 27, 2010 at 02:18 AM 0
Share

Format code by selecting it and hitting the code format button.

1 Reply

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

Answer by Eric5h5 · Jul 27, 2010 at 02:16 AM

You're trying to use string variables as GUIStyle parameters. Change the "," to a "+":

GUI.Label(Rect(205,150,100,100),"Level : "+Level);

BTW, you can just use "boolean" instead of "System.Boolean". Also it's a good idea to get in the habit of using lowercase for variable names (and upper case for functions and classes), because that's what the convention is in Unity, so code that adheres to that is more understandable. Also you should use appropriate types for variables...the level, damage, and intelligence variables should probably be ints, and then use ToString() to convert to strings where necessary.

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 JackJones · Jul 27, 2010 at 02:22 AM 0
Share

Thanx a lot mate really help full :)

avatar image sovalopivia · Jul 27, 2010 at 10:47 AM 0
Share

Perhaps you could add the ToString() to your code snippet to make it more clear that it is important to include, and and how to use it? :)

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

No one has followed this question yet.

Related Questions

Disable Mouse Input when OnGUI() 1 Answer

How to disable a part of a script to avoid replayed camera animations ? 0 Answers

Check if a button is NOT pressed? 3 Answers

How to make GUI object prevent clicking/touching what is under it? 1 Answer

Hide/show GUI Buion 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