Exemple #1
0
    private void AudioTest2(string testPath)
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            // Load the clip
            AudioClip loadedClip;
            AudioLoader.LoadAudioClipBlocking(testPath, out loadedClip);

            // Push the clip
            Simulation      sim = Simulation.Instance;
            AudioController ac  = sim.Controller.GetSimulationComponent <AudioController>();
            ac.PlayClip(Vector3.zero, loadedClip, 1, true);
        }
    }
Exemple #2
0
    public override void OnReceivedMessage(Message message)
    {
        if (message.Route == (int)MessageDestination.SCENE_CHANGE)
        {
            if (message.Identifier == "VALID")
            {
                StopAllSources();
                SimulationScene scene = (SimulationScene)message.Data;

                string volumeStr; //filePath
                int    volume = 0;
                if (scene.GetAttribute("GENERAL_SETTINGS_ALARM_VOLUME", out volumeStr))
                {
                    volume = Int32.Parse(volumeStr);
                    if (volume <= 0)
                    {
                        return;
                    }
                }
                string filePath;
                if (scene.GetAttribute("GENERAL_SETTINGS_ALARM_FILE", out filePath))
                {
                    // Add a prefix to fix bad file names
                    string url        = Application.dataPath + @"/JsonScene/" + filePath;
                    string filePrefix = @"file://";
                    url = filePrefix + url;

                    Debug.Log(url);
                    AudioClip clip;
                    if (AudioLoader.LoadAudioClipBlocking(url, out clip))
                    {
                        PlayClip(Vector3.zero, clip, (float)volume / 100, true);
                    }
                    else
                    {
                        Debug.LogError("FAILED TO PLAY CLIP FROM URL " + url);
                    }
                }
            }
        }
    }