public void MergeFrom(ref object value, MonoStream ms) { if (value == null) { value = IL.Help.Create(type); } WRStream stream = ms.Stream; while (stream.ReadSize != 0) { var fieldName = stream.ReadString(); var length = stream.ReadLength(); if (length == 0) { } else { int endPos = stream.WritePos; stream.WritePos = stream.ReadPos + length; try { var fieldInfo = fieldInfos.Find((field) => { return(fieldName == field.Name); }); if (fieldInfo == null) { stream.ReadPos += length; } else { object cv = fieldInfo.GetValue(value); //bool isSet = false; //if (cv == null) //{ // cv = IL.Help.Create(fieldInfo.FieldType); // //isSet = true; //} MonoSerialize.GetByType(fieldInfo).MergeFrom(ref cv, ms); //if (isSet || !cv.GetType().IsClass || cv.GetType().FullName == "System.String") { fieldInfo.SetValue(value, cv); } } } catch (System.Exception ex) { UnityEngine.Debug.LogException(ex); } finally { #if UNITY_EDITOR if (stream.ReadSize != 0) { UnityEngine.Debug.LogErrorFormat("type:{0} fieldName:{1} length:{2}", type.Name, fieldName, length); } #endif stream.WritePos = endPos; } } } }