I am making a multiple choice quiz game in unity following the tutorial from unity, and the questions are loaded in with Json.
It is done this because it will be possible to change the questions, update, add and remove questions, without unity and without having to reupload the quiz to the (it is a webGL build).
Here is the problem:
Some of the questions have either images attach (e.g. an album cover and the question is: Who made this album) or some sound attached.
I saved the Json file from the question i made in the inspector. The images and sounds are then saved as:
“QuestionAudio”: { “instanceID”: 10004 },
“QuestionImage”: { “instanceID”: 0 },
0 = no image or sound.
Then it is loaded from Json file the image won’t show and the sound won’t play.
And in the inspector in unity it says: “Type mismatch” in the box for the sound file or image file:

The text works perfectly and it is possible to update the text outside of unity in a text editor.
Is it possible to add images and sounds in the Json file?
I know Json is only text. but i was thinking something like link to the location of the image or sound file.
The Json code:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using System.IO;
public class DataController : MonoBehaviour
{
public RoundData[] allRoundData;
private string gameDataFileName = "data.json";
// Use this for initialization
void Start()
{
DontDestroyOnLoad(gameObject);
LoadGameData();
SceneManager.LoadScene("MenuScreen");
}
private void LoadGameData()
{
// Path.Combine combines strings into a file path
// Application.StreamingAssets points to Assets/StreamingAssets in the Editor, and the StreamingAssets folder in a build
string filePath = Path.Combine(Application.streamingAssetsPath, gameDataFileName);
if (File.Exists(filePath))
{
// Read the json from the file into a string
string dataAsJson = File.ReadAllText(filePath);
// Pass the json to JsonUtility, and tell it to create a GameData object from it
//GameData loadedData = JsonUtility.FromJson<GameData>(dataAsJson);
GameData loadedData = JsonUtility.FromJson<GameData>(dataAsJson);
// Retrieve the allRoundData property of loadedData
allRoundData = loadedData.allRoundData;
}
else
{
Debug.LogError("Cannot load game data!");
}
}