Fixed an issue causing new objects to not have their SyncedVars inited
This commit is contained in:
parent
6f1f035136
commit
e1cc0b6fbd
@ -206,10 +206,12 @@ namespace MLAPI.MonoBehaviours.Core
|
|||||||
internal List<FieldType> syncedFieldTypes = new List<FieldType>();
|
internal List<FieldType> syncedFieldTypes = new List<FieldType>();
|
||||||
private List<object> syncedFieldValues = new List<object>();
|
private List<object> syncedFieldValues = new List<object>();
|
||||||
private List<MethodInfo> syncedVarHooks = new List<MethodInfo>();
|
private List<MethodInfo> syncedVarHooks = new List<MethodInfo>();
|
||||||
|
private bool syncVarInit = false;
|
||||||
//A dirty field is a field that's not synced.
|
//A dirty field is a field that's not synced.
|
||||||
private bool[] dirtyFields;
|
private bool[] dirtyFields;
|
||||||
internal void SyncVarInit()
|
internal void SyncVarInit()
|
||||||
{
|
{
|
||||||
|
syncVarInit = true;
|
||||||
FieldInfo[] sortedFields = GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.Instance).OrderBy(x => x.Name).ToArray();
|
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++)
|
for (byte i = 0; i < sortedFields.Length; i++)
|
||||||
{
|
{
|
||||||
@ -453,6 +455,8 @@ namespace MLAPI.MonoBehaviours.Core
|
|||||||
private float lastSyncTime = 0f;
|
private float lastSyncTime = 0f;
|
||||||
internal void SyncVarUpdate()
|
internal void SyncVarUpdate()
|
||||||
{
|
{
|
||||||
|
if (!syncVarInit)
|
||||||
|
SyncVarInit();
|
||||||
SetDirtyness();
|
SetDirtyness();
|
||||||
if(Time.time - lastSyncTime >= SyncVarSyncDelay)
|
if(Time.time - lastSyncTime >= SyncVarSyncDelay)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user