@@ -231,6 +231,8 @@ internal void SendNetworkDestroy()
231231 SceneNetworkSystem . Instance . Broadcast ( msg ) ;
232232 }
233233
234+ private static readonly GameObject . SerializeOptions _refreshSerializeOptions = new ( ) { SingleNetworkObject = true } ;
235+
234236 internal ObjectRefreshMsg GetRefreshMessage ( )
235237 {
236238 var system = SceneNetworkSystem . Instance ;
@@ -239,23 +241,20 @@ internal ObjectRefreshMsg GetRefreshMessage()
239241
240242 var snapshot = ( ( IDeltaSnapshot ) this ) . WriteSnapshotState ( ) ;
241243
242- var o = new GameObject . SerializeOptions
243- {
244- SingleNetworkObject = true
245- } ;
246-
247244 var msg = new ObjectRefreshMsg
248245 {
249246 Guid = GameObject . Id ,
250247 Parent = GameObject . Parent . Id ,
251- JsonData = GameObject . Serialize ( o ) . ToJsonString ( ) ,
248+ JsonData = GameObject . Serialize ( _refreshSerializeOptions ) . ToJsonString ( ) ,
252249 TableData = WriteReliableData ( ) ,
253250 Snapshot = system . DeltaSnapshots . GetFullSnapshotData ( snapshot )
254251 } ;
255252
256253 return msg ;
257254 }
258255
256+ private static readonly GameObject . SerializeOptions _refreshDescendantSerializeOptions = new ( ) { IgnoreChildren = true } ;
257+
259258 internal void SendNetworkRefresh ( GameObject go )
260259 {
261260 var system = SceneNetworkSystem . Instance ;
@@ -288,17 +287,11 @@ internal void SendNetworkRefresh( GameObject go )
288287 {
289288 var snapshot = ( ( IDeltaSnapshot ) this ) . WriteSnapshotState ( ) ;
290289
291- // Only this one object...
292- var options = new GameObject . SerializeOptions
293- {
294- IgnoreChildren = true
295- } ;
296-
297290 var msg = new ObjectRefreshDescendantMsg
298291 {
299292 GameObjectId = GameObject . Id ,
300293 ParentId = go . Parent . Id ,
301- JsonData = go . Serialize ( options ) . ToJsonString ( ) ,
294+ JsonData = go . Serialize ( _refreshDescendantSerializeOptions ) . ToJsonString ( ) ,
302295 TableData = WriteReliableData ( ) ,
303296 Snapshot = system . DeltaSnapshots . GetFullSnapshotData ( snapshot )
304297 } ;
@@ -579,16 +572,16 @@ internal void TransmitStateChanged()
579572 LocalSnapshotState . ClearConnections ( ) ;
580573 }
581574
575+ private static readonly GameObject . SerializeOptions _createSerializeOptions = new ( ) { SingleNetworkObject = true } ;
576+
582577 internal ObjectCreateMsg GetCreateMessage ( )
583578 {
584- var o = new GameObject . SerializeOptions { SingleNetworkObject = true } ;
585-
586579 if ( GameObject . Parent is null )
587580 {
588581 throw new ( $ "GameObject { GameObject . Id } ({ GameObject . Name } has invalid parent" ) ;
589582 }
590583
591- var jsonData = GameObject . Serialize ( o ) ;
584+ var jsonData = GameObject . Serialize ( _createSerializeOptions ) ;
592585 if ( jsonData is null )
593586 {
594587 throw new ( $ "Unable to serialize { GameObject . Id } ({ GameObject . Name } )" ) ;
0 commit comments