@@ -221,7 +221,7 @@ public void NetworkSerialize(NetworkSerializer serializer)
221
221
222
222
public void InitializeInterpolator < TPos , TRot , TScale > ( ) where TPos : IInterpolator < float > , new ( ) where TRot : IInterpolator < Quaternion > , new ( ) where TScale : IInterpolator < float > , new ( )
223
223
{
224
- AllFloatInterpolators . Clear ( ) ;
224
+ m_AllFloatInterpolators . Clear ( ) ;
225
225
if ( Interpolate )
226
226
{
227
227
PositionXInterpolator = new TPos ( ) ;
@@ -243,16 +243,15 @@ public void NetworkSerialize(NetworkSerializer serializer)
243
243
ScaleZInterpolator = new NoInterpolator < float > ( ) ;
244
244
}
245
245
246
- AllFloatInterpolators . Add ( PositionXInterpolator ) ;
247
- AllFloatInterpolators . Add ( PositionYInterpolator ) ;
248
- AllFloatInterpolators . Add ( PositionZInterpolator ) ;
249
- AllFloatInterpolators . Add ( ScaleXInterpolator ) ;
250
- AllFloatInterpolators . Add ( ScaleYInterpolator ) ;
251
- AllFloatInterpolators . Add ( ScaleZInterpolator ) ;
246
+ m_AllFloatInterpolators . Add ( PositionXInterpolator ) ;
247
+ m_AllFloatInterpolators . Add ( PositionYInterpolator ) ;
248
+ m_AllFloatInterpolators . Add ( PositionZInterpolator ) ;
249
+ m_AllFloatInterpolators . Add ( ScaleXInterpolator ) ;
250
+ m_AllFloatInterpolators . Add ( ScaleYInterpolator ) ;
251
+ m_AllFloatInterpolators . Add ( ScaleZInterpolator ) ;
252
252
}
253
253
254
- // public IInterpolator<float>[] all = new[];
255
- private readonly List < IInterpolator < float > > AllFloatInterpolators = new List < IInterpolator < float > > ( 6 ) ;
254
+ private readonly List < IInterpolator < float > > m_AllFloatInterpolators = new List < IInterpolator < float > > ( 6 ) ;
256
255
257
256
private Transform m_Transform ; // cache the transform component to reduce unnecessary bounce between managed and native
258
257
@@ -553,12 +552,12 @@ private void Awake()
553
552
{
554
553
m_Transform = transform ;
555
554
556
- if ( AllFloatInterpolators . Count == 0 )
555
+ if ( m_AllFloatInterpolators . Count == 0 )
557
556
{
558
557
InitializeInterpolator < BufferedLinearInterpolatorFloat , BufferedLinearInterpolatorQuaternion , BufferedLinearInterpolatorFloatForScale > ( ) ;
559
558
}
560
559
561
- foreach ( var interpolator in AllFloatInterpolators )
560
+ foreach ( var interpolator in m_AllFloatInterpolators )
562
561
{
563
562
interpolator . Awake ( ) ;
564
563
interpolator . UseFixedUpdate = UseFixedUpdate ;
@@ -588,7 +587,7 @@ private void Awake()
588
587
589
588
public void Start ( )
590
589
{
591
- foreach ( var interpolator in AllFloatInterpolators )
590
+ foreach ( var interpolator in m_AllFloatInterpolators )
592
591
{
593
592
interpolator . Start ( ) ;
594
593
}
@@ -598,7 +597,7 @@ public void Start()
598
597
599
598
public void OnEnable ( )
600
599
{
601
- foreach ( var interpolator in AllFloatInterpolators )
600
+ foreach ( var interpolator in m_AllFloatInterpolators )
602
601
{
603
602
interpolator . OnEnable ( ) ;
604
603
}
@@ -612,10 +611,11 @@ public override void OnNetworkSpawn()
612
611
{
613
612
ResetCurrentInterpolatedState ( ) ; // useful for late joining
614
613
615
- foreach ( var interpolator in AllFloatInterpolators ) // todo remove GC alloc this creates
614
+ foreach ( var interpolator in m_AllFloatInterpolators )
616
615
{
617
616
interpolator . OnNetworkSpawn ( ) ;
618
617
}
618
+
619
619
// todo cache network manager to remove some of the time it takes to get it
620
620
RotationInterpolator . OnNetworkSpawn ( ) ;
621
621
@@ -627,7 +627,7 @@ private void OnDestroy()
627
627
{
628
628
ReplNetworkState . OnValueChanged -= OnNetworkStateChanged ;
629
629
630
- foreach ( var interpolator in AllFloatInterpolators )
630
+ foreach ( var interpolator in m_AllFloatInterpolators )
631
631
{
632
632
interpolator . OnDestroy ( ) ;
633
633
}
@@ -672,7 +672,7 @@ private void FixedUpdate()
672
672
ApplyNetworkStateFromAuthority ( ReplNetworkState . Value ) ;
673
673
}
674
674
675
- foreach ( var interpolator in AllFloatInterpolators )
675
+ foreach ( var interpolator in m_AllFloatInterpolators )
676
676
{
677
677
interpolator . FixedUpdate ( NetworkManager . ServerTime . FixedDeltaTime ) ;
678
678
}
@@ -696,7 +696,7 @@ private void Update()
696
696
// apply interpolated value
697
697
if ( ! IsServer && ( NetworkManager . Singleton . IsConnectedClient || NetworkManager . Singleton . IsListening ) )
698
698
{
699
- foreach ( var interpolator in AllFloatInterpolators )
699
+ foreach ( var interpolator in m_AllFloatInterpolators )
700
700
{
701
701
interpolator . Update ( Time . deltaTime ) ;
702
702
}
0 commit comments