当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.AudioClip类代码示例

本文整理汇总了C#中UnityEngine.AudioClip的典型用法代码示例。如果您正苦于以下问题:C# AudioClip类的具体用法?C# AudioClip怎么用?C# AudioClip使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AudioClip类属于UnityEngine命名空间,在下文中一共展示了AudioClip类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PlayMusic

    public void PlayMusic(AudioClip clip, float fadeDuration = 1) {
        activeMusicSourceIndex = 1 - activeMusicSourceIndex;
        musicSources[activeMusicSourceIndex].clip = clip;
        musicSources[activeMusicSourceIndex].Play();

        StartCoroutine(AnimateMusicCrossfade(fadeDuration));
    }
开发者ID:queekusme,项目名称:Lamb-to-Slaughter,代码行数:7,代码来源:AudioManager.cs

示例2: PlayMusic

        /**
         * Plays game music using an audio clip.
         * One music clip may be played at a time.
         * @param musicClip The music clip to play
         * @param atTime Time in the music clip to start at
         */
        public void PlayMusic(AudioClip musicClip, bool loop, float fadeDuration, float atTime)
        {
            AudioSource audioSource = GetComponent<AudioSource>();
            if (audioSource == null || audioSource.clip == musicClip)
            {
                return;
            }

            if (fadeDuration == 0f)
            {
                audioSource.clip = musicClip;
                audioSource.loop = loop;
                audioSource.time = atTime;	// May be inaccurate if the audio source is compressed http://docs.unity3d.com/ScriptReference/AudioSource-time.html BK
                audioSource.Play();
            }
            else
            {
                float startVolume = audioSource.volume;

                LeanTween.value(gameObject, startVolume, 0f, fadeDuration)
                    .setOnUpdate( (v) => {
                        // Fade out current music
                        audioSource.volume = v;
                    }).setOnComplete( () => {
                        // Play new music
                        audioSource.volume = startVolume;
                        audioSource.clip = musicClip;
                        audioSource.loop = loop;
                        audioSource.time = atTime;	// May be inaccurate if the audio source is compressed http://docs.unity3d.com/ScriptReference/AudioSource-time.html BK
                        audioSource.Play();
                    });
            }
        }
开发者ID:rstruk,项目名称:ProjetLaby,代码行数:39,代码来源:MusicController.cs

示例3: ParseTextAndSpeak

    //This is called by the Line Reader to parse a string and begin speaking
    public void ParseTextAndSpeak(string inputText, AudioClip inputAudio)
    {
        mouthQueue.Clear();
        textTime.Clear();
        currentSyllable = 0;
        //split the string up into
        string[] splitString = inputText.Split(';');
        for (int i = 0; i < splitString.Length; i++)
        {
            for (int m = 0; m < mouths.Length; m++)
            {
                for (int s = 0; s < mouths[m].syllable.Length; s++)
                {
                    if (splitString[i].StartsWith(mouths[m].syllable[s]))
                    {
                        mouthQueue.Add(m);
                        textTime.Add(splitString[i].Length * timePerInputCharacter);
                        //break;
                    }
                }

            }
        }
        //reset the coroutine
        CancelInvoke("SetNextMouth");
        SetNextMouth();
        myAudio.clip = inputAudio;
        myAudio.Play();
    }
开发者ID:nkornek,项目名称:FartBuckets,代码行数:30,代码来源:LipSync.cs

示例4: OnShoot

    void OnShoot()
    {
        gunshot = Resources.Load<AudioClip>("Sounds/gunfire");
        source = GetComponent<AudioSource>();

        source.PlayOneShot(gunshot);
    }
开发者ID:raftelti,项目名称:flamewars,代码行数:7,代码来源:SoundOnShoot.cs

示例5: PlayOneShot

 void PlayOneShot(AudioClip sound)
 {
     if(_state == State.Play)
     {
         SoundPlayer.PlayOneShot(sound);
     }
 }
开发者ID:funcodes,项目名称:AirGame,代码行数:7,代码来源:SoundManager.cs

