/// <summary> /// 按照Field类型设定FieldInfo的数值 /// </summary> // 按照物体类型将字符串转到所需类型 private static object ConvertObject(string rawValue, System.Type type) { if (type == typeof(int)) { return(int.Parse(rawValue)); } else if (type == typeof(float)) { return(float.Parse(rawValue)); } else if (type == typeof(string)) { return(rawValue); } else if (type == typeof(SerilizableVector2)) { return(SerilizableVector2.Parse(rawValue)); } else if (type == typeof(SerilizableVector3)) { return(SerilizableVector3.Parse(rawValue)); } else if (type == typeof(SerilizableQuaternion)) { return(SerilizableQuaternion.Parse(rawValue)); } else { throw new System.NotImplementedException(string.Format("未处理类型{0}的读取方式", type)); } }
public static SerilizableVector2 Parse(string text) { var raw = text.Split(','); var result = new SerilizableVector2(); result.x = float.Parse(raw[0]); result.y = float.Parse(raw[1]); return(result); }