Optimized SyncedVarInit

This commit is contained in:
Albin Corén 2018-04-02 19:58:12 +02:00
parent e1cc0b6fbd
commit 0572ab1b13
2 changed files with 3 additions and 0 deletions

View File

@ -211,6 +211,8 @@ namespace MLAPI.MonoBehaviours.Core
private bool[] dirtyFields;
internal void SyncVarInit()
{
if (syncVarInit)
return;
syncVarInit = true;
FieldInfo[] sortedFields = GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Instance).OrderBy(x => x.Name).ToArray();
for (byte i = 0; i < sortedFields.Length; i++)

View File

@ -186,6 +186,7 @@ namespace MLAPI.MonoBehaviours.Core
{
childNetworkedBehaviours[i].NetworkStart();
childNetworkedBehaviours[i].SyncVarInit();
childNetworkedBehaviours[i].networkedStartInvoked = true;
}
}
}