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 fusobotic · May 25, 2011 at 07:02 PM · guimenubackgroundpause

Paused Menu backdrop

Hey there, I have a small question, I'd like to have a semi-transparent GUI color or texture put into the game viewport when paused, sort of like in MW2, Mirror's Edge, Minecraft and lots of other games. All I need is to know how to render something like that across the entire screen (independent of screen size), instead of a single massive GUI texture, which could mess up if the resolution is higher than usual. I looked through the documentation under GUI but there isn't anything that pertains to this in particular. btw, Also I was wondering how to center a different GUItexture in the middle of the screen according to percentage instead of pixel offset. Thanks

Here's my bit of code for GUI:

 function OnGUI() {
 GUI.color = Color.black;  //version number print, ignore this
 GUI.Label (Rect (10,10,200,20), message);
 GUI.color = Color(1,1,1, 0.5);
 GUI.Label (Rect (9,9,200,20), message);

 if (Time.timeScale == 0){ //pauses the game
     //here's where I need something
 }

}

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
1
Best Answer

Answer by GlennHeckman · May 26, 2011 at 03:30 AM

For centering an object use this:

 var screenCenterX:int = Screen.width/2;
 var screenCenterY:int = Screen.height/2;
 var myObjectWidth:int = 300;
 var myObjectHeight:int = 100;
 
 var objX:int = (myObjectWidth/2) - screenCenterX;
 var objY:int = (myObjectHeight/2) - screenCenterY;

You obviously don't have to use all of those variables, but I put them there to help point out the "elements" used in a typical centering formula.

As for a full screen cover, there are many ways. Personally, I would probably create a customStyle in my GUISkin or a local GUIStyle and set the Normal value for the Box style to a semi transparent graphic you've created in Photoshop (or a similiar app). In the Box style drop down, set the width and height checkboxes to stretch. To have it display, put this code:

 var transparentScreen:GUIStyle; //this goes at the top of your script

 function OnGUI()
 {
      GUI.Box(new Rect(0,0,Screen.width,Screen.height),"","transparentScreen");
 }
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

2 People are following this question.

avatar image avatar image

Related Questions

How to place/add a HD image/picture in background of my game? 0 Answers

Halt function midway until player presses 'OK' then continue 1 Answer

Menu gui with background image 0 Answers

GUI Buttons not working after scene transition 0 Answers

Overlaping GUITexture, help! 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