using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; public class PixelSaver : MonoBehaviour { [Tooltip("the root path will be sibling of unity project path")] public string dataRoot = "Screenshot"; DirectoryInfo pool_root; DirectoryInfo PoolRoot { get { if (pool_root == null) pool_root = Directory.GetParent(Application.dataPath).Parent.CreateSubdirectory(dataRoot); return pool_root; } } FileInfo GetFileInfo(string filename) { return new FileInfo(PoolRoot.FullName + @"\" + filename); } private void Update() { if (Input.GetKeyDown(KeyCode.P)) { string filename = string.Format("Screenshot-{0}.png", System.DateTime.Now.ToString("yyyyMMddHHmmss")); ScreenCapture.CaptureScreenshot(GetFileInfo(filename).FullName); } } }