private SetValueForMixLevel ( UnityEditor.Audio.AudioMixerController controller, |
||
controller | UnityEditor.Audio.AudioMixerController | |
snapshot | ||
value | float | |
Результат | void |
private void EffectSlotDragging(Rect r, AudioMixerSnapshotController snapshot, AudioMixerEffectController effect, bool showLevel, float level, int effectIndex, ref int highlightEffectIndex, AudioMixerChannelStripView.ChannelStripParams p) { Event current = Event.current; switch (current.GetTypeForControl(this.m_EffectInteractionControlID)) { case EventType.MouseDown: if (r.Contains(current.mousePosition) && current.button == 0 && GUIUtility.hotControl == 0) { GUIUtility.hotControl = this.m_EffectInteractionControlID; this.m_MouseDragStartX = current.mousePosition.x; this.m_MouseDragStartValue = level; highlightEffectIndex = effectIndex; this.m_MovingEffectSrcIndex = -1; this.m_MovingEffectDstIndex = -1; this.m_WaitingForDragEvent = true; this.m_MovingSrcRect = r; this.m_MovingDstRect = r; this.m_MovingSrcGroup = p.group; this.m_MovingDstGroup = p.group; this.m_MovingEffectAllowed = true; this.SetFocus(); Event.current.Use(); EditorGUIUtility.SetWantsMouseJumping(1); InspectorWindow.RepaintAllInspectors(); } break; case EventType.MouseUp: if (GUIUtility.hotControl == this.m_EffectInteractionControlID && current.button == 0 && p.stripRect.Contains(current.mousePosition)) { if (this.m_MovingEffectDstIndex != -1 && this.m_MovingEffectAllowed) { if (this.IsDuplicateKeyPressed() && this.CanDuplicateDraggedEffect()) { AudioMixerEffectController sourceEffect = this.m_MovingSrcGroup.effects[this.m_MovingEffectSrcIndex]; AudioMixerEffectController effect2 = this.m_MovingSrcGroup.controller.CopyEffect(sourceEffect); List<AudioMixerEffectController> list = this.m_MovingDstGroup.effects.ToList<AudioMixerEffectController>(); if (AudioMixerController.InsertEffect(effect2, ref list, this.m_MovingEffectDstIndex)) { this.m_MovingDstGroup.effects = list.ToArray(); } } else { if (this.m_MovingSrcGroup == this.m_MovingDstGroup) { List<AudioMixerEffectController> list2 = this.m_MovingSrcGroup.effects.ToList<AudioMixerEffectController>(); if (AudioMixerController.MoveEffect(ref list2, this.m_MovingEffectSrcIndex, ref list2, this.m_MovingEffectDstIndex)) { this.m_MovingSrcGroup.effects = list2.ToArray(); } } else { if (!this.m_MovingSrcGroup.effects[this.m_MovingEffectSrcIndex].IsAttenuation()) { List<AudioMixerEffectController> list3 = this.m_MovingSrcGroup.effects.ToList<AudioMixerEffectController>(); List<AudioMixerEffectController> list4 = this.m_MovingDstGroup.effects.ToList<AudioMixerEffectController>(); if (AudioMixerController.MoveEffect(ref list3, this.m_MovingEffectSrcIndex, ref list4, this.m_MovingEffectDstIndex)) { this.m_MovingSrcGroup.effects = list3.ToArray(); this.m_MovingDstGroup.effects = list4.ToArray(); } } } } } this.ClearEffectDragging(ref highlightEffectIndex); current.Use(); EditorGUIUtility.SetWantsMouseJumping(0); GUIUtility.ExitGUI(); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == this.m_EffectInteractionControlID) { if (this.HasFocus() && this.m_WaitingForDragEvent) { this.m_ChangingWetMixIndex = -1; if (effectIndex < p.group.effects.Length) { if (Mathf.Abs(current.delta.y) > Mathf.Abs(current.delta.x)) { this.m_MovingEffectSrcIndex = effectIndex; this.ClearFocus(); } else { this.m_ChangingWetMixIndex = this.m_IndexCounter; } } this.m_WaitingForDragEvent = false; } if (this.IsMovingEffect() && p.stripRect.Contains(current.mousePosition)) { float num = r.height * 0.5f; float num2 = (effectIndex != 0) ? 0f : (-num); float num3 = (effectIndex != p.group.effects.Length - 1) ? r.height : (r.height + num); float num4 = current.mousePosition.y - r.y; if (num4 >= num2 && num4 <= num3 && effectIndex < p.group.effects.Length) { int num5 = (num4 >= num) ? (effectIndex + 1) : effectIndex; if (num5 != this.m_MovingEffectDstIndex || this.m_MovingDstGroup != p.group) { this.m_MovingDstRect.x = r.x; this.m_MovingDstRect.width = r.width; this.m_MovingDstRect.y = ((num4 >= num) ? (r.y + r.height) : r.y) - 1f; this.m_MovingEffectDstIndex = num5; this.m_MovingDstGroup = p.group; this.m_MovingEffectAllowed = ((!this.m_MovingSrcGroup.effects[this.m_MovingEffectSrcIndex].IsAttenuation() || !(this.m_MovingSrcGroup != this.m_MovingDstGroup)) && !AudioMixerController.WillMovingEffectCauseFeedback(p.allGroups, this.m_MovingSrcGroup, this.m_MovingEffectSrcIndex, this.m_MovingDstGroup, num5, null) && (!this.IsDuplicateKeyPressed() || this.CanDuplicateDraggedEffect())); } current.Use(); } } if (this.IsAdjustingWetMix() && this.HasFocus() && showLevel) { this.m_WaitingForDragEvent = false; float value = AudioMixerChannelStripView.kEffectScaleMouseDrag * HandleUtility.niceMouseDelta + level; float num6 = Mathf.Clamp(value, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect) - level; if (num6 != 0f) { Undo.RecordObject(this.m_Controller.TargetSnapshot, "Change effect level"); if (effect.IsSend() && this.m_Controller.CachedSelection.Count > 1 && this.m_Controller.CachedSelection.Contains(p.group)) { List<AudioMixerEffectController> list5 = new List<AudioMixerEffectController>(); foreach (AudioMixerGroupController current2 in this.m_Controller.CachedSelection) { AudioMixerEffectController[] effects = current2.effects; for (int i = 0; i < effects.Length; i++) { AudioMixerEffectController audioMixerEffectController = effects[i]; if (audioMixerEffectController.effectName == effect.effectName && audioMixerEffectController.sendTarget == effect.sendTarget) { list5.Add(audioMixerEffectController); } } } foreach (AudioMixerEffectController current3 in list5) { if (!current3.IsSend() || current3.sendTarget != null) { current3.SetValueForMixLevel(this.m_Controller, snapshot, Mathf.Clamp(current3.GetValueForMixLevel(this.m_Controller, snapshot) + num6, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect)); } } } else { if (!effect.IsSend() || effect.sendTarget != null) { effect.SetValueForMixLevel(this.m_Controller, snapshot, Mathf.Clamp(level + num6, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect)); } } InspectorWindow.RepaintAllInspectors(); } current.Use(); } } break; } }
private void EffectSlotDragging(Rect r, AudioMixerSnapshotController snapshot, AudioMixerEffectController effect, bool showLevel, float level, int effectIndex, ref int highlightEffectIndex, AudioMixerChannelStripView.ChannelStripParams p) { Event current1 = Event.current; switch (current1.GetTypeForControl(this.m_EffectInteractionControlID)) { case EventType.MouseDown: if (!r.Contains(current1.mousePosition) || current1.button != 0 || GUIUtility.hotControl != 0) break; GUIUtility.hotControl = this.m_EffectInteractionControlID; this.m_MouseDragStartX = current1.mousePosition.x; this.m_MouseDragStartValue = level; highlightEffectIndex = effectIndex; this.m_MovingEffectSrcIndex = -1; this.m_MovingEffectDstIndex = -1; this.m_WaitingForDragEvent = true; this.m_MovingSrcRect = r; this.m_MovingDstRect = r; this.m_MovingSrcGroup = p.group; this.m_MovingDstGroup = p.group; this.m_MovingEffectAllowed = true; this.SetFocus(); Event.current.Use(); EditorGUIUtility.SetWantsMouseJumping(1); InspectorWindow.RepaintAllInspectors(); break; case EventType.MouseUp: if (GUIUtility.hotControl != this.m_EffectInteractionControlID || current1.button != 0 || !p.stripRect.Contains(current1.mousePosition)) break; if (this.m_MovingEffectDstIndex != -1 && this.m_MovingEffectAllowed) { if (this.IsDuplicateKeyPressed() && this.CanDuplicateDraggedEffect()) { AudioMixerEffectController effect1 = this.m_MovingSrcGroup.controller.CopyEffect(this.m_MovingSrcGroup.effects[this.m_MovingEffectSrcIndex]); List<AudioMixerEffectController> list = ((IEnumerable<AudioMixerEffectController>) this.m_MovingDstGroup.effects).ToList<AudioMixerEffectController>(); if (AudioMixerController.InsertEffect(effect1, ref list, this.m_MovingEffectDstIndex)) this.m_MovingDstGroup.effects = list.ToArray(); } else if ((UnityEngine.Object) this.m_MovingSrcGroup == (UnityEngine.Object) this.m_MovingDstGroup) { List<AudioMixerEffectController> list = ((IEnumerable<AudioMixerEffectController>) this.m_MovingSrcGroup.effects).ToList<AudioMixerEffectController>(); if (AudioMixerController.MoveEffect(ref list, this.m_MovingEffectSrcIndex, ref list, this.m_MovingEffectDstIndex)) this.m_MovingSrcGroup.effects = list.ToArray(); } else if (!this.m_MovingSrcGroup.effects[this.m_MovingEffectSrcIndex].IsAttenuation()) { List<AudioMixerEffectController> list1 = ((IEnumerable<AudioMixerEffectController>) this.m_MovingSrcGroup.effects).ToList<AudioMixerEffectController>(); List<AudioMixerEffectController> list2 = ((IEnumerable<AudioMixerEffectController>) this.m_MovingDstGroup.effects).ToList<AudioMixerEffectController>(); if (AudioMixerController.MoveEffect(ref list1, this.m_MovingEffectSrcIndex, ref list2, this.m_MovingEffectDstIndex)) { this.m_MovingSrcGroup.effects = list1.ToArray(); this.m_MovingDstGroup.effects = list2.ToArray(); } } } this.ClearEffectDragging(ref highlightEffectIndex); current1.Use(); EditorGUIUtility.SetWantsMouseJumping(0); GUIUtility.ExitGUI(); break; case EventType.MouseDrag: if (GUIUtility.hotControl != this.m_EffectInteractionControlID) break; if (this.HasFocus() && this.m_WaitingForDragEvent) { this.m_ChangingWetMixIndex = -1; if (effectIndex < p.group.effects.Length) { if ((double) Mathf.Abs(current1.delta.y) > (double) Mathf.Abs(current1.delta.x)) { this.m_MovingEffectSrcIndex = effectIndex; this.ClearFocus(); } else this.m_ChangingWetMixIndex = this.m_IndexCounter; } this.m_WaitingForDragEvent = false; } if (this.IsMovingEffect() && p.stripRect.Contains(current1.mousePosition)) { float num1 = r.height * 0.5f; float num2 = effectIndex != 0 ? 0.0f : -num1; float num3 = effectIndex != p.group.effects.Length - 1 ? r.height : r.height + num1; float num4 = current1.mousePosition.y - r.y; if ((double) num4 >= (double) num2 && (double) num4 <= (double) num3 && effectIndex < p.group.effects.Length) { int targetIndex = (double) num4 >= (double) num1 ? effectIndex + 1 : effectIndex; if (targetIndex != this.m_MovingEffectDstIndex || (UnityEngine.Object) this.m_MovingDstGroup != (UnityEngine.Object) p.group) { this.m_MovingDstRect.x = r.x; this.m_MovingDstRect.width = r.width; this.m_MovingDstRect.y = (float) (((double) num4 >= (double) num1 ? (double) r.y + (double) r.height : (double) r.y) - 1.0); this.m_MovingEffectDstIndex = targetIndex; this.m_MovingDstGroup = p.group; this.m_MovingEffectAllowed = (!this.m_MovingSrcGroup.effects[this.m_MovingEffectSrcIndex].IsAttenuation() || !((UnityEngine.Object) this.m_MovingSrcGroup != (UnityEngine.Object) this.m_MovingDstGroup)) && !AudioMixerController.WillMovingEffectCauseFeedback(p.allGroups, this.m_MovingSrcGroup, this.m_MovingEffectSrcIndex, this.m_MovingDstGroup, targetIndex, (List<AudioMixerController.ConnectionNode>) null) && (!this.IsDuplicateKeyPressed() || this.CanDuplicateDraggedEffect()); } current1.Use(); } } if (!this.IsAdjustingWetMix() || !this.HasFocus() || !showLevel) break; this.m_WaitingForDragEvent = false; float num = Mathf.Clamp(AudioMixerChannelStripView.kEffectScaleMouseDrag * HandleUtility.niceMouseDelta + level, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect) - level; if ((double) num != 0.0) { Undo.RecordObject((UnityEngine.Object) this.m_Controller.TargetSnapshot, "Change effect level"); if (effect.IsSend() && this.m_Controller.CachedSelection.Count > 1 && this.m_Controller.CachedSelection.Contains(p.group)) { List<AudioMixerEffectController> effectControllerList = new List<AudioMixerEffectController>(); using (List<AudioMixerGroupController>.Enumerator enumerator = this.m_Controller.CachedSelection.GetEnumerator()) { while (enumerator.MoveNext()) { foreach (AudioMixerEffectController effect1 in enumerator.Current.effects) { if (effect1.effectName == effect.effectName && (UnityEngine.Object) effect1.sendTarget == (UnityEngine.Object) effect.sendTarget) effectControllerList.Add(effect1); } } } using (List<AudioMixerEffectController>.Enumerator enumerator = effectControllerList.GetEnumerator()) { while (enumerator.MoveNext()) { AudioMixerEffectController current2 = enumerator.Current; if (!current2.IsSend() || (UnityEngine.Object) current2.sendTarget != (UnityEngine.Object) null) current2.SetValueForMixLevel(this.m_Controller, snapshot, Mathf.Clamp(current2.GetValueForMixLevel(this.m_Controller, snapshot) + num, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect)); } } } else if (!effect.IsSend() || (UnityEngine.Object) effect.sendTarget != (UnityEngine.Object) null) effect.SetValueForMixLevel(this.m_Controller, snapshot, Mathf.Clamp(level + num, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect)); InspectorWindow.RepaintAllInspectors(); } current1.Use(); break; } }