Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 k_koehler · Aug 21, 2014 at 01:40 AM · editor-scriptingscreenshotscreencapture

Automatically take screen capture of multiple scenes via script

I am attempting to take high resolution screen captures of a large number of scenes in Unity without having to manually open each scene myself to initiate some sort of script to take the screen capture. If you have any advice for how to do this other than what I've shown below, I'm all ears. Otherwise, I've included my script along with the problem I'm having. I'm very new to programming in C# and am open to any and all suggestions.

This script successfully opens each scene, because I can see it cycle through the filenames on the top left of the menu bar. However, the only scene that enters play mode is the final scene. The screen capture script is attached to a camera in every scene and successfully takes a screen capture (using EditorApplication.CaptureScreenshot) within the Awake method once play mode is entered. It seems like it needs to pause and wait for play mode to be entered and for the screen capture to be taken before moving on. I've tried while loops with various conditionals and co-routines with no success.

A bit of additional info: The script is in the Editor folder in my project, so it creates a menu item that I can click within the editor to initiate it. I automatically baked all the lights for these scenes using a similar implementation, but I can't get this to work, and I have no idea why.

 using UnityEngine;
 using UnityEditor;
 using System.Collections;
 using System.IO;
 
 public class TakeCaptures : MonoBehaviour 
 {
     
     [MenuItem("SaveLighting/Take Captures")]
     
     static void TakeIt()
     {
         
         DirectoryInfo dir = new DirectoryInfo ("Assets/_CompleteScenes");
         DirectoryInfo[] info = dir.GetDirectories ();
         foreach (DirectoryInfo f in info) 
         {
             
             DirectoryInfo dir2 = new DirectoryInfo (f.FullName);
             FileInfo[] info2 = dir2.GetFiles("*bake.unity");
             foreach (FileInfo ff in info2) 
             {
                 
                 string filename = ff.FullName.ToString ();
                 EditorApplication.OpenScene (filename);
                 EditorApplication.isPlaying = true;
                 
             }
         }
     }
 }






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 anpd03 · Sep 17, 2014 at 01:21 PM 0
Share

Did you manage to find a solution to this?

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by k_koehler · Sep 17, 2014 at 09:10 PM

I ended up adopting a completely different approach that I describe below. In case you're interested in using coroutines with static methods, this is the best resource I found (it ended up not being tractable for the editor scripts I was using): http://benbeagley.com/2013/10/14/calling-a-static-ienumerator-in-unity/

What I ended up doing, I described in this thread: http://forum.unity3d.com/threads/automatically-take-screen-capture-of-multiple-scenes-via-script.266473/#post-1763168

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 anpd03 · Sep 18, 2014 at 06:05 AM 0
Share

Thanks for sharing :) much appreciated!

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

22 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

Related Questions

ScreenCapture.CaptureScreenshot skips frames 1 Answer

capture a screen shot and show in the album folder 1 Answer

Screenshot resolution using ScreenCapture 1 Answer

Take screenshot and use it as texture using ScreenCapture 2 Answers

How to do screenshot and save it in phone as png(not texture)? 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