public static object InnerStructFromString(Type type, string value) { if (type == typeof(ColorBlock)) { return(ParamAnalysisTool.StringToColorBlock(value)); } if (type == typeof(Color)) { return(ParamAnalysisTool.StringToColor(value)); } else if (type == typeof(Vector2)) { return(ParamAnalysisTool.StringToVector2(value)); } else if (type == typeof(Vector2Int)) { return(ParamAnalysisTool.StringToVector2Int(value)); } else if (type == typeof(Vector3)) { return(ParamAnalysisTool.StringToVector3(value)); } else if (type == typeof(Vector3Int)) { return(ParamAnalysisTool.StringToVector3Int(value)); } else if (type == typeof(Vector4)) { return(ParamAnalysisTool.StringToVector4(value)); } else if (type == typeof(Rect)) { return(ParamAnalysisTool.StringToRect(value)); } Debug.LogWarningFormat("未成功解析类型为{0}的信息", type.FullName); return(null); }
public static object GetValueFromTypeString(Type type, string value, AssemblerStateMechine mechine) { if (type == typeof(SpriteState)) { return(ParamAnalysisTool.StringToSpriteState(value, mechine.spriteFolderPath)); } else if (type == typeof(ColorBlock)) { return(ParamAnalysisTool.StringToColorBlock(value)); } else if (type == typeof(Sprite)) { return(ParamAnalysisTool.StringToObject <Sprite>(value, mechine.spriteFolderPath)); } else if (type == typeof(Font)) { return(ParamAnalysisTool.StringToObject <Font>(value, mechine.fontFolderPath)); } else if (type == typeof(Material)) { return(ParamAnalysisTool.StringToObject <Material>(value, mechine.materialFolderPath)); } else if (type == typeof(Texture)) { return(ParamAnalysisTool.StringToObject <Texture>(value, mechine.textureFolderPath)); } else if (type == typeof(Texture2D)) { return(ParamAnalysisTool.StringToObject <Texture2D>(value, mechine.textureFolderPath)); } else if (type == typeof(Color)) { return(ParamAnalysisTool.StringToColor(value)); } else if (type == typeof(Vector2)) { return(ParamAnalysisTool.StringToVector2(value)); } else if (type == typeof(Vector3)) { return(ParamAnalysisTool.StringToVector3(value)); } else if (type == typeof(Vector4)) { return(ParamAnalysisTool.StringToVector4(value)); } else if (type == typeof(Rect)) { return(ParamAnalysisTool.StringToRect(value)); } else if (typeof(IConvertible).IsAssignableFrom(type)) { if (type.IsSubclassOf(typeof(System.Enum))) { return(Enum.Parse(type, value)); } else { try { return(Convert.ChangeType(value, type)); } catch (Exception e) { Debug.LogWarning(e.Message + ":" + value); } } } Debug.LogWarningFormat("未成功解析类型为{0}的信息", type.FullName); return(null); }