Version: 5.4 beta (switch to 5.3)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorWindow.Update()

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Called multiple times per second on all visible windows.


Save frames from the Game View when on play mode.

no example available in JavaScript
/// C# Example
// Simple script that saves frames from the Game View when on play mode
//
// You can put later the frames togheter and create a video.
// Note: The frames are saved next to the Assets folder.
	
using UnityEngine;
using UnityEditor;
	
public class SimpleRecorder : EditorWindow {
	string fileName = "FileName";
	
	string status = "Idle";
	string recordButton = "Record";
	bool recording = false;
	float lastFrameTime = 0.0f;
	int capturedFrame = 0;
	
	[MenuItem ("Example/Simple Recorder")]
	static void Init () {
		SimpleRecorder window = 
			(SimpleRecorder)EditorWindow.GetWindow(typeof(SimpleRecorder));
	}
	
	void OnGUI () {
		fileName = EditorGUILayout.TextField ("File Name:", fileName);
			
		if(GUILayout.Button(recordButton)) {
			if(recording) { //recording
				status = "Idle...";
				recordButton = "Record";				
				recording = false;
			} else { // idle
				capturedFrame = 0;
				recordButton = "Stop";
				recording = true;
			}
		}
		EditorGUILayout.LabelField ("Status: ", status);
	}
		
	void Update () {
		if (recording) {
			if (EditorApplication.isPlaying && !EditorApplication.isPaused){
				RecordImages();
				Repaint();
			} else
				status = "Waiting for Editor to Play";
		}
	}
		
	void RecordImages() {
		if(lastFrameTime < Time.time + (1/24f)) { // 24fps
			status = "Captured frame " + capturedFrame;
			Application.CaptureScreenshot(fileName + " " + capturedFrame + ".png");
			capturedFrame++;
			lastFrameTime = Time.time;	
		}
	}
}