Version: 2021.1
public static bool isPlaying ;

描述

在任何类型的已构建播放器中调用时,或者在播放模式的编辑器中调用时,返回 true(只读)。

在已构建播放器中,此方法将始终返回 true。

在编辑器中,如果编辑器处于播放模式,将返回 true。

Note: In the Editor for ScriptableObject assets, this property will return false in OnEnable. After reloading the domain, when reloading assemblies, Unity invokes OnEnable on all ScriptableObject instances. This happens before isPlaying is set to true.

另请参阅:Application.IsPlayingExecuteAlways

using UnityEngine;

class Example : MonoBehaviour { void Start() { if (Application.isPlaying) { print("In player or playmode"); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961