예제 #1
0
    /**
     * Loads all needed resources for the audio event manager
     * when using unity audio
     */
    private void InitializeUnityAudio()
    {
        // Adds the audio listener
        this.gameObject.AddComponent <AudioListener>();

        SoundEventDatabase databaseInstance = LoadGenericResource(
            "Databases/SoundEventDatabase",
            "Event database successfully loaded",
            "Unable to load the events database") as SoundEventDatabase;

        SoundObject = LoadGenericResource(
            "Prefabs/SoundObject",
            "Sound object successfully loaded",
            "Unable to load the sound object prefab") as GameObject;

        AudioMixer _musicMixer = LoadGenericResource(
            "Mixers/MusicMixer",
            "Music mixer successfully loaded",
            "Unable to load the music mixer") as AudioMixer;

        AudioMixer _sfxMixer = LoadGenericResource(
            "Mixers/SFXMixer",
            "SFX mixer successfully loaded",
            "Unable to load the sfx mixer") as AudioMixer;

        MusicMixer = _musicMixer.FindMatchingGroups("Master")[0];
        SFXMixer   = _sfxMixer.FindMatchingGroups("Master")[0];

        if (databaseInstance != null)
        {
            Events = databaseInstance.Events;
        }
    }
    /**
     * Initializes the editor window. Loads the sound event database
     * @return False on loading error, else true
     */
    public static bool LoadSoundEventDatabase()
    {
        databaseInstance = Resources.Load("Databases/SoundEventDatabase") as SoundEventDatabase;
        if (!databaseInstance)
        {
            EditorUtility.DisplayDialog(
                "Unable to load the event database",
                "Please check if the database exist in the resources folder.", "Ok");

            return(false);
        }

        return(true);
    }