Unity3D另类录制视频,每帧都截取屏幕的图片,可以用这种形式来录制
01 | using UnityEngine; |
02 | |
03 | public class ScreenshotMovie : MonoBehaviour |
04 | { |
05 | // The folder we place all screenshots inside. |
06 | // If the folder exists we will append numbers to create an empty folder. |
07 | public string folder = "ScreenshotMovieOutput" ; |
08 | public int frameRate = 25; |
09 | public int sizeMultiplier = 1; |
10 | |
11 | private string realFolder = "" ; |
12 | |
13 | void Start() |
14 | { |
15 | // Set the playback framerate! |
16 | // (real time doesn't influence time anymore) |
17 | Time.captureFramerate = frameRate; |
18 | |
19 | // Find a folder that doesn't exist yet by appending numbers! |
20 | realFolder = folder; |
21 | int count = 1; |
22 | while (System.IO.Directory.Exists(realFolder)) |
23 | { |
24 | realFolder = folder + count; |
25 | count++; |
26 | } |
27 | // Create the folder |
28 | System.IO.Directory.CreateDirectory(realFolder); |
29 | } |
30 | |
31 | void Update() |
32 | { |
33 | // name is "realFolder/shot 0005.png" |
34 | var name = string .Format( "{0}/shot {1:D04}.png" , realFolder, Time.frameCount); |
35 | |
36 | // Capture the screenshot |
37 | Application.CaptureScreenshot(name, sizeMultiplier); |
38 | } |
39 | } |
当然了。其实还有一个插件可以录制视频
http://download.csdn.net/detail/hackdjh/7591423