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


C# AudioClip.GetInstanceID方法代码示例

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


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

示例1: ExportAudio

        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;
            }
        }
开发者ID:CodeHelix,项目名称:FFWD,代码行数:19,代码来源:AssetHelper.cs

示例2: ExportAudio

 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);
 }
开发者ID:Joelone,项目名称:FFWD,代码行数:11,代码来源:ExportSceneWizard.cs

示例3: ImportInfo

        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;
            }
        }
开发者ID:gregzo,项目名称:G-Audio,代码行数:19,代码来源:SoundBankInspector.cs

示例4: PlayRandom

    /// <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;
    }
开发者ID:Noetan,项目名称:Cute-Platformer-Game,代码行数:52,代码来源:AudioPool.cs


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