// ========================================================
// 描述:
// 作者:青龙
// 创建时间:2020-08-10 11:02:12
// 版 本:1.0
// ========================================================
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Threading.Tasks;
public class CaptureEditor : Editor
{
[MenuItem("骚操作/截屏")]
public static void Capture() {
string _path = Application.streamingAssetsPath;
if (!Directory.Exists(_path))
Directory.CreateDirectory(_path);
string name = "pciture_" + DateTime.Now.ToString("ss_fff") + ".jpg"; //yyyy_MM_dd_HH_mm_
string path = Path.Combine(_path, name);
ScreenCapture.CaptureScreenshot(path, 3);
System.Func<Task> func = async () =>
{
await Task.Delay(System.TimeSpan.FromSeconds(1));
//需要延迟执行的方法体...
AssetDatabase.Refresh();
FileInfo fileInfo = new FileInfo(path);
fileInfo.Attributes = FileAttributes.Normal;//设置文件属性
Debug.Log("文件路径:" + fileInfo.Directory);
Debug.Log("文件名称:" + fileInfo.Name);
Debug.Log("文件是否只读:" + fileInfo.IsReadOnly);
Debug.Log("文件大小:" + fileInfo.Length);
};
func();
}
}
03-27
3417
02-09
509
10-14
3075