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.
35 lines
946 B
35 lines
946 B
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);
|
|
}
|
|
}
|
|
}
|
|
|