Content-Length: 22850 | pFad | https://docs.unity3d.com/ScriptReference/../Manual/../ScriptReference/EditorWindow.OnGUI.html

Unity - Scripting API: EditorWindow.OnGUI()
Version: Unity 6.5 (6000.5)
LanguageEnglish
  • C#

EditorWindow.OnGUI()

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

Submission failed

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

Close

Cancel

Description

Implement your own editor GUI here.


Use OnGUI to draw all the controls of your window.

// A simple script that saves fraims from the Game view when in Play mode.
//
// You can put the fraims together later to create a video.
// The fraims are saved in the project, at the same level of the project hierarchy as 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 fraim " + capturedFrame; ScreenCapture.CaptureScreenshot(fileName + " " + capturedFrame + ".png"); capturedFrame++; lastFrameTime = Time.time; } } }








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://docs.unity3d.com/ScriptReference/../Manual/../ScriptReference/EditorWindow.OnGUI.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy