コード例 #1
0
    public void setSyncedField(string fieldName, object fieldValue)
    {
        FieldInfo field = component.GetType().UnderlyingSystemType.GetField(fieldName);

        QTUtils.setCorrectSyncedObject(this, field, fieldValue);

        QTDebugger.instance.debug(QTDebugger.debugType.NETWORK, "Syncing value(" + fieldName + "=" + fieldValue + ")");
    }
コード例 #2
0
    public void syncFields()
    {
        foreach (FieldInfo fi in component.GetType().UnderlyingSystemType.GetFields().Where(fi => Attribute.IsDefined(fi, typeof(QTSynced))))
        {
            object latestValue = fi.GetValue(component);

            if (lastFields.ContainsKey(fi.Name) == false)
            {
                lastFields.Add(fi.Name, latestValue);

                onSyncedFieldChanged(fi.Name, lastFields[fi.Name]);
            }
            else if (QTUtils.hasSyncedFieldChanged(this, fi, lastFields[fi.Name]))
            {
                lastFields[fi.Name] = latestValue;

                onSyncedFieldChanged(fi.Name, lastFields[fi.Name]);
            }
        }
    }