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 Dan.R · Dec 03, 2012 at 05:49 PM · guibuttonpausetime.timescale

Unity android button and Time.timescale problems

Hi. I`m making a car game and i have problems with the pause button meaning , i use Time.timescale=0 to pause but i also use Time.timescale=0 on diffrent game events such as collisions and countdowns that end the game.This script contains both the pause button components and the game ending situations.So the problem is that each fragment works independent meaning that the pause button works but when i add the other fragment it stops working and viceversa. I `m really stuck on this and cant figure a workaround, i would really like some help on this.thanks in advance.

 var x:float=2560;
  var y:float=1600;
  var TextStyle = new GUIStyle();
  var TextStyle2 = new GUIStyle();
  var TextStyle3 = new GUIStyle();
  var time : float;
  static var timeScale : float; 
  var image : Texture; //fuel texture
  var image2 : Texture; //gameover texture
  var paused : boolean = false;
  var btnTexture : Texture;
 function OnGUI ()
 {       
  GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3(1.0*Screen.width/x, 1.0*Screen.height/y, 1.0));//resolution scale
 
  var Cooldown : String = "Fuel "+(60-Mathf.Round(Time.time)+CarsCOLLISION.Timer);
     GUI.DrawTexture(new Rect(100, 1250, 340, 340), image); //fuel 
     GUI.Label (Rect (1500, 20, 1000, 100),"Score "+(Mathf.Round(Time.time)*7+CarsCOLLISION.Score), TextStyle);//score
     GUI.Label (Rect (120, 1200, 2560, 1600),"Fuel "+(60-Mathf.Round(Time.time)+CarsCOLLISION.Timer), TextStyle2);//countdown timer
 
  
 
  if(Cooldown == "Fuel "+0)// end game when fuel is empty
   { 
      GUI.DrawTexture(new Rect(350, 300, 1920, 1080), image2);//post image game over
       Time.timeScale = 0;
 }
  else { Time.timeScale = 1;
       }
 
  if (GameObject.Find("player car") == null)// end game on collision with police
  { 
    GUI.DrawTexture(new Rect(350, 300, 1920, 1080), image2); //post image game over
    Time.timeScale = 0;
  }
 
 if (GUI.Button(Rect(10,10,100,100),btnTexture)&& paused == false)//pause button
 { Time.timeScale = 0;
   paused =true;
 }
 if (GUI.Button(Rect(40,40,100,100),btnTexture)&& paused == true)//resume button
 {  Time.timeScale = 1;
    paused =false;
 }
 
 
 
 
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dan.R · Dec 04, 2012 at 05:54 PM

 else { Time.timeScale = 1;
       } 

I have deleted this line and everything runs like clockwork:)

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity GUI Button Options 0 Answers

Play a video ingame by clickin on gameobject 3 Answers

GUI Button appears when Paused 1 Answer

A node in a childnode? 1 Answer

Custom GUI Button is Black 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