Inheritance: UnityEngine.ScriptableObject
コード例 #1
0
            public void Load(AudioClipList audioClipList)
            {
                var audioClips = audioClipList.audioClips;

                // Clear(loopClips);
                // Clear(endClips);
                loopClips = new AudioClip[loopClipIDs.Length];
                endClips  = new AudioClip[endClipIDs.Length];

                for (int i = 0; i < loopClipIDs.Length; ++i)
                {
                    if (loopClipIDs[i] >= 0)
                    {
                        loopClips[i] = audioClips[loopClipIDs[i]];
                    }
                }

                for (int i = 0; i < endClipIDs.Length; ++i)
                {
                    if (endClipIDs[i] >= 0)
                    {
                        endClips[i] = audioClips[endClipIDs[i]];
                    }
                }
            }
コード例 #2
0
 private AudioClip GetAudioClip(AudioClipList list, int index)
 {
     if (index >= list.Count)
     {
         return(null);
     }
     return(list.List[index]);
 }
コード例 #3
0
    public void PlaySound(AudioClipList audioClip)
    {
        AudioClip ac = m_audioDico[audioClip].Item1;

        m_MyAudioSource.clip   = ac;
        m_MyAudioSource.volume = m_audioDico[audioClip].Item2 * m_fxVolume * m_masterVolume;
        m_MyAudioSource.Play();
    }
コード例 #4
0
        public void _Load()
        {
            audioClipList           = ScriptableObject.CreateInstance <AudioClipList>();
            audioClipList.hideFlags = HideFlags.DontSave;
            audioClipList.Load(data);

            for (int i = 0; i < sounds.Length; ++i)
            {
                sounds[i].Load(audioClipList);
            }
        }
コード例 #5
0
 public void GetEditorClips()
 {
     if (audioClipList)
     {
         DestroyImmediate(audioClipList);
     }
     audioClipList           = ScriptableObject.CreateInstance <AudioClipList>();
     audioClipList.hideFlags = HideFlags.DontSave;
     for (int i = 0; i < sounds.Length; ++i)
     {
         sounds[i].GetEditorClips();
     }
 }
コード例 #6
0
    public void CreateSound(PlayerSoundType type, int playerNum, Vector3 position, float minVolume, float maxVolume)
    {
        PlayerSoundList playerSoundList = this.playerSounds[(int)type];

        if (playerSoundList.clipLists == null || playerSoundList.clipLists.Length == 0)
        {
            Debug.LogWarning("No clips for " + type);
            return;
        }

        // Get list of sounds for this playerNum
        if (playerNum > playerSoundList.clipLists.Length)
        {
            Debug.LogWarning("playerNum " + playerNum + " is too high");
            playerNum %= playerSoundList.clipLists.Length;
        }
        AudioClipList clipList = playerSoundList.clipLists[playerNum];

        AudioClip clip = clipList.items[UnityEngine.Random.Range(0, clipList.items.Length)];

        CreateSound(position, clip, minVolume, maxVolume);
    }
コード例 #7
0
        private void HandlePlayAudioEvents(DialogueEvent ev, AudioSource player, AudioClipList audioClipList)
        {
            string functionName = "PlayBGM";

            if (ev.eventType == DialogueEventType.PlaySFX)
            {
                functionName = "PlaySFX";
            }
            if (ev.parameters.Length <= 0)
            {
                Debug.LogWarning(functionName + " need at least one integer argument");
            }
            else
            {
                string[] parameters = ev.parameters;


                if (parameters.Length == 1)
                {
                    //PlayAudio(int clipIndex);
                    if (isInteger(parameters[0]))
                    {
                        if (ev.eventType == DialogueEventType.PlayBGM)
                        {
                            PlayBGM(Int32.Parse(parameters[0]));
                        }
                        else if (ev.eventType == DialogueEventType.PlaySFX)
                        {
                            PlaySFX(Int32.Parse(parameters[0]));
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Invalid argument/ " + functionName + "(int index)");
                    }
                }
                else if (parameters.Length == 2)
                {
                    //PlayAudio(int clipIndex, float volume);
                    if (isInteger(parameters[0]) && isFloat(parameters[1]))
                    {
                        if (ev.eventType == DialogueEventType.PlayBGM)
                        {
                            PlayBGM(Int32.Parse(parameters[0]), float.Parse(parameters[1]));
                        }
                        else if (ev.eventType == DialogueEventType.PlaySFX)
                        {
                            PlaySFX(Int32.Parse(parameters[0]), float.Parse(parameters[1]));
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Invalid argument/ " + functionName + "(int index, float volume)");
                    }
                }
                else if (parameters.Length > 2)
                {
                    //PlayAudio(int clipIndex, float volume, bool isLoop);
                    if (isInteger(parameters[0]) && isFloat(parameters[1]))
                    {
                        if (isBoolean(parameters[2]))
                        {
                            if (ev.eventType == DialogueEventType.PlayBGM)
                            {
                                PlayBGM(Int32.Parse(parameters[0]), float.Parse(parameters[1]), Boolean.Parse(parameters[2]));
                            }
                            else if (ev.eventType == DialogueEventType.PlaySFX)
                            {
                                PlaySFX(Int32.Parse(parameters[0]), float.Parse(parameters[1]), Boolean.Parse(parameters[2]));
                            }
                        }
                        else
                        {
                            Debug.LogWarning("Invalid boolean argument");
                            if (ev.eventType == DialogueEventType.PlayBGM)
                            {
                                PlayBGM(Int32.Parse(parameters[0]), float.Parse(parameters[1]));
                            }
                            else if (ev.eventType == DialogueEventType.PlaySFX)
                            {
                                PlaySFX(Int32.Parse(parameters[0]), float.Parse(parameters[1]));
                            }
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Invalid argument/ " + functionName + "(int index, float volume, bool isLoop)");
                    }
                }
            }
        }