GameObject InstantiateChorus(ChorusScriptable c, Vector3 position) { GameObject go = (GameObject)Instantiate(audioSourcePrefab); go.name = c.instrumentName; CustomAudioSource source = go.GetComponent <CustomAudioSource>(); source.SetSound(AudioMixer.Instance.Load(c.path)); go.transform.SetParent(this.transform); go.AddComponent <Image>(); go.GetComponent <Image>().sprite = c.instrumentImage; go.transform.localScale = Vector3.one; go.transform.localPosition = 10 * position; orchestraPrefab.AddSource(source); VolumeDisplay volume = Instantiate(VolumeDislayer, go.transform); volume.transform.localPosition = new Vector3(100, -50, 0); volume.Source = go.GetComponent <CustomAudioSource>(); return(go); }
void AddItem() { ChorusScriptable newChorus = new ChorusScriptable(); newChorus.instrumentName = "New instrument"; trackScriptable.chorusList.Add(newChorus); viewIndex = trackScriptable.chorusList.Count; }