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 Rgalaxy · Jan 19, 2014 at 05:47 AM · javascripttimescaleprevent

Time.timeScale = 0 did not prevent click

Holla Uniters ! i try to figure out how to pausing a game.. after awhile of searching i found out there are a lot of way to do it.. but i comes up with the easiest(i think) way to do it.

So, part of my code is

 function Start{
    Time.timeScale=0
 }
 function OnGUI{
    If(GUI.Button(new Rect(100,100,50,50),"next")){
        Time.timeScale=1;
    }
 }

ok, it works perfectly, but.. in the background of this i have some GUI Button attached to the screen, and when i press "Play" i can still press the GUI Button, and is affecting game, although it doesn't move the player.. but after i press "next" my character start moving because of action i do before.. could anybody help me?

How exactly i could make, say, i want to blackout all the back screen OR i want so that player couldn't touch anything until they press "next"

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 HappyMoo · Jan 19, 2014 at 12:08 PM

Your code shouldn't work. This does nothing:

 Time.timeScale=1;


If you don't want some things to be possible, don't allow them or hide them if timescale==0. Unity doesn't do that for you, or you wouldn't be able to leave pause again if all Buttons stopped working.

http://docs.unity3d.com/Documentation/ScriptReference/Time-timeScale.html

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 Rgalaxy · Jan 19, 2014 at 12:23 PM 0
Share

so what i should do , is play the logic of hiding and unhiding objects i dont want to interact with?

but, i just too confused for my code aldy to how to hide them.. i mean like if i have button and drawtexture, if i press the button, i want the button to go away to underworld and only appear the drawtexture, so its like

 if(GUI.Button(Rect(0,0,10,10), "press")){
    GUI.DrawTexture(new Rect(0,0,200,200),someTexture)
    //also disable the "press" Button.
 }

if i just use boolean to enable and disable the GUI.Button won't it disable the DrawTexture also? sorry if i ask silly thing, but i just can't get it on my $$anonymous$$d about the logic :(

avatar image HappyMoo · Jan 19, 2014 at 01:00 PM 0
Share

if you go into pause, just set pause$$anonymous$$ode=true and then have some code depend on that...

 if (pause$$anonymous$$ode)
 {
   // show pause menu etc.
 } else {
   // normal game logic here
 }

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

19 People are following this question.

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

Related Questions

Javascript Timescale Problem 0 Answers

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

how to make Time in your game while you play? 1 Answer

Smooth the Changes in TimeScale, in TimeBending script 0 Answers


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