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
0
Question by sschimper · Apr 14, 2020 at 08:35 AM · saverendertexturescreenshot

[Solved] Take a Screenshot from game and use it immediately in UI

Hi,

I am working on a Load/Save UI for my game and I encountered a problem which is bugging me for quite a while.

In my UI panel, each saved game is visually represented by a button which consists of an image (the screenshot), a name provided by the user and the date and time. alt text

Whenever I save a game, I take a screenshot of the game and I save it on my hard drive. After the saving is done, I would like to update the GUI (on the screenshot above) with a new button representing that saved game. And for that, I would like to place the taken screenshot in the image slot of that button. This happens right now: alt text The screenshot is not placed inside the button. The Image file is on the hard drive, I've checked. I think I figured out what caused that bug, however I fail to come up with a solution: In order to take the screenshot and save it to the hard drive, I use the OnPostRender() function, which according to my knowledge does its job ON THE NEXT FRAME. I have another script which is in charge of creating the buttons. Its looks at the screenshots already saved on my hard drive and identifies the right one to place in the button. In this case, this script tells me that it cannot find the newly created screenshot, and I believe this is because the screenshot hasn't been rendered yet.

I don't know what I can do to fix this behaviour. Is there a way to pause the whole project until OnPostRender() is finished? I tried to use Coroutines to wait until the screenshot is rendered but this did not really work for me.

Your help is very much appreciated, thank you very much in advance for it! Have a nice day!

save2.png (177.2 kB)
save.png (132.5 kB)
Comment
Add comment · Show 1
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 sschimper · Apr 14, 2020 at 08:37 AM 0
Share

Edit: this happens immediately after I saved a game. When I exit play mode and go back to play mode the screenshots are getting displayed correctly.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by sschimper · Apr 16, 2020 at 09:23 AM

I managed to figure it out. I am wating for one frame by starting a coroutine:

 private IEnumerator UpdateCards(DisplayCards saveDisplayCards, DisplayCards loadDisplayCards, string saveName)
     {
         // will make script wait for one frame
         yield return 0;
 
         // my functions for updating the ui
         saveDisplayCards.addToCards(saveName, 1); // 1 becuase on pos 0 is the save button
         loadDisplayCards.addToCards(saveName, 0); // at pos 0
     }
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

130 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

Related Questions

Screenshot script not uploading PNG to server when used with key trigger 1 Answer

Best way to capture super large screenshot images (all GPUs) 0 Answers

Capture rendered scene to PNG with background transparent 6 Answers

capturing screen shot, and showing the captured image on screen 2 Answers

Wierd Screen Shot Problem, texture of screen shot looks different in editor and in system. 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