- Home /
Inspector support for .json TextAsset
I want to use .json files to define certain attributes for objects. For instance, "spider.json" or "wolf.json" files.
I want to be able to assign those files to specific Game Objects through the Unity editor and to be able to choose a different one through the Editor itself.
Basically, I would have a class such as:
public class Unit: MonoBehaviour {
public TextAsset jsonFile;
}
Then, in the Editor itself, I would in principle be able to choose a text asset to assign to jsonFile.
However, .json files don't seem to appear in the inspector. I have renamed it to .txt and those do appear, but I don't really like the idea of having to use .txt for .json files.
According to the docs (http://docs.unity3d.com/Manual/class-TextAsset.html) both .txt and .json files (among others) are supported as TextAssets.
Am I doing something wrong; is that the expected behaviour of the inspector?
Would there be any other way to give designers the ability to choose a file (such as a .json, in this case) through the Editor, to link it to an object?
Your answer
Follow this Question
Related Questions
ReImport in c# of GameObjects only for Scene Objects, not assets? 1 Answer
Is there any way to hide properties to JsonUtility.ToJson but show them in inspector? 1 Answer
Unity editor and inspector header 0 Answers
[Solved]Why doesn't my ScriptableObject based asset save using a custom inspector ? 1 Answer
Why doesn't my ScriptableObject save using a custom EditorWindow? 3 Answers