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
0
Question by biohazard · Jun 03, 2011 at 12:39 PM · javascriptgui

Need help with my script

i have one major problem with this script. everyting works except the buttons "Erster Wert" (first value) and "Letzter Wert" (last value)..

i am really finished off D:

 var Source : TextAsset;
 var ZeigerSpeed : GameObject;
 var ZeigerRPM   : GameObject;
 var ZeigerHitze : GameObject;
 var DisplaySpeed : GUIText;
 var DisplayRPM : GUIText;
 var DigitalSpeed = 0;
 var DigitalRPM = 0;
 var DrehungSpeed = 0.0;
 var DrehungRpm = 0.0;
 var DrehungHitze = 0.0;
 
 var Paused : boolean = false;
 var Rewinding : boolean = false;
 var ErsterWert : boolean = false;
 var LetzterWert : boolean = false;
 
 var DrehungSpeed_alt = 0.0;
 var DrehungRpm_alt = 0.0;
 var DrehungHitze_alt = 0.0;
 
 var counter =4;
 
 var i = 4;
 
 
 
 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]);
         //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(1.0);
         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(1.0);
         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(1.0);
         }
         
         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(1.0);
             
         }
         
 }
 }
 function OnGUI(){
     
     
     if(GUI.Button(Rect(10,10,50,50),"Play"))
     
     {
         
         Dashboard();
     
     }
     
     if(GUI.Button(Rect(10,70,50,50),"Pause")) 
         
         { 
             if(Paused == false) Paused = true; 
             else 
             Paused=false;
             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;
     }
     
     GUI.Box(Rect(0,1080,Screen.width,Screen.height/4.0),"Zeilennummer : " + i + "\n" + "Geschwindigkeit : " + DigitalSpeed + "\n" + "Umdrehungen Pro Minute : " + DigitalRPM + "\n");
 }
 function Start()
 {   
     
 }   
 
 function Update()
 {
 
     
     ZeigerSpeed.transform.rotation = Quaternion.Lerp(ZeigerSpeed.transform.rotation,Quaternion.Euler(0,0,DrehungSpeed),Time.deltaTime*1.5);
     ZeigerRPM.transform.rotation = Quaternion.Lerp(ZeigerRPM.transform.rotation,Quaternion.Euler(0,0,DrehungRpm),Time.deltaTime);
     //ZeigerHitze.transform.rotation = Quaternion.Lerp(ZeigerHitze.transform.rotation,Quaternion.Euler(0,0,DrehungHitze),Time.deltaTime); //No algorithm yet
      DisplaySpeed.text = DigitalSpeed.ToString("000 km/h");
      DisplayRPM.text = DigitalRPM.ToString("0000 RPM");
      
 }
Comment
Add comment · Show 6
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 · Jun 03, 2011 at 01:34 PM 0
Share

also offering translations of the variables!

avatar image Peter G · Jun 03, 2011 at 01:37 PM 0
Share

Could you give the expected behavior? What do you want to happen compared to what actually is happening?

avatar image biohazard · Jun 03, 2011 at 01:43 PM 0
Share

if i press first value button, the needles on my dashboard are supposed to rotate after the first line's values in my TextAsset....now you can guess what last value button does :O

avatar image RetepTrun · Jun 03, 2011 at 02:07 PM 0
Share

I take it this is a speedometer for a car?

How to apply it to test it out?

Whats an Ersterwert and a lesterwert?

avatar image biohazard · Jun 03, 2011 at 02:16 PM 0
Share

ErsterWert = first value LetzterWert = last value

it is a speedometer.

make 3 cyliners and pretend they are ur needles. get a .csv file with speed values in it.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting Scroll View Width GUILayout 1 Answer

Items with Statistics(such as attack damage) that actually effect the character? 2 Answers

[SOLVED]Possible Alternation of Transform.Rotate 1 Answer

Limit on GUI Components? 0 Answers

Finding if a specific key contains a specific value in a Hashtable? 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