Application

1、 静态属性

1.1 Path路径

属性名 描述
dataPath 返回项目所在的assert文件夹的相对目录(相对路径)
streamingAssetsPath 返回流数据缓存目录(相对路径)
persistentDataPath 返回持久化目录,同平台不同程序调用此属性,返回值相同
temporaryCachePath 临时数据缓存目录,同平台不同程序调用返回值相同

注:不同平台下,位置不同

Debug.Log("dataPath:" + Application.dataPath);
Debug.Log("streamingAssetsPath:" + Application.streamingAssetsPath);
Debug.Log("persistentDataPath:" + Application.persistentDataPath);
Debug.Log("temporaryCachePath:" + Application.temporaryCachePath);
image.png

1.2 loadedLevel 关卡属性

//返回当前场景的索引值,依据BuildSetting当前scene的索引顺序有关
Debug.Log("loadedLevel:" + Application.loadedLevel);
//返回当前场景的名字
Debug.Log("loadedLevelName:" + Application.loadedLevelName);
//是否有场景正在被加载
Debug.Log("isLoadingLevel:" + Application.isLoadingLevel);
//返回游戏中可被加载的场景数量,依据BuildSetting中勾选的数量有关
Debug.Log("levelCount:" + Application.levelCount);
//返回当前游戏的运行平台
Debug.Log("platform:" + Application.platform);
//当前游戏是否正在运行
Debug.Log("isPlaying:" + Application.isPlaying);
//当前游戏是否处于Unity编辑模式
Debug.Log("isEditor:" + Application.isEditor);
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容