*.tsv file as TextAssets ?

Reading the documentation and *.tsv file type isn’t yet recognized as TestAssets type.

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?

Thank you :slight_smile:

Just use a different extension.

–Eric

Yes thank you Eric.

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?..

Kindly,

Thomas.

3219718--246760--Untitled-1.png

you can make your own in about <1minute also
File.ReadAllLines()

from unity it would take about 2-4 years *estimate based on other feature changes :slight_smile:

And to tell the truth, I already do not use Unity’s class to read the file, I went with C# if someone goes into the same issue :

string assetPath = Application.dataPath + "/" + AssetDatabase.GetAssetPath (Selection.activeObject).Replace ("Assets/", "");
string [] tmp = System.IO.File.ReadAllLines(@"" + assetPath);
1 Like

ahah yes as mentionned right now to the top :smile:

bouah! lol

also should be probably possible to do custom asset importer, that converts (or renames) those files into unity text assets…

TSV is still not supported. (

1 Like

Try this :slight_smile:

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();
    }
}
6 Likes

PERFECT. Thanks, this is exactly what I needed.

Thanks :slight_smile:

Updated for Unity 2020(.3)

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();
    }
}
7 Likes

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