您的位置:首页 > 移动开发 > Unity3D

Unity3d 截取窗体图片并保存

2013-02-22 11:38 246 查看
// The folder we place all screenshots inside.

// If the folder exists we will append numbers to create an empty folder.

var folder = "ScreenshotFolder";

var frameRate = 25;   //每秒25帧。

private var realFolder = "";

function Start () {

    // Set the playback framerate!

    // (real time doesn't influence time anymore)

    Time.captureFramerate = frameRate;

    // Find a folder that doesn't exist yet by appending numbers!

    realFolder = folder;

    count = 1;

    while (System.IO.Directory.Exists(realFolder)) {

        realFolder = folder + count;

        count++;

    }

    // Create the folder

    System.IO.Directory.CreateDirectory(realFolder);

}

function Update () {

    // name is "realFolder/0005 shot.png"

    var name = String.Format("{0}/{1:D04} shot.png", realFolder, Time.frameCount );

    // Capture the screenshot

    Application.CaptureScreenshot (name);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: