private FieldGUIInfo GenerateAttribute(FieldInfo info) { FieldGUIInfo attribute = Attribute.GetCustomAttribute(info, typeof(FieldGUIInfo)) as FieldGUIInfo; if (attribute == null) { attribute = new FieldGUIInfo(); attribute.Title = FieldGUI.ToTitleCase(info.Name); return(attribute); } if (attribute.Title == null) { attribute.Title = FieldGUI.ToTitleCase(info.Name); } return(attribute); }
private static FieldGUIInfo GetFieldGUIInfo(FieldInfo fieldInfo) { FieldGUIInfo guiInfo = Attribute.GetCustomAttribute (fieldInfo, typeof(FieldGUIInfo)) as FieldGUIInfo; if (guiInfo == null) { guiInfo = new FieldGUIInfo(); guiInfo.Title = FieldGUI.GetTitleCase(fieldInfo.Name); return(guiInfo); } if (guiInfo.Title == null) { guiInfo.Title = FieldGUI.GetTitleCase(fieldInfo.Name); } return(guiInfo); }
private static FieldGUIBase GenerateGUI(object data, FieldInfo fieldInfo, FieldGUIInfo guiInfo) { FieldGUI.GetFieldGUIType(data, fieldInfo, out Type type, out bool typeIsIList); if (data == null || typeIsIList) { return(new FieldGUIs.UnSupportedGUI(data, fieldInfo, guiInfo)); } if (type == typeof(bool)) { return(new FieldGUIs.BoolGUI(data, fieldInfo, guiInfo)); } if (type == typeof(int)) { return(new FieldGUIs.IntGUI(data, fieldInfo, guiInfo)); } if (type == typeof(float)) { return(new FieldGUIs.FloatGUI(data, fieldInfo, guiInfo)); } if (type == typeof(Vector2)) { return(new FieldGUIs.Vector2GUI(data, fieldInfo, guiInfo)); } if (type == typeof(Vector3)) { return(new FieldGUIs.Vector3GUI(data, fieldInfo, guiInfo)); } if (type == typeof(Vector4)) { return(new FieldGUIs.Vector4GUI(data, fieldInfo, guiInfo)); } if (type == typeof(Vector2Int)) { return(new FieldGUIs.Vector2IntGUI(data, fieldInfo, guiInfo)); } if (type == typeof(Vector3Int)) { return(new FieldGUIs.Vector3IntGUI(data, fieldInfo, guiInfo)); } if (type == typeof(Color)) { return(new FieldGUIs.ColorGUI(data, fieldInfo, guiInfo)); } if (type == typeof(Matrix4x4)) { return(new FieldGUIs.Matrix4x4GUI(data, fieldInfo, guiInfo)); } if (type == typeof(bool)) { return(new FieldGUIs.BoolGUI(data, fieldInfo, guiInfo)); } if (type == typeof(string)) { if (guiInfo.IPv4) { return(new FieldGUIs.IPv4GUI(data, fieldInfo, guiInfo)); } else { return(new FieldGUIs.StringGUI(data, fieldInfo, guiInfo)); } } if (type.IsEnum) { return((FieldGUIBase)Activator.CreateInstance (typeof(FieldGUIs.EnumGUI <>).MakeGenericType(fieldInfo.FieldType), data, fieldInfo, guiInfo)); } //if (type.IsValueType) // Means any other struct. //{ // return new FieldGUIs.UnSupportedGUI(data, fieldInfo, guiInfo); //} return(new FieldGUIs.FieldGUI(data, fieldInfo, guiInfo)); }