/// <summary> /// 绘制Audio列表 /// </summary> /// <param name="targets"></param> private void DrawAudioList(UnityEngine.Object[] targets) { EffectPack effectPack = targets[0] as EffectPack; for (int i = 0; i < effectPack.AudioAttrs.Count;) { m_audioAttr.Copy(effectPack.AudioAttrs[i]); string header = ((m_audioAttr.AudioName != null) ? m_audioAttr.AudioName : string.Empty);//标题 if (LayoutUtility.Foldout(header)) { LayoutUtility.BeginContents(); if (GUILayout.Button("", "ToggleMixed", GUILayout.Width(20f))) { UnityEditor.Undo.RecordObjects(targets, "Remove AudioClip"); for (int j = 0; j < targets.Length; ++j) { (targets[j] as EffectPack).AudioAttrs.RemoveAt(i); EditorUtility.SetDirty(targets[j]); } } else { DrawAudioAttribute(m_audioAttr); if (!m_audioAttr.Equals(effectPack.AudioAttrs[i])) { UnityEditor.Undo.RecordObjects(targets, "Modify AudioClip"); for (int j = 0; j < targets.Length; ++j) { (targets[j] as EffectPack).AudioAttrs[i].Copy(m_audioAttr); EditorUtility.SetDirty(targets[j]); } } } LayoutUtility.EndContents(); } ++i; } // 绘制加入新的Audio的选项 if (LayoutUtility.Foldout("Add New AudioClip")) { LayoutUtility.BeginContents(); string audioName = LayoutUtility.AudioFiled("Audio Clip", null); if (audioName != null) { UnityEditor.Undo.RecordObjects(targets, "Add Audio Clip"); for (int j = 0; j < targets.Length; ++j) { EffectPack.AudioAttr audioAttr = new EffectPack.AudioAttr(); audioAttr.AudioName = audioName; audioAttr.AudioPath = EffectConfig.Instance.AudioClipPath + "/" + audioName; (targets[j] as EffectPack).AudioAttrs.Add(audioAttr); EditorUtility.SetDirty(targets[j]); } } LayoutUtility.EndContents(); } }