Here is a quick video preview of how UniDDatabase 3.0 will import comma separated values. Let me know if the community enjoys this style of data import. I will post a video for Sql import tomorrow. I’m trying to make it as easy as possible.
I’m finishing the video for SQL import. I will have it up later on today.
Here is a modification I made so I can define the column type in the CSV file itself. Great when having many columns and frequently changing the data in the CSV.
You will still be prompted to set column type, but whatever you select will be replaced with what you set in the CSV file.
Set column types in your CSV like:
columnName=DATATYPE
Here is a list of the data types, full list can be seen inside the CreateNewDropDownMenu function inside ImportCsvToUniDDatabase.cs :
TEXT
INT
FLOAT
Position_Uni
Rotation_Uni
INTEGER_PRIMARY_KEY
BOOL
Modifications to ImportCsvToUniDDatabase.cs
//Find this function
public static void GetFieldTypeOfData(Rect labelTypeOfDataRect,string fieldName,int index)
{
// Start Modification
string[] fieldnameArr = fieldName.Split("="[0]);
fieldName = fieldnameArr[0];
//End modification
//Replaced row currentRowTypeInputLine=CreateNewDropDownMenu();
//with
currentRowTypeInputLine=CreateNewDropDownMenu(fieldnameArr[1]);
Change the function CreateNewDropDownMenu() to accept a string argument
public static string CreateNewDropDownMenu(string defaultTypeSelection )
// and after the line selGridIntColumnDeclaration=EditorGUILayout.Popup(selGridIntColumnDeclaration,listOfColumnDeclaration,EditorStyles.popup);
//add
return defaultTypeSelection;
//And commented out the rest of the function
Finally, in the function AddUserInputToThisWindow() find the line
if(currentRowNameInputLine ==“” || currentRowTypeInputLine ==“” || selGridIntColumnDeclaration==0)
and change it to
if(currentRowNameInputLine =="" || currentRowTypeInputLine =="")
I am sure there are better ways to do this, like skipping the whole proccess if column types are set in CSV. Or prompt only if no column type is set in the file.
This will break if you are attempting to import a file without defining column types in the CSV file
I’m not sure I understand your question. I don’t think it’s a good idea to work with CSV at run time.