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 incitement · Aug 08, 2010 at 08:11 PM · guisystem

A big problem with Button, Please Help

Hello

I make this script to call an application when the plyer click the button. the script works fine that what i'm thinking first but the problem is when a click the button, the application start open in many time,

alt text

this is the script that i use

unction OnGUI () {

 if (buttonOn ==true) {

         if (GUI.Button (Rect (450, 500, 400, 120), "Question1")) {
                 windowOn = true;
         }


         if (windowOn == true) {
                 System.Diagnostics.Process.Start(Application.dataPath + "/TEKLILA.exe");



         }
 }  

is there any solution to make my application open one time when i click the button. THanks for any help

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
1

Answer by Peter G · Aug 08, 2010 at 08:27 PM

Unless you turn buttonOn false after the user clicks the button once, then you will continue to open the application again and again. So he user clicks the button once then windowOn becomes true and every time OnGUI is called, you will open the application again.

I might do something like:

var appOpen = false;

function OnGUI () {

  if (buttonOn) {

      if (GUI.Button (Rect (450, 500, 400, 120), "Question1")) {
          if(!appOpen) {
               appOpen = true;
               System.Diagnostics.Process.Start(Application.dataPath + "/TEKLILA.exe");

               //MakeButtonAvailable(10); //Will let the user click the
               //button again in 10 seconds.

          }
       }
   }

}

/ function MakeButtonAvailable (seconds : int) { yield WaitForSeconds(seconds); appOpen = false; } /

This way, when the user hits the button, the app opens, then the button won't open up any more applications. You could easily add a yield in another function which I demonstrated in parenthesis to delay the user clicking the button again for x seconds.

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

Answer by incitement · Aug 09, 2010 at 09:21 AM

Thanks Man that work Fine. you are the best

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

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

Draw Camera On GUI? 1 Answer

Accessing local system ( File Browser ) 2 Answers

Help With Message System Script 1 Answer

Scoresystem wont function correctly 0 Answers

Linking event or custom callback for gui elements by using custom UI System 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