You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.5 KiB

5 years ago
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.IO;
  4. using UnityEditor;
  5. [RequireComponent(typeof(Camera))]
  6. public class Renderator_FREE_EN : MonoBehaviour {
  7. public int multipler; // multipling Game window resolution
  8. public KeyCode render; // press it to make render
  9. public bool renderAtStart; // if true it will render at start
  10. public string path; // path where renders will be saved
  11. void Start ()
  12. {
  13. if(path == "")
  14. {
  15. if(!Directory.Exists("Assets/Screenshots")) // check if folder exist
  16. Directory.CreateDirectory("Assets/Screenshots"); // if not it creates one
  17. }else if(!Directory.Exists(path)) // the same for our path
  18. Directory.CreateDirectory(path);
  19. if(renderAtStart)
  20. {
  21. if(path == "") // saving in Asset folder
  22. {
  23. ScreenCapture.CaptureScreenshot("Assets/Screenshots/Render" // path to folder with renders and firts part of the name (Render)
  24. + System.DateTime.Now.ToString("_yyyy-MM-dd_") // giving date to name
  25. + System.DateTime.Now.ToString ("hh-mm-ss_") // giving current time to name
  26. + ".png", multipler); //screenshot with resolution multipler
  27. }else
  28. { // saving in our folder we choose
  29. ScreenCapture.CaptureScreenshot(path + "/Render" // path to folder with renders and firts part of the name (Render)
  30. + System.DateTime.Now.ToString("_yyyy-MM-dd_") // giving date to name
  31. + System.DateTime.Now.ToString ("hh-mm-ss_") // giving current time to name
  32. + ".png", multipler); //screenshot with resolution multipler
  33. }
  34. }
  35. }
  36. void Update()
  37. {
  38. if(Input.GetKeyDown(render))
  39. {
  40. if(path == "") // saving in Asset folder
  41. {
  42. ScreenCapture.CaptureScreenshot("Assets/Screenshots/Render" // path to folder with renders and firts part of the name (Render)
  43. + System.DateTime.Now.ToString("_yyyy-MM-dd_") // giving date to name
  44. + System.DateTime.Now.ToString ("hh-mm-ss_") // giving current time to name
  45. + ".png", multipler); //screenshot with resolution multipler
  46. }else
  47. { // saving in our folder we choose
  48. ScreenCapture.CaptureScreenshot(path + "/Render" // path to folder with renders and firts part of the name (Render)
  49. + System.DateTime.Now.ToString("_yyyy-MM-dd_") // giving date to name
  50. + System.DateTime.Now.ToString ("hh-mm-ss_") // giving current time to name
  51. + ".png", multipler); //screenshot with resolution multipler
  52. }
  53. }
  54. }
  55. [ContextMenu("Choose save folder")]
  56. void Kalesony()
  57. {
  58. string piach = EditorUtility.OpenFolderPanel("Choose save folder", "", "");
  59. if( piach.Length != 0 )
  60. {
  61. path = piach;
  62. }
  63. }
  64. }