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 Christopher Travis · Apr 15, 2011 at 12:47 AM · animationguitextguitext

HELP with scripting where GUI is involved

I have a section of code set up which is making the text appear, but it is appearing as soon as i press play rather than when the animation is triggered, hoping someone can help me sort this problem out, ill post my code below.

Thanks in advance for any help offered.

displayMessage = false;

function OnTriggerEnter (Player : Collider) { animation.Play("Take 001"); displayMessage = true; yield WaitForSeconds(3); displayMessage = false; }

function OnGUI ( ) { if ( "displayMessage" ) { GUI.Label(new Rect(Screen.width /2.5, Screen.height / 2, 200, 200), "You received 5gp"); } }

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 Justin Warner · Apr 15, 2011 at 02:21 AM 1
Share

Just my 2 cents... You should learn scripting if you really want to pursue this... Obviously, if this is for a school project, then you should be trying to LEARN something, rather than script kiddy'ing all day and having people do your whole project for you... If you don't want to make a game, then don't make a game... If you want to take the time to learn to make a game, than take the time... What you're asking is a very stupid and ignorant question that anyone with any brain of program$$anonymous$$g knowledge could answer...

2 Replies

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

Answer by Joshua · Apr 15, 2011 at 12:58 AM

At the top where you say:

displayMessage = false;

it should say:

var displayMessage = false;

and whereit says:

 if ( "displayMessage" )

it should just say:

if (displayMessage)
Comment
Add comment · Show 3 · 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 Christopher Travis · Apr 15, 2011 at 01:00 AM 0
Share

thanks joshua that helped solve that problem.

avatar image Christopher Travis · Apr 15, 2011 at 01:05 AM 0
Share

is there any way to change the size etc of the text that appears on screen? is that done in the code?

avatar image Joshua · Apr 15, 2011 at 01:32 AM 2
Share

Travis, this site is for helping unity developers when they have a real question, not for asking questions that have already been answered http://answers.unity3d.com/search?q=gui+text+size and are easy to look up http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

avatar image
0

Answer by marceloroca · Apr 15, 2011 at 12:49 AM

change if ( "displayMessage" ) to if ( displayMessage )

Comment
Add comment · Show 1 · 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 Christopher Travis · Apr 15, 2011 at 12:52 AM 0
Share

ok thanks ive just tried that when i did it though this error occurred.

Assets/NewBehaviourScript.js(13,14): BCE0005: $$anonymous$$ identifier: 'display$$anonymous$$essage'.

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

What's wrong with my function? It keeps telling me 'loseText' is not a member of 'UnityEngine.GUIText'. Please help, please and thank you! 0 Answers

How do i make a text box appear on screen after a chest has been opened? 3 Answers

Fix Blurry UI text? 10 Answers

Create GUIText from Javascript 3 Answers

Gui text, ammo counter 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