AudioClip.SetData(samples,0) not working loading sample data from json file in Unity

1.3k views Asked by At

I am trying to Set audioclip samples previously saved using audioclip.GetData from a json file. The Audio data is present in my json file but it seems not to work when Loading this file and setting up the audioclip data using SetData:

In my Load function: I am Instantiating a prefab that contains the component AudioSource: audioFB. Then I want to set up the clip using:

audioFB.GetComponent<AudioSource>().clip.SetData(qc.clipData, 0);

However I do have this error: Object reference not set to an instance of an object when doing so.

On the other hand if I directly Load an audio file from Resources folder, it does work.

Am I not using SetData correctly?

Thank you for your help.

0

There are 0 answers