3テラバイト

プログラム関連備忘録サイト。主にゲーム。

Unity

Unityでスクリプトからゲームの再生や停止を行う

投稿日:

こんにちは、今日はUnityでスクリプトからゲームの再生や停止を行う方法についてまとめていきます。

エディタの再生、一時停止、停止ボタンの処理をスクリプトから行うことができます。
これらの処理はエディタ上でのみ有効です。

確認環境

Unity 2018.4.15f1

ゲームの再生

UnityEditor.EditorApplication.isPlaying = true;

ゲームの停止

UnityEditor.EditorApplication.isPlaying = false;

ゲームの一時停止

UnityEditor.EditorApplication.isPaused = true;

ゲームの再開

UnityEditor.EditorApplication.isPaused = false;

リンク

EditorApplication-isPlaying – Unity スクリプトリファレンス
https://docs.unity3d.com/ja/2018.4/ScriptReference/EditorApplication-isPlaying.html

EditorApplication-isPaused – Unity スクリプトリファレンス
https://docs.unity3d.com/ja/2019.4/ScriptReference/EditorApplication-isPaused.html

-Unity


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


reCaptcha の認証期間が終了しました。ページを再読み込みしてください。

関連記事

no image

Unityで引数に最も近い整数を返す関数Mathf.Round

確認環境 Unity 2018.4.15f1 使い方 float num = Mathf.Round(1.2f); Debug.Log(num); float型の数値を渡すと、その値に最も近い整数値を …

no image

UnityのGUI.Labelのサイズを取得する

こんにちは、今日はUnityのGUI.Labelのサイズを取得する方法についてまとめていきます。 確認環境 Unity 2018.4.15f1 GUI.Labelのサイズを取得する string st …

no image

Unity – プラットフォームやエディタ等の実行環境ごとに処理を切り分ける方法

こんにちは、今日はUnityでWindows、Mac、Android、iOS等の各プラットフォームごとや、エディタ上で実行されている場合にスクリプトの処理を切り分ける方法についてまとめていきます。 確 …

no image

Unityで数値を指定範囲に収める

確認環境 Unity 2018.4.15f1 数値を指定範囲に収める Clamp public static int Clamp(int value, int min, int max); publi …

no image

Unityで古いプロジェクトを開いた際に表示されるAPI Update Requiredダイアログ

確認環境 Unity 2019.4.28f1 表示内容 This project contains scripts and/or assemblies that use obsolete APIs.I …