Since *.csv (comma-separated values) is a commin type of file saved from Excel, GoogleSheet, etc…
*.tsv ( tab-separated values) is I think used more often since the “,” always leads to confusion when parsing float value.
Also UnityEditor doesn’t even recognize it as ASCII file and doesn’t even print the content from the Inspector tab.
Is that something making sense? or…
Where could I fill a form as request as new feature to get it in up coming release?
Should I also make a meeting with my team to justify why Unity cannot read those file type and they have to rename it their self each time they use my interface?
I am asking this because I think it should also be part of those file list as smart it is already :
.txt
.html
.htm
.xml
.bytes
.json
.csv
.yaml
.fnt
Do not get me wrong, but it shouldn’t take long to make the integration, isn’t it?..
Make sure this is inside any folder called “Editor” within your Assets folder, and you’ll be able to load up a .tsv file as a TextAsset, just like .txt files
using System.IO;
using UnityEditor;
using UnityEditor.Experimental.AssetImporters;
using UnityEngine;
[ScriptedImporter(1, "tsv")]
public class TSVImporter : ScriptedImporter
{
public override void OnImportAsset(AssetImportContext ctx)
{
TextAsset textAsset = new TextAsset(File.ReadAllText(ctx.assetPath));
ctx.AddObjectToAsset(Path.GetFileNameWithoutExtension(ctx.assetPath), textAsset);
ctx.SetMainObject(textAsset);
AssetDatabase.SaveAssets();
}
}
using System.IO;
using UnityEditor;
using UnityEngine;
[UnityEditor.AssetImporters.ScriptedImporter(1, "tsv")]
public class TSVImporter : UnityEditor.AssetImporters.ScriptedImporter
{
public override void OnImportAsset(UnityEditor.AssetImporters.AssetImportContext ctx)
{
TextAsset textAsset = new TextAsset(File.ReadAllText(ctx.assetPath));
ctx.AddObjectToAsset(Path.GetFileNameWithoutExtension(ctx.assetPath), textAsset);
ctx.SetMainObject(textAsset);
AssetDatabase.SaveAssets();
}
}
This piece of code right here is INCREDIBLE, what a lifesaver! I’m making a quiz game and used a spreadsheet to organize all the data but some of the Questions are sentences with commas in the middle, so I couldn’t use csv, and that one script which made .tsv’s work saved the project! thank you so much other Firestorm and akingdom! XD