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 biohazard · Jul 12, 2011 at 10:44 AM · guipauseplayrewind

Pause, Play and Rewind buttons for a function

Hello,

I have written a function and in my Project's GUI i got buttons with the names :

Pause, Play, Rewind.

It's all good until now, but when i capsule the buttons into each other (first play gets pressed, then rewind, pause, play etc)

It starts my function Multiple times and this isn't what i'm looking for.

Linking the functions OnGUI() and Dashboard()

  function Dashboard()
 {
     var lines = Source.text.Split("\n"[0]);
     for(i = counter; i < lines.Length; i++)
     {
         
         DrehungSpeed_alt = DrehungSpeed;
         DrehungRpm_alt = DrehungRpm;
         DrehungHitze_alt = DrehungHitze;
         var values = lines[i].Split(";"[0]);
         DrehungSpeed = int.Parse(values[4]);
         DrehungRpm = int.Parse(values[8]);
         DigitalSpeed = int.Parse(values[4]);
         zeilennr = i;
         //DrehungHitze = int.Parse(values[XXXX]);
         DrehungSpeed = Mathf.Clamp(DrehungSpeed/300.0 * 180.0,0.0,180.0);
         DrehungRpm = Mathf.Clamp(DrehungRpm/8000.0 * 240.0,0.0,240.0);
         
         DigitalRPM = int.Parse(values[8]);
         yield WaitForSeconds(0.5);
         counter = i;
         if(Paused == true) 
         { 
             Rewinding = false;
             ErsterWert = false;
             LetzterWert = false;
             break;
             
             
         }
         
         if(Rewinding == true)
         {
                 Paused = false;
                 ErsterWert = false;
                 LetzterWert = false;
                 for(i = counter; i > 4; i--)
             {
         
         values = lines[i].Split(";"[0]);
         DrehungSpeed_alt = DrehungSpeed;
         DrehungRpm_alt = DrehungRpm;
         DrehungHitze_alt = DrehungHitze;
        
         DrehungSpeed = int.Parse(values[4]);
         DrehungRpm = int.Parse(values[8]);
         DigitalSpeed = int.Parse(values[4]);
         
         //DrehungHitze = int.Parse(values[XXXX]);
         DrehungSpeed = Mathf.Clamp(DrehungSpeed/300.0 * 180.0,0.0,180.0);
         DrehungRpm = Mathf.Clamp(DrehungRpm/8000.0 * 240.0,0.0,240.0);
         
         DigitalRPM = int.Parse(values[8]);
         yield WaitForSeconds(0.5);
         counter = i;
             
         
         
             }
     
     } 
     
         if(ErsterWert == true)
         {
             Paused = false;
             Rewinding = false;
             LetzterWert = false;
             
             
             values = lines[4].Split(";"[0]);
             DrehungSpeed = int.Parse(values[4]);
             DrehungRpm = int.Parse(values[8]);
             DigitalSpeed = int.Parse(values[4]);
             //DrehungHitze = int.Parse(values[XXXX]);
             
             DrehungSpeed = Mathf.Clamp(DrehungSpeed/300.0 * 180.0,0.0,180.0);
             DrehungRpm = Mathf.Clamp(DrehungRpm/8000.0 * 240.0,0.0,240.0);
         
             DigitalRPM = int.Parse(values[8]);
             yield WaitForSeconds(0.5);
         }
         
         if(LetzterWert == true)
         {
             Paused = false;
             Rewinding = false;
             ErsterWert = false;
             
             var endwert = lines.length - 1.0;
             
             values = lines[endwert].Split(";"[0]);
             DrehungSpeed = int.Parse(values[4]);
             DrehungRpm = int.Parse(values[8]);
             DigitalSpeed = int.Parse(values[4]);
             //DrehungHitze = int.Parse(values[XXXX]);
             
             DrehungSpeed = Mathf.Clamp(DrehungSpeed/300.0 * 180.0,0.0,180.0);
             DrehungRpm = Mathf.Clamp(DrehungRpm/8000.0 * 240.0,0.0,240.0);
         
             DigitalRPM = int.Parse(values[8]);
             yield WaitForSeconds(0.5);
             
         }
         
 }
 }function OnGUI(){
     
     
     if(GUI.Button(Rect(10,10,50,50),"Play")) 
     
     {    
         Dashboard();            
     }
     
 
         
          
 
                     
     
 
     
     
     if(GUI.Button(Rect(10,130,70,50),"Rewind")) 
     {
         Rewinding = true;
     }
     
     
     if(GUI.Button(Rect(10,190,100,50),"Erster Wert"))
     {
         ErsterWert = true;
     }
     
         
     if(GUI.Button(Rect(10,250,100,50),"Letzter Wert"))
     {
         LetzterWert = true;
     }
     
     if(GUI.Button(Rect(10,310,100,50),"Close"))
     {
         Application.Quit();
     }
     
     GUI.Box(Rect(0,1080,Screen.width,Screen.height/4.0),"Zeilennummer : " + i + "\n" + "Geschwindigkeit : " + DigitalSpeed + "\n" + "Umdrehungen Pro Minute : " + DigitalRPM + "\n");
Comment
Add comment · Show 4
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 Waz · Jul 12, 2011 at 01:06 PM 0
Share

The German variable names I can manage, but your formatting makes it unreadable regardless. Please fix.

avatar image biohazard · Jul 12, 2011 at 01:15 PM 0
Share

Formatting doesn't matter at all...

avatar image Waz · Jul 12, 2011 at 01:29 PM 0
Share

It does to people who you want to read that mess. We aren't compilers.

avatar image biohazard · Jul 12, 2011 at 01:33 PM 0
Share

short from of the code : i'm reading a file with racing values like velocity and engine rotation and rotating a dashboard's needles with them. now i want play, pause and rewind buttons.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Waz · Jul 12, 2011 at 01:42 PM

It's starting Dashboard multiple times, because that's what your code tells it to do (eg. whenever you toggle Pause). Start it once, then control it through the variables, otherwise you're just going to get into a big mess.

Comment
Add comment · Show 7 · 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 biohazard · Jul 12, 2011 at 01:43 PM 0
Share

oh i forgot to update the script. 1 sec

avatar image biohazard · Jul 12, 2011 at 01:45 PM 0
Share

@Warwick Allison script updated

avatar image Waz · Jul 12, 2011 at 02:10 PM 0
Share

I think you need to restructure that code to have a single loop. For example, how are you going to pause or play while rewinding?

avatar image biohazard · Jul 12, 2011 at 02:11 PM 0
Share

that exactly is the problem i keep running into

avatar image Waz · Jul 12, 2011 at 03:00 PM 1
Share

So learn, and stop contradicting. "Formatting doesn't matter at all" is about the most ignorant comment I've ever seen on this site.

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to play sound on GUI touch IOS 1 Answer

A node in a childnode? 1 Answer

Unity android button and Time.timescale problems 1 Answer

How to Disable/Inactive NGUI Button on Game Pause? 0 Answers

Help with GUI clicking ??? 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