[SOLVED] Unity WalletConnect destroyed error after moving scene with QR login

I have WalletConnect destroyed error after moving scene with QR login.

The process is like below.

-> QR login at scene1 (success)
-> move scene 2
-> move scene1
-> try to QR login again (fail)
-> then encounter MissingReferenceException: The object of type ‘WalletConnect’ has been destroyed but you are still trying to access it.

Every scene I can find WalletConnect in DontDestroyInLoad.
But why I encounter those error.

You can try to also post in Discord in a channel specific to unity

1 Like

Hi!
I’m not sure, but I think it’s because the WalletConnect is set through the Inspector. Try changing the code in WalletConnectQRImage.cs

Change it

public WalletConnect walletConnect;

to this

private WalletConnect walletConnect => WalletConnect.Instance;
1 Like

I found the solution.
I’m using Authenticatonkit and WalletConnect include that link.
And when return to the 1st scene, the link is broken because DontDestroyOnLoad includes Walletconnect in 2nd scene.

[solution]
Before returning back to the 1st scene, I destroyed that and the link isn’t broken.
like below…

GameObject walletConnectObject = GameObject.Find(“WalletConnect”);
DestroyImmediate(walletConnectObject);

Welcome any comments!

1 Like