2 回答

TA貢獻1853條經驗 獲得超18個贊
我嘗試了很多但我沒有得到想要的行為(關于重新授權/應用程序不退出)
即使我改變場景,憑據仍然存在。
如果您想更改帳戶,
重新啟動應用程序,然后在歡迎場景中注銷(facebook 或 google)

TA貢獻1829條經驗 獲得超4個贊
假設它第一次按預期工作,聽起來DontDestroyOnLoad
就是您要找的東西:
切換場景時不會破壞該對象 -> 因此不會Start
再次運行該方法。但是,您還需要將它與singleton
模式結合起來,以確保在返回第一個場景時不會再次添加/運行它:
public class AuthComponent : MonoBehaviour
{
private static AuthComponent singleton;
private void Awake()
{
// Check if already another AuthComponent running
if(singleton)
{
Debug.Log("Already another AuthComponent running");
Destroy(gameObject);
return;
}
// Otherwise store a global reference of this AuthComponent
singleton = this;
// and make it DontDestroyOnLoad
DontDestroyOnLoad(gameObject);
}
...
}
- 2 回答
- 0 關注
- 120 瀏覽
添加回答
舉報