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でアプリケーションの多重起動を制限する方法

こんにちは、今日はUnityでアプリケーションの多重起動を制限する方法についてまとめていきます。 確認環境 Unity 2018.4.15f1 アプリケーションの多重起動を制限する Edit > Pr …

no image

UnityのManaged Memoryサイズをスクリプトから取得する

こんにちは、今日はUnityのManaged Memoryサイズをスクリプトから取得する方法についてまとめていきます。 Profiler.GetMonoUsedSizeLong() Profiler. …

no image

Unity – Consoleウィンドウにログを表示する方法まとめ

こんにちは、今日はUnityでConsoleウィンドウにログを表示する方法についてまとめていきます。 確認環境 Unity 2018.4.15f1 ログの出力 ログの出力にはUnityEngine.D …

no image

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

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

no image

Unityのオブジェクトが使用しているメモリ量を取得する

こんにちは、今日はUnityのオブジェクトが使用しているメモリ量を取得する方法についてまとめていきます。 確認環境 Unity 2018.4.15f1 Unityオブジェクトの使用メモリ量取得 以下の …