コード例 #1
0
ファイル: AssetHelper.cs プロジェクト: CodeHelix/FFWD
        internal void ExportAudio(AudioClip audio)
        {
            if (audio == null) return;
            string path = AssetDatabase.GetAssetPath(audio.GetInstanceID());
            if (exportedAudio.Contains(path)) return;

            exportedAudio.Add(path);
            string dest = Path.Combine(AudioDir, Path.GetFileName(path));

            try
            {
                File.Copy(path, dest, true);
            }
            catch (UnityException ue)
            {
                Debug.Log(ue.ToString());
                throw;
            }
        }
コード例 #2
0
ファイル: ExportSceneWizard.cs プロジェクト: Joelone/FFWD
 public void ExportAudio(AudioClip asset)
 {
     string assetPath = AssetDatabase.GetAssetPath(asset.GetInstanceID());
     string exportPath = Path.Combine(Path.Combine(assets.AudioDir, ".."), assetPath.Replace("Assets/", ""));
     if (!Directory.Exists(Path.GetDirectoryName(exportPath)))
     {
         Directory.CreateDirectory(Path.GetDirectoryName(exportPath));
     }
     File.Copy(assetPath, exportPath, true);
     //Debug.Log("Exported Audio asset to " + exportPath);
 }
コード例 #3
0
ファイル: SoundBankInspector.cs プロジェクト: gregzo/G-Audio
        public ImportInfo( AudioClip clip )
        {
            Clip			= clip;
            Path 			= AssetDatabase.GetAssetPath( clip.GetInstanceID() );
            GUID			= AssetDatabase.AssetPathToGUID( Path );
            Importer		= AssetImporter.GetAtPath( Path ) as AudioImporter;

            if( GATEditorUtilities.IsInResources( Path ) )
            {
                PathInResources = GATEditorUtilities.PathInResources( Path );

            }
            else if( GATEditorUtilities.IsInStreamingAssets( Path ) )
            {
                PathInResources = GATEditorUtilities.PathInStreamingAssets( Path );
                System.IO.Path.ChangeExtension( PathInResources, System.IO.Path.GetExtension( Importer.assetPath ) );
                IsStreamingAsset = true;
            }
        }
コード例 #4
0
    /// <summary>
    /// Plays the given audio clip with a random pitch and volume as defined in the settings given.
    /// </summary> 
    public AudioSource PlayRandom(AudioClip clip, Vector3 pos, AudioClipSettings settings)
    {
        if (settings.SingleInstance && m_activeClips.Count > 0)
        {
            // Search the list for the matching audio clip
            for (int i = 0; i < m_activeClips.Count; i++)
            {
                if (m_activeClips[i].clip.GetInstanceID() == clip.GetInstanceID())
                {
                    // Found and overlap period not over yet
                    // End the function and skip the audio clip
                    if (m_activeClips[i].time < settings.OverlapThreshold && m_activeClips[i].isPlaying)
                    {
                        return null;
                    }
                    // Found and overlap is over
                    else
                    {
                        m_activeClips.RemoveAt(i);
                        break;
                    }
                }
            }
        }

        // Retrieve unused audio source from pool
        GameObject newSound = m_AudioSources.New(pos);
        var cb = newSound.GetComponent<CustomBehaviour>();
        var audSrc = cb.GetAudioSource;
        // Randomization
        float randomPitch = UnityEngine.Random.Range(settings.MinPitch, settings.MaxPitch);
        float randomVol = UnityEngine.Random.Range(settings.MinVolume, settings.MaxVolume);

        newSound.transform.position = pos;
        audSrc.clip = clip;
        audSrc.pitch = randomPitch;
        audSrc.volume = randomVol;
        audSrc.outputAudioMixerGroup = settings.MixerGroup;

        if (settings.SingleInstance)
        {
            m_activeClips.Add(audSrc);
        }

        newSound.SetActive(true);
        Timing.RunCoroutine(StoreClip(cb), Segment.SlowUpdate);

        return audSrc;
    }