コード例 #1
0
 public void PlayRunningSound()
 {
     if (currentFloor != null)
     {
         AudioClipPair audioClipPair = GetAudioClipPairForCurrentFloor();
         audioSource.clip = audioClipPair.runningAudioClip;
         PlayOrUnPauseAudioSource();
     }
 }
コード例 #2
0
    public static AudioClipCache FromResources(AudioClip[] gameObjects)
    {
        BlobAssetReference <AudioClipCacheBlobAsset> reference;

        using (var builder = new BlobBuilder(Allocator.Temp)) {
            ref var root      = ref builder.ConstructRoot <AudioClipCacheBlobAsset>();
            var     clipPairs = builder.Allocate(ref root.AudioClipPairs, gameObjects.Length);

            for (int i = 0; i < gameObjects.Length; i++)
            {
                Debug.Log($"Adding Prefab {gameObjects[i].name} with ID {gameObjects[i].GetInstanceID()} to AudioClipCache.");
                clipPairs[i] = new AudioClipPair(gameObjects[i].Hash(), gameObjects[i]);
            }
            reference = builder.CreateBlobAssetReference <AudioClipCacheBlobAsset>(Allocator.Persistent);
            Debug.Log($"{clipPairs.Length} total items in cache");
        }