示例6: playSoundRandom

    public void playSoundRandom(Vector3 soundPos, AudioClip []arrayOfSounds, int sizeOfArray, int []availableSounds, int lenghtOfAvailableSounds)
    {
        bool numIsUsable = false;
        int ranNum = 0;

        for (int a = 0; a < 20; a++)
        {
            ranNum = Mathf.RoundToInt(Random.Range(0, sizeOfArray));

            for (int b = 0; b < lenghtOfAvailableSounds; b++)
            {
                if (ranNum == availableSounds[b])
                {
                    numIsUsable = true;
                    break;
                }
            }

            if (numIsUsable)
                break;
        }

        if (numIsUsable)
        {
            source.PlayOneShot(arrayOfSounds[ranNum]);
            //AudioSource.PlayClipAtPoint(arrayOfSounds[ranNum], soundPos);
            Debug.Log(ranNum);
        }
    }
开发者ID:kjarosz,项目名称:Hookshot,代码行数:29,代码来源:SoundEffectHelper.cs

示例7: Start

    void Start()
    {
        _audioSource = gameObject.AddComponent <AudioSource>();

                _godzillaDamageAudioclip = _doLoadAudioClipByName (MainConstants.AUDIO_GODZILLA_DAMAGE);
                _mazingerDamageudioclip = _doLoadAudioClipByName (MainConstants.AUDIO_MAZINGER_DAMAGE);
    }
开发者ID:pmartinezalvarez,项目名称:monsters-vs-robots,代码行数:7,代码来源:AudioManager.cs

示例8: Play

 public void Play(AudioClip sound)
 {
     GameObject temp;
     if (soundObjects.TryGetValue(sound, out temp)) {
         if (!temp.GetComponent<AudioSource>().isPlaying) temp.GetComponent<AudioSource>().Play();
     }
 }
开发者ID:acenode,项目名称:unity-rts-demo,代码行数:7,代码来源:AudioElement.cs

示例9: Stop

 public void Stop(AudioClip sound)
 {
     GameObject temp;
     if (soundObjects.TryGetValue(sound, out temp)) {
         temp.GetComponent<AudioSource>().Stop ();
     }
 }
开发者ID:acenode,项目名称:unity-rts-demo,代码行数:7,代码来源:AudioElement.cs

示例10: ReplaceMusic

 public void ReplaceMusic(AudioClip muse, float newVolume)
 {
     if (ownSource.clip != muse){
         nextMusic = muse;
         maxVolume = newVolume;
     }
 }
开发者ID:chorgan93,项目名称:Ectoplazaa,代码行数:7,代码来源:BGMS.cs

示例11: justplaySfx

    IEnumerator justplaySfx(AudioClip _clip,float volume)
    {
        //audio.PlayOneShot (_clip, volume);
        audio.PlayOneShot (_clip, volume);

        yield return null;
    }
开发者ID:meetingmeeting,项目名称:grass_sled_secure,代码行数:7,代码来源:playerAni.cs

示例12: PlaySoundLoop

	public void PlaySoundLoop(AudioClip inClip, float timeDelay = 0)
	{
		audio.loop = true;
		audio.clip = inClip;
		//audio.Play();
		audio.PlayDelayed(timeDelay);
	}
开发者ID:BGCX262,项目名称:zzzstrawhatzzz-svn-to-git,代码行数:7,代码来源:SoundPlayerScript.cs

示例13: PlaySoundAt

 public AudioSource PlaySoundAt(AudioClip clip, Transform soundParent, string tag = "Untagged")
 {
     AudioSource source = PlaySoundAt(clip, soundParent.position, tag);
     source.transform.SetParent(soundParent, false);
     source.transform.localPosition = new Vector3(0, 0, 0);
     return source;
 }
开发者ID:JonECG,项目名称:Spoopy,代码行数:7,代码来源:SoundManagerController.cs

示例14: setCard

 //Method that other scripts can use to pass new sprites into this object
 public void setCard(Sprite image, int inputId, string t, AudioClip c)
 {
     clip = c;
     id = inputId;
     type = t;
     GetComponent<SpriteRenderer>().sprite = image;
 }
开发者ID:dnaismyth,项目名称:Learning-App,代码行数:8,代码来源:cardBack.cs

示例15: Play

		public void Play(AudioClip clip, float volume = 1.0f)
		{
			if (clip != null)
			{
				_source.PlayOneShot(clip, _source.volume * volume);
			}
		}
开发者ID:paveltimofeev,项目名称:GameJamFramework,代码行数:7,代码来源:BaseAudioManager.cs


注:本文中的UnityEngine.AudioClip类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。