PlayerPrefs.GetInt 获取整数键值
Returns the value corresponding to key in the preference file if it exists.
如果存在,返回游戏存档文件中key对应的值。
If it doesn't exist, it will return defaultValue.
如果不存在,将返回默认值。
music.SetActive(PlayerPrefs.GetInt("openMusic",1)==1?false:true);
返回false;
PlayerPrefs.SetInt("openMusic",PlayerPrefs.GetInt("openMusic",1)==1?0:1);
music.SetActive(PlayerPrefs.GetInt("openMusic",1)==1?false:true);
返回true;
本文介绍如何在Unity中利用PlayerPrefs.GetInt来获取和设置游戏存档文件中的整数值,实现用户偏好、游戏进度等状态的管理。

被折叠的 条评论
为什么被折叠?



