using UnityEngine;
using System.Collections;
using System.Windows.Forms;
public class screenshots : MonoBehaviour {
public int I = 1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.A))
{
Screen();
}
}
public void Screen()
{
SaveFileDialog saveLog = new SaveFileDialog();
saveLog.InitialDirectory = "c:\\";
saveLog.Filter = "Image File(*.JPG;*.BMP;*.PNG)|*.JPG;*.BMP;*.PNG|All files(*.*)|*.*";
DialogResult result = saveLog.ShowDialog();
if (result == DialogResult.OK)
{
string path = saveLog.FileName;
UnityEngine.Application.CaptureScreenshot(path, I);
}
}
}
需要导入插件:System.Windows.Forms
本文介绍了一个Unity脚本,该脚本允许在游戏中通过按键触发屏幕截图,并将截图保存为本地文件。截图保存路径和格式可通过对话框选择,支持JPG、BMP和PNG格式。
2万+

被折叠的 条评论
为什么被折叠?



