Exemple #1
0
    SoundManager(AudioSource audioSource)
    {
        if (GameManager.instance == null)
        {
            Debug.Log("Initialize GameManager First.");
        }

        if (DatatableManager.instance == null)
        {
            DatatableManager.InitDatatableManager();
        }

        this.audioSource = audioSource;

        {
            List <SEInfo> soundeffects = DatatableManager.instance.LoadJson <List <SEInfo> >("Datatables/datatable_soundeffect");

            foreach (SEInfo soundeffect in soundeffects)
            {
                var         filenames = soundeffect.FileNames;
                AudioClip[] clips     = new AudioClip[filenames.Count];
                for (int i = 0; i < filenames.Count; i++)
                {
                    clips[i] = Resources.Load <AudioClip>(filenames[i]);
                }

                m_soundEffects.Add(soundeffect.ClassName, clips);
            }
        }

        datatableBGM = DatatableManager.instance.LoadDatatableByClassName <BGMSetInfo>("Datatables/datatable_bgm");
    }
    void Awake()
    {
        if (GameManager.instance != null)
        {
            return;
        }

        GameManager.instance = this;

        DatatableManager.InitDatatableManager();
        SoundManager.InitSoundManager(GetComponent <AudioSource>());
    }