You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to save gameobject states before quitting, so when i load a scene and spawned several object(destroyWithScene = true), i cached the references to some objects. Then, when i quit(stop playing in editor), i implement the saving code in OnApplicationQuit() on monobehavior "script_1". But the saved data are all zeros(default), and in debuging, the references to spawned objects are all null.
By looking into the source code of NetworkManager, it appears that NetworkManager also implemented OnApplicationQuit() in which ShutdownInternal() is called. So, I changed the script order of my "script_1" or move saving code to Application.wantsToQuit, so that in debuging, My saving code is always called before NetworkManager's OnApplicationQuit(). However, the reults are all the same(valid spawned object reference become null), and the NetworkManager always has shutdown even before NetworkManager's OnApplicationQuit() being called.
This only happens to the dynamically spawned object, the referece to the in-scene object remains valid.
Reproduce Steps
start a host
load a scene and spawn a network prefab
find and cache the reference to a in-scene object and the spawned object
set debug breakpoint and quit
check the references in Application.wantsToQuit
Actual Outcome
Reference to in-scene object is valid, but to spawned object is null in Application.wantsToQuit
Expected Outcome
The references should be valid and object states can be retrieved in Application.wantsToQuit
Screenshots
References when scene loaded and a object spawned
References in Application.wantsToQuit
Environment
OS: [Win10]
Unity Version: [6000.0.26f1]
Netcode Version: [2.1.1]
Additional Context
Add any other context about the problem here. Logs, code snippets would be useful here but please also consider attaching a minimal Unity project that reproduces the issue.
The text was updated successfully, but these errors were encountered:
Description
I want to save gameobject states before quitting, so when i load a scene and spawned several object(destroyWithScene = true), i cached the references to some objects. Then, when i quit(stop playing in editor), i implement the saving code in
OnApplicationQuit()
on monobehavior "script_1". But the saved data are all zeros(default), and in debuging, the references to spawned objects are allnull
.By looking into the source code of
NetworkManager
, it appears thatNetworkManager
also implementedOnApplicationQuit()
in whichShutdownInternal()
is called. So, I changed the script order of my "script_1" or move saving code toApplication.wantsToQuit
, so that in debuging, My saving code is always called before NetworkManager'sOnApplicationQuit()
. However, the reults are all the same(valid spawned object reference become null), and the NetworkManager always has shutdown even before NetworkManager'sOnApplicationQuit()
being called.This only happens to the dynamically spawned object, the referece to the in-scene object remains valid.
Reproduce Steps
Application.wantsToQuit
Actual Outcome
Reference to in-scene object is valid, but to spawned object is
null
inApplication.wantsToQuit
Expected Outcome
The references should be valid and object states can be retrieved in
Application.wantsToQuit
Screenshots
References when scene loaded and a object spawned
References in
Application.wantsToQuit
Environment
Additional Context
Add any other context about the problem here. Logs, code snippets would be useful here but please also consider attaching a minimal Unity project that reproduces the issue.
The text was updated successfully, but these errors were encountered: