static private void SetPropDataFieldValue(PropData propData, string fieldName, string fieldValueString) { // What extension of PropData is this? Type propDataType = propData.GetType(); // Get the FieldInfo of the requested name from this propData's class. FieldInfo fieldInfo = propDataType.GetField(fieldName); // Get the VALUE of this field from the string! if (fieldInfo == null) { Debug.LogError("We've been provided an unidentified prop field type. " + debug_roomDataLoadingRoomKey + ". PropData: " + propData + ", fieldName: " + fieldName); } else if (fieldInfo.FieldType == typeof(bool)) { fieldInfo.SetValue(propData, bool.Parse(fieldValueString)); } else if (fieldInfo.FieldType == typeof(float)) { fieldInfo.SetValue(propData, TextUtils.ParseFloat(fieldValueString)); } else if (fieldInfo.FieldType == typeof(int)) { fieldInfo.SetValue(propData, TextUtils.ParseInt(fieldValueString)); } else if (fieldInfo.FieldType == typeof(string)) { fieldInfo.SetValue(propData, fieldValueString); } else if (fieldInfo.FieldType == typeof(Rect)) { fieldInfo.SetValue(propData, TextUtils.GetRectFromString(fieldValueString)); } else if (fieldInfo.FieldType == typeof(Vector2)) { fieldInfo.SetValue(propData, TextUtils.GetVector2FromString(fieldValueString)); } else if (fieldInfo.FieldType == typeof(OnOfferData)) { fieldInfo.SetValue(propData, OnOfferData.FromString(fieldValueString)); } else if (fieldInfo.FieldType == typeof(TravelMindData)) { fieldInfo.SetValue(propData, TravelMindData.FromString(fieldValueString)); } else { Debug.LogWarning("Unrecognized field type in Room file: " + debug_roomDataLoadingRoomKey + ". PropData: " + propData + ", fieldName: " + fieldName); } }