Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
1
Question by absameen · Aug 24, 2012 at 01:58 PM · screenoffsetreadpixels

ReadPixels Screen is Offset

I'm using ReadPixels to capture the screen, but the texture always comes out quite a bit offset from the top.

This is the code I'm using:

 Texture2D tex2d = new Texture2D(Screen.width,Screen.height,TextureFormat.RGB24,false);
 tex2d.ReadPixels(new Rect(0,0,Screen.width,Screen.height),0,0,false);
 tex2d.Apply();


Here is what the Screen looks like:

alt text

And here is the result from ReadPixels:

alt text

Edit: It seems that ReadPixels is also reading pixels from the Unity editor. Here is another example:

The first image is what the screen looks like, and the second is what ReadPixels produces.

alt text

As you can see, a portion of the editor is being read along with the screen. How can we solve this problem?

Comment
Add comment · Show 4
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 absameen · Aug 24, 2012 at 02:52 PM 0
Share

It seems that ReadPixels will read a portion of the editor if you call it too quickly, such as in a Start method.

avatar image Khada · Aug 24, 2012 at 07:15 PM 0
Share

Probably because the main camera hasn't been set to the game camera etc. Does this problem persist after the game starts running?

avatar image absameen · Aug 24, 2012 at 08:08 PM 0
Share

It doesn't persist after the game starts running. To fix this, just wait a second before calling ReadPixels. However, I don't see why it shouldn't work correctly without having to wait. This is a bug as far as I'm concerned.

avatar image Khada · Aug 24, 2012 at 08:26 PM 0
Share

$$anonymous$$mm. Not sure about that. You could be right but there may be good reason for it. I guess there's no harm in submitting it as a bug - if it is, it will get fixed at some point. Until then, the work around is obviously no biggy :)

0 Replies

· Add your reply
  • Sort: 

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

8 People are following this question.

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

Related Questions

ReadPixels problem 3 Answers

Camera zoom while keeping an off-center object at the same screen co-ordinates 1 Answer

Trying to read pixel out of bounds - screenshot of just half the screen 1 Answer

ReadPixels from Game View (EditorWindow) 0 Answers

Aiming to center 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