- Home /
Question by
Goat-Boy · Apr 12, 2018 at 09:19 PM ·
assetsjsonloading file
What type is a JSON file for using LoadAssetAtPath?
I'm trying to open a JSON file via a script using AssetDatabase.OpenAsset. But in order to open it, I first have to load it using AssetDatabase.LoadAssetAtPath. If this was a C# script that I was loading, I'd use the type MonoScript, but that isn't working for my JSON file. What type do I need to use?
var lScript = (MonoScript)AssetDatabase.LoadAssetAtPath("Assets/StreamingAssets/TextDatabase.json", typeof(MonoScript));
if (lScript != null)
{
Debug.Log("Found script");
AssetDatabase.OpenAsset(lScript, 1);
}
Additonaly, I need to search that JSON file for a specific string, and then open it at the line where that string is, so if you know how to do that, I'd greatly appricaite you sharing, thanks.
Comment
Best Answer
Answer by Goat-Boy · Apr 13, 2018 at 02:23 AM
The type is TextAsset.
My other problem here is that the JSON file is in StreamingAssets. Something about the file being there messed with it so it couldn't find it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612160628im_/https://answers.unity.com/themes/thub/images/avi.jpg)