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; } }
public void CheckBankIntegrity(List <GATSampleInfo> sampleInfos) { if (Application.isPlaying) { throw new GATException("Check integrity cannot be called in play mode!"); } string path; string pathInResources; AudioClip clip; bool bankHasErrors = false; List <GATSampleInfo> samplesToRemove = new List <GATSampleInfo>(); foreach (GATSampleInfo info in sampleInfos) { path = AssetDatabase.GUIDToAssetPath(info.GUID); if (path == "") { info.clipStatus = SoundBankClipStatus.NotFound; if (ClipNotFoundDialog(info.Name)) { samplesToRemove.Add(info); } else { bankHasErrors = true; } continue; } clip = ( AudioClip )AssetDatabase.LoadAssetAtPath(path, typeof(AudioClip)); if (clip == null) { info.clipStatus = SoundBankClipStatus.NotFound; if (ClipNotFoundDialog(info.Name)) { samplesToRemove.Add(info); } else { bankHasErrors = true; } continue; } pathInResources = GATEditorUtilities.PathInResources(path); if (pathInResources == null) { pathInResources = GATEditorUtilities.PathInStreamingAssets(path); } if (pathInResources == null) { info.clipStatus = SoundBankClipStatus.NotInResources; if (EditorUtility.DisplayDialog("AudioClip not in Resources", string.Format("clip {0} was found, but is not in a Resources or StreamingAssets folder. Remove it from the SoundBank?", info.Name), "Remove", "Skip")) { samplesToRemove.Add(info); } else { bankHasErrors = true; } continue; } else if (pathInResources != info.PathInResources) { info.clipStatus = SoundBankClipStatus.Moved; Debug.Log(string.Format("moved form {0} to {1}", info.PathInResources, pathInResources)); if (EditorUtility.DisplayDialog("AudioClip moved", string.Format("clip {0} was found but has moved since it was added to the SoundBank. Update path info?", info.Name), "Update", "Skip")) { info.UpdatePathInResources(); } else { bankHasErrors = true; } continue; } } foreach (GATSampleInfo info in samplesToRemove) { _soundBank.RemoveSample(info); } EditorUtility.SetDirty(_soundBank); string endDialog = bankHasErrors ? "This Sound Bank contains errors that need to be fixed before it is loaded." : "No errors!"; EditorUtility.DisplayDialog("Check Completed", endDialog, "OK"); }