mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
QSBNetworkBehaviour: DontDestroyOnLoad
This commit is contained in:
parent
d0add050d0
commit
c5cae127bc
@ -124,6 +124,7 @@ public abstract class SyncBase : QSBNetworkTransform
|
||||
|
||||
public override void OnStartClient()
|
||||
{
|
||||
base.OnStartClient();
|
||||
if (IsPlayerObject)
|
||||
{
|
||||
// get player objects spawned before this object (or is this one)
|
||||
@ -133,7 +134,6 @@ public abstract class SyncBase : QSBNetworkTransform
|
||||
.MaxBy(x => x.PlayerId);
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@ public abstract class QSBNetworkBehaviour : NetworkBehaviour
|
||||
private double _lastSendTime;
|
||||
private byte[] _lastKnownData;
|
||||
|
||||
public override void OnStartClient() => DontDestroyOnLoad(gameObject);
|
||||
|
||||
/// <summary>
|
||||
/// checked before serializing
|
||||
/// </summary>
|
||||
|
@ -14,16 +14,11 @@ public class WorldObjectVariableSyncer<TSyncType, TWorldObjectType> : BaseVariab
|
||||
public override void OnStartClient()
|
||||
{
|
||||
VariableSyncStorage._instances.Add(this);
|
||||
DontDestroyOnLoad(this);
|
||||
base.OnStartClient();
|
||||
}
|
||||
|
||||
public override void OnStopClient()
|
||||
{
|
||||
VariableSyncStorage._instances.Remove(this);
|
||||
// DontDestroyOnLoad moves GOs to the scene "DontDestroyOnLoad"
|
||||
// so to undo it we can just move them back
|
||||
SceneManager.MoveGameObjectToScene(gameObject, SceneManager.GetActiveScene());
|
||||
base.OnStopClient();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user