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 kilian277 · Apr 24, 2011 at 01:19 PM · guierrorsoundmessageboxbce0077

Can someone help me with this script please

hi,

I have a script to make a messagebox that appears after a couple of seconds on the screen,

but i get an error ;

Assets/Guimessgage.js(5,7): BCE0077: It is not possible to invoke an expression of type 'int'.

here is the code ;

var WaitSeconds = 10;

function OnGUI () { if (WaitSeconds (10)) { GUI.Box (Rect (10,10,280,30), "To show the mouse press ESC button"); } }

What am i doing wrong.

I also wan't a audioclip to sound when the messagebox appears on the screen.

how do i do that ?

Any help is welcome !

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by AngryOldMan · Apr 24, 2011 at 08:54 PM

is this what you are after?

var WaitSeconds : int = 10; var showGUI : boolean = false;

function Start () { WaitFunction(); }

function WaitFunction() { yield WaitforSeconds (WaitSeconds); showGUI = true }

function OnGUI () { if (showGUI == true) { GUI.Box (Rect (10,10,280,30), "To show the mouse press ESC button"); } }

Comment
Add comment · Show 5 · 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 kilian277 · Apr 26, 2011 at 05:33 PM 0
Share

it helped a lot tnx !

avatar image kilian277 · Apr 26, 2011 at 05:47 PM 0
Share

one last question how do i destroy the message after showing ?

avatar image AngryOldMan · Apr 26, 2011 at 06:24 PM 0
Share

if you have a good look at the script and see what everything is doing you will find its blatently clear the way to switch on and off the GUI. If you want to permantly destroy it then have a look at the destory script reference http://unity3d.com/support/documentation/ScriptReference/Object.Destroy.html

avatar image kilian277 · Apr 26, 2011 at 06:49 PM 0
Share

don't $$anonymous$$d i found it

avatar image kilian277 · Apr 26, 2011 at 06:50 PM 0
Share

oops late see !

avatar image
1

Answer by Justin Warner · Apr 24, 2011 at 02:20 PM

OnGUI is ran every single frame. It's equal to Update. Having said this, you can't do a yield/WaitForSeconds (It isn't WaitSeconds) as that stops the frames.

Unless you have a method called WaitSeconds which takes the int you passed in, and then returns true when it's above the time...

So, what I'd do. Have a temp time, make it equal to the System time.

Then have an if statement comparing the current time and that one so like.

var tempTime =  System.DateTime.Now.TimeOfDay.Seconds;
function OnGUI()
{
    if(tempTime+3 > System.DateTime.Now.TimeOfDay.Seconds)
    {
        //draw
        //play sound
    }
}

As for adding sounds: http://unity3d.com/support/documentation/ScriptReference/AudioSource.html

Hope this helps! =)

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 kilian277 · Apr 26, 2011 at 05:34 PM 0
Share

and also tnx for putting my in de right direction with the audioclip !

avatar image kilian277 · Apr 26, 2011 at 05:47 PM 0
Share

one last question how do i destroy the message after showing ?

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

Let Sound Clip wait for x seconds before sounding ? 1 Answer

Can't edit GUI from another thread 1 Answer

BCE0004: Ambiguous reference 'Label' 1 Answer

Why is networkbehaviour underlined in green? 1 Answer

3 Days and I still can't figure out c# reflection, please help? Trying to use a protected Type and method. 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