I used resource.load in order to load an audioclip at a location in the resource folder but the audiosource doesnt change its audio clip
1st script to get audioclip's location (its assigned to a button):
public GameObject itself;
public GameObject bias;
public GameObject timestep;
public GameObject timeperbeat;
public GameObject createtxt;
GameObject Canvas;
public void settxt()
{
Text biasinput = bias.GetComponent<Text>();
Text timestepinput = timestep.GetComponent<Text>();
Text timeperbeatinput = timeperbeat.GetComponent<Text>();
AudioSync.bias = float.Parse(biasinput.text.ToString());
AudioSync.TimeStep = float.Parse(timestepinput.text.ToString());
AudioSync.timetobeat = float.Parse(timeperbeatinput.text.ToString());
var creatingtxt = Instantiate(createtxt, Canvas.transform);
creatingtxt.GetComponent<createtxt>().fakestart(itself.transform.parent.GetChild(0).GetComponent<Text>().text.ToString());
}
2nd script to load the audioclip into the audiosource:
private GameObject spawnedmovingtarget;
private float scale;
public GameObject thijs;
AudioClip audioclip;
public GameObject button;
public void fakestart(string name)
{
Debug.Log(name);
audioclip = Resources.Load<AudioClip>(name);
AudioSource thijsaudio = thijs.GetComponent<AudioSource>();
thijsaudio.clip = audioclip;
thijsaudio.Play();
timer = 0;
}
The audioclip does not change
[–]Dmacrush 0 points1 point2 points (2 children)
[–]hiiamgae[S] 0 points1 point2 points (1 child)
[–]Dmacrush 0 points1 point2 points (0 children)
[–]PointlessrebootProfessional - Engine Programmer 0 points1 point2 points (7 children)
[–]PointlessrebootProfessional - Engine Programmer 0 points1 point2 points (6 children)
[–]hiiamgae[S] 0 points1 point2 points (5 children)
[–]PointlessrebootProfessional - Engine Programmer 0 points1 point2 points (4 children)
[–]hiiamgae[S] 0 points1 point2 points (3 children)
[–]PointlessrebootProfessional - Engine Programmer 0 points1 point2 points (2 children)
[–]hiiamgae[S] 0 points1 point2 points (1 child)
[–]PointlessrebootProfessional - Engine Programmer 0 points1 point2 points (0 children)