irishstorm

ScreenShots.js

Feb 2nd, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //  ScreenShots.js
  2. //  Author : Christopher Cullen
  3. //  Date : 02/02/2013
  4.  
  5. //  Description :
  6. //  This script will allow you to take screenshots while in game.
  7.  
  8. //  How to use.
  9. //  1)  Drag the script on to anything that is in the level. (i.e Main Camera etc)
  10. //  2)  Set the name of the screenshot in the inspector. ( if not it will assign one for you).
  11. //  3)  when ingame press F12 to take the screenshot.
  12. //  4)  go to the directory where your project is and in the root folder you will your screenshots.
  13.                    
  14. //  Make sure to set a name or it will use the default title.
  15. public var screenshotName : String = "";
  16. private var defaultName : String = "Default";
  17.  
  18. //  fucntion Update()
  19. //  This function will check on every frame it the F12 button is pressed
  20. //  and if it is pressed it will check the name that it has to output, if
  21. //  it does not have a name it will assign the name default and capture
  22. //  the frame and saves it to the games directory
  23. function Update()
  24. {
  25.     if(Input.GetKeyDown(KeyCode.F12))
  26.     {
  27.         if(screenshotName == "")
  28.         {
  29.             screenshotName = defaultName;
  30.         }
  31.            
  32.         time = System.DateTime.Now.ToString("_hh_mm_ss");
  33.         date = System.DateTime.Now.ToString("_dd_MM_yyyy");
  34.         Application.CaptureScreenshot(screenshotName + time + "" + date + ".png" );
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment