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
2
Question by BandMaster · Dec 10, 2015 at 05:08 PM · c#cameraerrorrenderingrendertexture

RenderTexture and Readpixels android problem.

This is where I stuck. Basicly i trying to make "ShareMyScore-Image", an image with current score, when player loose.
While everything works just fine in editor, on android device i got black screen.
What am I doing wrong?

         SecondCamera.aspect = 1.0f;
         Texture2D virtualPhoto = new Texture2D(1024, 1024, TextureFormat.RGB24,false);      
         SecondCamera.enabled = true;
         RenderTexture.active = ScreenShot; //public link RenderTexture
         SecondCamera.Render();   
         virtualPhoto.ReadPixels(new Rect(0, 0, virtualPhoto.width, virtualPhoto.height), 0, 0,false);
         virtualPhoto.Apply();
         SecondCamera.enabled = false;
 
         File.WriteAllBytes(Application.persistentDataPath + "/1.png", virtualPhoto.EncodeToPNG());

Comment
Add comment · Show 2
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 Kirshor · Feb 21, 2018 at 08:58 AM 0
Share

$$anonymous$$e too: RenderTexture.Create failed: format unsupported - 2.

error at: mTexShadow2D.ReadPixels(mRectCopy, 1, 1);

Unity 2017.3.1f Only occur with my Android tablet, on my android phone it runs Ok.

avatar image WARdd · Jan 03, 2020 at 10:08 AM 0
Share

Have you made any progress on this problem? I suspect it's related to texture formats being overridden to different types for different platforms.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by WARdd · Jan 03, 2020 at 02:58 PM

I was dealing with the same problem. It seemed to get fixed by making sure there is always something rendering to the rendertexture e.g. a small image, or for a more clean solution, a solid black background.

I'm not sure why this made a difference, maybe the texture gets internally disabled on some platforms if it's fully transparent when Unity boots up?

Would appreciate if someone can figure out more about this, but I'll post this solution in case it can help someone.

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
avatar image
0

Answer by RobAnthem · Feb 21, 2018 at 09:07 AM

Umm, you are literally just creating a blank 1024x1024 image, reading the blank pixels, applying the still blank pixels, and then serializing it. Nowhere are you assigning pixels to the virtualPhoto, or assigning it as a render texture. It will always be a black image.

Comment
Add comment · 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 WARdd · Jan 03, 2020 at 10:04 AM 0
Share

ReadPixels has a slightly deceptive name, it takes the active screen texture and applies it to a texture. The ScreenShot rendertexture is presumably being rendered to and then applied to virtualPhoto using ReadPixels

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

6 People are following this question.

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

Related Questions

RenderTexture.Create failed: format unsupported 0 Answers

Object shown on top of another, rendering priorities? 2 Answers

Best way to access RenderTexture immediately after camera render 0 Answers

Trying to reset image settings on main camera smoothly 1 Answer

ClearFlags don't seem to work when I manually call Render() on my cameras. 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