• 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
Question by Robotic · Apr 14, 2013 at 01:25 PM · guiscreenpixelboxwidth

full screen wide GUI.Box

I'm using GUI.Box to draw two black rectangles that are screen wide during cutscenes (to give a cinematic effect)

They have a 1x1 px black looping background texture, but there is always an empty pixel at the right of the screen, even if I draw my boxes with twice the screen width.

 GUI.Box(new Rect(0,0,Screen.width,heightlol),(Texture)texband,styleband);
         
 GUI.Box(new Rect(0,Screen.height-heightlol,Screen.width,heightlol),(Texture)texband,styleband);

How do I get rid of these empty pixels ?

Comment
Graham-Dunnett

People who like this

1 Show 0
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

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Graham-Dunnett · Apr 14, 2013 at 01:33 PM

Clear the camera to black and render a few frames. Then set up a rectangle for the camera so it renders to the area of the screen you want it to render to. Now you have your cinematic effect implemented the correct way.

Comment

People who like this

0 Show 0 · 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

Answer by Robotic · Apr 14, 2013 at 02:11 PM

No, this doesn't do what I want. If I change the pixelRect, the render aspect changes, I only want black rectangles to appear over the image, without altering the render. Anyway I'll need to know if there's a way to render GUI.Box that would fill up the screen in width, is there a way to do that ?

Comment

People who like this

0 Show 1 · 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 Owen-Reynolds · Apr 14, 2013 at 04:57 PM 0
Share

If you can, try to post replies as a comment (like this.)

avatar image

Answer by Owen-Reynolds · Apr 14, 2013 at 04:56 PM

You write you're drawing with twice the screen width, but the examples you give are using the normal width. To get wider than the screen (this goes an extra 10 pixels): GUI.Box( new Rect(-10,-10, Screen.width+20, Screen.height+20) ....

But, a GUI.Box is supposed to have missing pixels at the corners, to round them off all pretty. May as well use the version that draws it square: GUI.DrawTexture. You can control fade with something like GUI.color = new Color(0,0,0,fadeAmt0to1);.

EDIT:

There appears to be a "bug" in editor fixed-Aspect mode (ex: 4:3) where it paints the pixels next to the "black bars" incorrectly. In Free mode the edge-pixels are fine. I'd guess on a build it's also fine.

Comment

People who like this

0 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 Robotic · Apr 14, 2013 at 06:04 PM 0
Share

Ok thanks I'll try with the DrawTexture. Of course in the script I gave I only put screen.width because this should be enough, but I tried with screen.width*2

What I observed while doing this is that the GUI Box wouldn't go further than the right side of the screen

avatar image Robotic · Apr 14, 2013 at 06:16 PM 0
Share

Okay, so I tried and I still got these empty pixels. Here's a screenshot : alt text

And here's the code in my camera :

 void OnGUI()
         {
             float heightlol=Screen.height/12f*1.5f*CamBand;
             GUI.DrawTexture(new Rect(0,0,Screen.width*2,heightlol),(Texture)texband);
             GUI.DrawTexture(new Rect(0,Screen.height-heightlol,Screen.width*2,heightlol),(Texture)texband);
     
         }

As you can see, I used Screen.width*2 to make sure it goes far enough.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

13 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

Related Questions

Thin Line on top of GUI 0 Answers

Resizable GUI box how to? 1 Answer

Filling the screen doesn't... 1 Answer

Screen.width not returning the right values 2 Answers

Is Mesh Collider Optimal for GUI? 2 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