public Vector3 GetVector3(string key) { if (this.ContainsKey(key)) { return(ParseTool.String2Vector3(this[key])); } if (data.m_defaultValue.ContainsKey(key)) { return(ParseTool.String2Vector3(data.m_defaultValue[key])); } throw new Exception("Don't Exist Value or DefaultValue by ->" + key + "<- TableName is : ->" + data.m_tableName + "<- singleDataName : ->" + m_SingleDataName + "<-"); // throw }
public Vector3 GetVector3(string key) { if (this.ContainsKey(key)) { return(ParseTool.String2Vector3(this[key])); } if (data.m_defaultValue.ContainsKey(key)) { return(ParseTool.String2Vector3(data.m_defaultValue[key])); } throw new Exception("Don't Exist Value or DefaultValue by " + key); // throw }
public static object TableString2ObjectValue(string v, FieldType fieldValueType, string enumType) { object t = null; switch (fieldValueType) { case FieldType.String: t = v; break; case FieldType.Bool: t = bool.Parse(v); break; case FieldType.Int: t = int.Parse(v); break; case FieldType.Float: t = float.Parse(v); break; case FieldType.Vector2: t = ParseTool.String2Vector2(v); break; case FieldType.Vector3: t = ParseTool.String2Vector3(v); break; case FieldType.Color: t = ParseTool.String2Color(v); break; case FieldType.Enum: Type type = ConfigFieldValueType2Type(fieldValueType, enumType); t = Enum.Parse(type, v); break; case FieldType.StringArray: t = ParseTool.String2StringArray(v); break; case FieldType.IntArray: t = ParseTool.String2IntArray(v); break; case FieldType.FloatArray: t = ParseTool.String2FloatArray(v); break; case FieldType.BoolArray: t = ParseTool.String2BoolArray(v); break; case FieldType.Vector2Array: t = ParseTool.String2Vector2(v); break; case FieldType.Vector3Array: t = ParseTool.String2Vector3Array(v); break; default: break; } return(t); }
public Vector3 GetVector3() { return(ParseTool.String2Vector3(m_content)); }
/// <summary> /// 原始表格字符串类型转换为具体的数据 /// </summary> /// <param name="v"></param> /// <param name="fieldValueType"></param> /// <param name="enumType"></param> /// <returns></returns> public static object TableString2ObjectValue(string v, FieldType fieldValueType, string enumType, List <char> m_ArraySplitFormat) { object t = null; switch (fieldValueType) { case FieldType.String: t = v; break; case FieldType.Bool: t = bool.Parse(v); break; case FieldType.Int: t = int.Parse(v); break; case FieldType.Float: t = float.Parse(v); break; case FieldType.Vector2: t = ParseTool.String2Vector2(v); break; case FieldType.Vector3: t = ParseTool.String2Vector3(v); break; case FieldType.Color: t = ParseTool.String2Color(v); break; case FieldType.Enum: Type type = ConfigFieldValueType2Type(fieldValueType, enumType, m_ArraySplitFormat); try { t = Enum.Parse(type, v); } catch (Exception e) { t = Enum.GetValues(type).GetValue(0); // Debug.LogError("fieldValueType:" + fieldValueType + " enumType:" + enumType + " type:" + type + " v:" + v + "\n"+e); throw e; } break; case FieldType.StringArray: //t = ParseTool.String2StringArray(v); //break; case FieldType.IntArray: //t = ParseTool.String2IntArray(v); //break; case FieldType.FloatArray: //t = ParseTool.String2FloatArray(v); //break; case FieldType.BoolArray: //t = ParseTool.String2BoolArray(v); //break; case FieldType.Vector2Array: //t = ParseTool.String2Vector2(v); //break; case FieldType.Vector3Array: //t = ParseTool.String2Vector3Array(v); t = ParseTool.String2Array(fieldValueType, v, m_ArraySplitFormat.ToArray()); break; default: break; } return(t); }