Beispiel #1
0
        public static AudioInfo CreateAudioInfo(string assetPath)
        {
            if (!EditorPath.IsAudio(assetPath))
            {
                return(null);
            }

            AudioInfo audioInfo = null;

            if (!_dictAudioInfo.TryGetValue(assetPath, out audioInfo))
            {
                audioInfo = new AudioInfo();
                _dictAudioInfo.Add(assetPath, audioInfo);
            }

            AudioImporter audioImporter = AssetImporter.GetAtPath(assetPath) as AudioImporter;
            AudioClip     audioClip     = AssetDatabase.LoadAssetAtPath <AudioClip>(assetPath);

            if (audioImporter == null || audioClip == null)
            {
                Debug.LogError("audioImporter is empty");
                return(null);
            }

            audioInfo.Path                             = assetPath;
            audioInfo.ForceToMono                      = audioImporter.forceToMono;
            audioInfo.LoadInBackground                 = audioImporter.loadInBackground;
            audioInfo.Ambisonic                        = audioImporter.ambisonic;
            audioInfo.MemSize                          = EditorTool.GetRuntimeMemorySize(audioClip);
            audioInfo.ImportedSize                     = EditorTool.GetRuntimeMemorySize(audioClip);
            audioInfo.StandAloneAudioClipLoadType      = audioImporter.GetOverrideSampleSettings("Standalone").loadType;
            audioInfo.AndroidAudioClipLoadType         = audioImporter.GetOverrideSampleSettings("Android").loadType;
            audioInfo.iOSAudioClipLoadType             = audioImporter.GetOverrideSampleSettings("iOS").loadType;
            audioInfo.StandAloneAudioCompressionFormat = audioImporter.GetOverrideSampleSettings("Standalone").compressionFormat;
            audioInfo.AndroidAudioCompressionFormat    = audioImporter.GetOverrideSampleSettings("Android").compressionFormat;
            audioInfo.iOSAudioCompressionFormat        = audioImporter.GetOverrideSampleSettings("iOS").compressionFormat;
            audioInfo.OriginSize                       = ViewerConst.GetInternalValue <int>(audioImporter, "get_origSize", null);
            audioInfo.CompressedSize                   = ViewerConst.GetInternalValue <int>(audioImporter, "get_compSize", null);

            if (++_loadCount % 256 == 0)
            {
                Resources.UnloadUnusedAssets();
            }

            return(audioInfo);
        }