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
1
Question by Gadied · Oct 27, 2015 at 11:57 AM · unity 5screenscreenshotoffsetreadpixels

ReadPixels problem

Hello, I have a problem that is driving me crazy , I searched literature about it but it seems no one gives to the solution , some say even that may be a bug in this version of Unity . The problem is that when I try to take a screenshot I obtain always an offset image. I used this code:

public IEnumerator CaptureCamera() { isProcessing = true; // wait for graphics to render yield return new WaitForEndOfFrame();

     // create the texture
     Texture2D screenTexture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, true);
     // put buffer into texture
     screenTexture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
     // apply
     screenTexture.Apply();

     dataToSave = screenTexture.EncodeToPNG();
     destination = Path.Combine(Application.persistentDataPath, System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".png");
     File.WriteAllBytes(destination, dataToSave);
     isProcessing = false;
 }

this the original img:alt text and this is the result:alt text My Unity version is 5.2.2f1 Personal Please someone knows the solution to this problem? Thanks in advance

bug1.jpg (245.1 kB)
bug2.png (248.3 kB)
Comment
Add comment · Show 7
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 _dns_ · Oct 27, 2015 at 02:33 PM 1
Share

Hi, do you have multiple render target/textures ? ReadPixels reads from the current render target so you may be saving an image from another render target/texture. Try setting RenderTexture.active to the correct RenderTexture before calling readpixels (I think setting it to null means you want to read what's on screen, not in a render texture).

avatar image Gadied · Oct 28, 2015 at 05:57 PM 0
Share

O$$anonymous$$, is a Bug. I change for Unity version 5.1 and all works fine. Thanks anyway

avatar image AngryMuppet · Nov 06, 2015 at 09:57 AM 1
Share

I've just found this issue as well in 5.2.2p2. I'm only getting half a screenshot in portrait with the first half being black.

Did you find/report the bug so I can vote on it? Can't seem to find any mention in the issue tracker?

avatar image Gadied · Nov 07, 2015 at 03:38 AM 0
Share

i reported, but don recive any answer

avatar image antti_partagames · Dec 07, 2015 at 01:13 PM 0
Share

Welp, I'm having this problem too with Unity 5.2.3f1

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by wibble82 · Dec 07, 2015 at 02:20 PM

Could I just check - are you running the code in 'PostRender'. I could be wrong, but I believe that exactly where you call ReadPixels can matter (perhaps it shouldn't, but it might well do), as it's reading from a render target.

Try putting your code in 'OnPostRender' of your camera object.

-Chris

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

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 Screen is Offset 0 Answers

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

Unity not recognizing clipboard contents (Still Unsolved) 1 Answer

Texture2D.ReadPixels Being Set But Not Saved? 1 Answer

Take photo in unity 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