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 /
  • Help Room /
avatar image
0
Question by Santifocus · May 14, 2019 at 09:04 AM · cameracolortexture2drendertexturescreenshot

Wrong Coloring (Sometimes) when capturing "Screen"-shot

I have a modular ShipEditor in my game where you are able to piece your ship together to then later use it, when you start the scene where you edit ships you get a Panel with Previews of all your creations, these creations are the typicall "Create a camera/rendertexture, camera.render(), Texture.readpixels(), destroy camera" and the output would be something like this:

alt text

but for some reason sometimes (!) it looks some sort of this: alt text the colors seem to be different everytime.

I call this in the first frame of the Playmode, that might be a part of the problem, here is the code:

         private RenderTexture GetPreview(Ship ship)
         {
             RenderTexture preview = new RenderTexture(128, 128, 1);
             preview.format = RenderTextureFormat.ARGBFloat;
 
             //build ship
             GameObject chassis = Instantiate(AllChassis[ship.data.chassisReference].shipObject, transform);
             bool armourIsCenter = false;
             if (ship.data.selectedArmour != -1)
             {
                 armourIsCenter = true;
                 Instantiate(AllChassis[ship.data.chassisReference].chassisArmors[ship.data.selectedArmour].armorObject, AllChassis[ship.data.chassisReference].armorSlot.position, Quaternion.Euler(AllChassis[ship.data.chassisReference].armorSlot.direction), chassis.transform);
             }
 
             for (int i = 0; i < ship.data.filledModuleSlots.Length; i++)
             {
                 if (ship.data.filledModuleSlots[i] == -1)
                     continue;
 
                 Instantiate(AllModules[ship.data.filledModuleSlots[i]].model, AllChassis[ship.data.chassisReference].moduleSlots[i].position, Quaternion.Euler(AllChassis[ship.data.chassisReference].moduleSlots[i].direction), chassis.transform);
             }
 
             for (int i = 0; i < chassis.transform.childCount; i++)
             {
                 chassis.transform.GetChild(i).gameObject.layer = 15;
             }
             //position camera
 
             previewScreenshotCamera.transform.position = (armourIsCenter ? AllChassis[ship.data.chassisReference].armorSlot.position : Vector3.zero) + previewScreenshotCamera.transform.forward * -20;
 
             //screen shot
             previewScreenshotCamera.gameObject.SetActive(true);
             previewScreenshotCamera.targetTexture = preview;
             previewScreenshotCamera.Render();
             previewScreenshotCamera.gameObject.SetActive(false);
             previewScreenshotCamera.targetTexture = null;
 
             DestroyImmediate(chassis); //needs to be immediate or a ghost of this will appear in next preview
             return preview;
         }

normal.png (9.3 kB)
notnormal.png (10.2 kB)
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
0
Best Answer

Answer by Santifocus · Sep 17, 2019 at 01:19 PM

Forgot to post the fix that i found out a while ago, for anyone who might encounter this problem. Apparently Unity does some stuff with the camera in the first frame-Awake, therefore you should only do screenshots in Start or later. Could be considered a bug not sure if it will be fixed tho.

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

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

Related Questions

ScreenCapture.CaptureScreenshotAsTexture() is making a milky white tinted screenshot. 1 Answer

Trying to Take a Snapshot of Only a Portion of the Screen In-Game 0 Answers

HDRP: Camera solid color background 0 Answers

how can i store a screenshot into android mobile? 0 Answers

Rendering Camera to PNG produces completely grey image. 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