UnityEngine.DefautAsset as TextAsset

I’m trying to load a CSV file using a relative reference as a TextAsset.

dataBase = AssetDatabase.LoadMainAssetAtPath("Assets/Game Specific Assets/GameData/weapons.csv") as TextAsset;

But I get an invalid cast exception. I can find no reference to UnityEngine.DefaultAsset anywhere and I’m not sure what I’m doing wrong.

What's the type of dataBase? What specific error message are you getting?

Its a TextAsset, but I found a good workaround here: http://answers.unity3d.com/questions/193735/automatic-csv-to-txt-conversion-solved.html

Good to know. Thanks for the solution link.

1 Answer

1

Its a TextAsset, but I found a good work around here: