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


C# AudioClip.UnloadAudioData方法代码示例

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


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

示例1: UnloadNonPreloadedAudioData

        /*! \cond PRIVATE */
#if UNITY_5
        public static void UnloadNonPreloadedAudioData(AudioClip clip) {
            if (clip != null && !clip.preloadAudioData) {
                clip.UnloadAudioData(); // restore memory
            }
        }
开发者ID:riscvul,项目名称:SCP_Game_Prototype,代码行数:7,代码来源:AudioUtil.cs

示例2: StartImport

    public AudioClip StartImport(string mPath)
    {
        MPGImport.mpg123_init();
        handle_mpg = MPGImport.mpg123_new(null, errPtr);
        try
        {
            x = MPGImport.mpg123_open(handle_mpg, mPath);
            MPGImport.mpg123_getformat(handle_mpg, out rate, out channels, out encoding);
            intRate = rate.ToInt32();
            intChannels = channels.ToInt32();
            intEncoding = encoding.ToInt32();

            MPGImport.mpg123_id3(handle_mpg, out id3v1, out id3v2);
            MPGImport.mpg123_format_none(handle_mpg);
            MPGImport.mpg123_format(handle_mpg, intRate, intChannels, 208);

            Debug.Log("Getting ID3 info");
            MPGImport.mpg123_id3v1 v1 = (MPGImport.mpg123_id3v1)Marshal.PtrToStructure(id3v1, typeof(MPGImport.mpg123_id3v1));

            FrameSize = MPGImport.mpg123_outblock(handle_mpg);
            byte[] Buffer = new byte[FrameSize];
            lengthSamples = MPGImport.mpg123_length(handle_mpg);

            myClip = AudioClip.Create(new String(v1.title), lengthSamples, intChannels, intRate, false);

            int importIndex = 0;

            while (0 == MPGImport.mpg123_read(handle_mpg, Buffer, FrameSize, out done))
            {
                float[] fArray;
                fArray = ByteToFloat(Buffer);
                float offset = (importIndex * fArray.Length) / 2;
                if (offset > lengthSamples)
                {
                    Debug.LogWarning("[STED] MP3 file " + mPath + " is of an unexpected length and was truncated.");
                    break; // File was reported as shorter than it is. Salvage what we have and return.
                }
                myClip.SetData(fArray, (int)offset);
                importIndex++;
            }
        }
        catch (Exception ex)
        {
            // Attempt to dump any used memory before continuing.
            // TODO: Still holds onto memory when repeatedy failing.
            myClip.UnloadAudioData();
            myClip = null;
            throw ex;
        }
        finally
        {
            MPGImport.mpg123_close(handle_mpg);
        }
        return myClip;
    }
开发者ID:pizzaoverhead,项目名称:SoundtrackEditor,代码行数:55,代码来源:MP3Import.cs


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