Hello everyone,
I’m in quite a pickle here as can’t find any answers to match my situation.
In my game (UI based) i have 3 scenes:
SCENE 1:
Is just generic loading page which connects to the backend and moves to next scene when connection has been established.
SCENE 2:
Is a login page. When the connection to the backend is established, an event is triggered which checks if the user is currently logged in by checking the presence of an AES encrypted file and if it exists it decrypts it and passes the login details or auth token to an authentication method which authenticates the user to the backend.
If user is already logged in (encrypted file exists) they won’t even see SCENE 2…unless the credentials have changed in the meantime, of course. The above happens quickly and when complete it loads SCENE 3.
If the user is not logged in (encrypted file doesn’t exist), then they are prompted for username and password and the LOGIN button creates the file, authenticates the user to the backend and loads SCENE 3.
SCENE 3:
This, as you suspected is the main scene. Stuff happens here with events sent to the backend, handling of responses, UI changes and the works. Normal stuff…
Now…here’s the catch. There’s a LOGOUT button in this scene which when pressed it does the following (in this order):
- Deletes the encrypted file holding the current credentials
- Resets the connection to the backend
- Goes back to SCENE 2
(nothing else)
This works as intended. The user then logs in and SCENE 3 is loaded with the current user’s stats pulled from the backend. But when I interact with any object in the scene I get the below error.
If I close the application and reopen it it goes through the normal process as above and everything works ok. So it’s got to be because I went from SCENE 3 to SCENE 2…then back to SCENE 3.
I can’t figure out what to do to discard SCENE 3 when player logs out and then reload a fresh SCENE 3 when they log in (in the same session).
There are no DoNotDestroyOnLoad objects in scene 3.
I hope the above makes sense.
Many thanks for your time and assistance.
Alex