Search Unity

Pause menu script added to the wiki

Discussion in 'Immediate Mode GUI (IMGUI)' started by Deleted User, Mar 14, 2008.

  1. Deleted User

    Deleted User

    Guest

  2. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    nice! going have a play with it now.

    cheers.
     
  3. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    Wow, thats pretty comprehensive... a pause script on steroids!
     
  4. Deleted User

    Deleted User

    Guest

    Thanks, all it needs is a game attached!
     
  5. ToxicInsanity

    ToxicInsanity

    Joined:
    Oct 13, 2010
    Posts:
    1
    Great job, exactly what I was looking for. Thank you!
     
  6. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Very nice work. ty!
     
  7. Choczy123

    Choczy123

    Joined:
    Jan 21, 2011
    Posts:
    184
    What is the SepiaToneEffect??? I cant find it -_-
     
  8. BriceMcphail

    BriceMcphail

    Joined:
    Jun 3, 2011
    Posts:
    4
    Me Either!!!! I get the same error
     
  9. BrknGlassStudios

    BrknGlassStudios

    Joined:
    May 12, 2011
    Posts:
    4
    The answer to your question is in the "Setup" instructions:

     
  10. clxyeah

    clxyeah

    Joined:
    Aug 4, 2011
    Posts:
    59
    Thanks heaps!
     
  11. edasert

    edasert

    Joined:
    Jul 26, 2013
    Posts:
    2
    How can I comment out that section?

    BTW thank you
     
  12. Philip-Rowlands

    Philip-Rowlands

    Joined:
    May 13, 2013
    Posts:
    353
    Select the code inside MonoDevelop and then right-click. When the menu appears, select "Comment Selection".


    EDIT: thanks for that script, technicat.
     
  13. Deleted User

    Deleted User

    Guest

  14. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    This looks like a great scipt although I can't use it because it keeps giving me this error:

    Assets/Pause menu/Pausescript.js(366,25): BCW0012: WARNING: 'UnityEngine.GameObject.active' is obsolete. GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.


    any thoughts on how to fix this?

    The cursor doesn't lock making the camera still able to move during pause.
     
    Last edited: Apr 19, 2014
  15. Deleted User

    Deleted User

    Guest

    That's actually a compiler warning, not an error, so it should still run, but warnings should be fixed, too. I'll fix the script on github (haven't touched it in a couple of years), but if you want to take a crack at it ahead of time and fix the script yourself (it's just a couple of lines in the script), I think it's a worthwhile exercise both in terms of getting familiar with the script and understanding SetActive, as that's a pretty important Unity script function everyone should understand.

    Check out the Unity Script Reference page for SetActive, and the Unity 4 release notes has an explanation of how it differs from the Unity 3 active variable. The change was big enough to confuse a lot of people, so I blogged about it too:

    http://www.fugutalk.com/?p=5892
     
  16. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    Thanks for the link to the blog, reading it now. Yes it still works but the cursor doesn't lock and the camera still moves around v_v

    I will try to have a crack at it as you say :p see how far I get but I am a noob at scripting so I may end up waiting till you fix it.

    I know it has to do with (obj.active)
     
  17. Deleted User

    Deleted User

    Guest

    I don't know why the cursor lock wouldn't work (as long as the variable is set to true in the inspector, and keep in mind it cursor locks when unpaused and not when paused), but the script only pauses time so it would only pause camera move if that is time dependent (e.g. I don't think the Unity-supplied mouselook script will stop movement when time is paused). So that's up to you to explicitly disable or modify scripts that need to be paused (see earlier posts on checking if timeScale is zero or disabling scripts and that that that of stuff is asked on the Unity answer site too).

    The code in the script that sets active is actually a feeble attempt at letting you deactivate something extra besides just pausing time, but obviously it's limited (just one GameObject, which was enough for my purposes at the time), so that code is a good place to customize with your extra pause/unpause code. Think of the script as a starter example (as you can see from the github mod date, I haven't been using it for a long while since I don't use UnityGUI anymore...)
     
  18. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    I see, yes I can add in a lock camera scipt to it :) looking into it now.
     
  19. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    I fixed it with this addition:

    var firstPersonControllerCamera = gameObject.Find("First Person Controller").GetComponent(MouseLook);
    var mainCamera = gameObject.Find("Main Camera").GetComponent(MouseLook);

    Here's the script: http://pastebin.com/iLusCTPF

    Basically added the FPS controller and main camera as a variable and then called it after the pause menu is off :)

    Although clicking "Continue" doesn't really work
     
    Last edited: Apr 19, 2014
  20. Deleted User

    Deleted User

    Guest

    Nice job! By the way, I just remembered I have yet another version of the pause script written for my Unity 4 book, so that version should be up to date with Unity 4 but on the other hand is probably more limited since I tailored it for the book. It's included in the project samples on github: http://technicat.github.io/LearnUnity/