Skip to content

API V2版本的微信的PlayerPrefs怎么用,看Demo示例里还是Unity的PlayerPrefs #960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
YaowenCode opened this issue Feb 22, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@YaowenCode
Copy link

YaowenCode commented Feb 22, 2025

描述Bug

如题,API V2的Demo示例里仍然是用的Unity的PlayerPrefs:https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Demo/API_V2/Assets/API/PlayerPrefs/PlayerPrefsManager.cs 真没明白要怎么使用。

微信开放社区里之前有个问题里有官方人员提到不要使用Unity PlayerPrefs,要替换为微信SDK提供的PlayerPrefs,那么API V2里要怎么替换为微信SDK提供的PlayerPrefs?

运行环境

Windows 11 / Unity 2022.3.50
@YaowenCode YaowenCode added the bug Something isn't working label Feb 22, 2025
@xiashanabc
Copy link

微信SDK重写了PlayerPrefs的,你直接在项目中这样调用就可以:PlayerPrefs.SetString。但要用全局命名空间的,如果是带UnityEngine命名空间的不行

@YaowenCode
Copy link
Author

微信SDK重写了PlayerPrefs的,你直接在项目中这样调用就可以:PlayerPrefs.SetString。但要用全局命名空间的,如果是带UnityEngine命名空间的不行

嗯,用了全局命名空间起作用,至少SetInt和GetInt没问题,SetString和GetString有问题。

不过同时在微信开发工具还有以下提示:

Image

IndexedDB is not available. Data will not persist in cache and PlayerPrefs will not be saved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants