Write me a Unity editor window script that shows all audio sources in the scene and has…
- User
Write me a Unity editor window script that shows all audio sources in the scene and has a button to play them.
- Assistant
Sure, here's an example Unity editor window script that shows all audio sources in the scene and has a button to play them:
using UnityEngine;
public class PlayAllSources : MonoBehaviour { public GameObject[] sources; public bool playSource = false;
void Start() { foreach (GameObject source in sources) { if (source.GetComponent<AudioSource>()!= null) { source.GetComponent<AudioSource>().Play(); playSource = true; } } } void Update() { if (playSource) { foreach (GameObject source in sources) { if (source.GetComponent<AudioSource>()!= null) { source.GetComponent<AudioSource>().Stop(); } } playSource = false; } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.