Repaint the current view.
public void OnGUI(Rect position) { if (GradientEditor.s_Styles == null) { GradientEditor.s_Styles = new GradientEditor.Styles(); } float num = 16f; float num2 = 30f; float num3 = position.height - 2f * num - num2; position.height = num; this.ShowSwatchArray(position, this.m_AlphaSwatches, true); position.y += num; if (Event.current.type == EventType.Repaint) { position.height = num3; if (this.m_TextureDirty) { this.BuildTexture(); } GradientEditor.DrawGradientWithBackground(position, this.m_PreviewTex); } position.y += num3; position.height = num; this.ShowSwatchArray(position, this.m_RGBSwatches, false); if (this.m_SelectedSwatch != null) { position.y += num; position.height = num2; position.y += 10f; float num4 = 45f; float num5 = 60f; float num6 = 20f; float labelWidth = 50f; float num7 = num5 + num6 + num5 + num4; Rect position2 = position; position2.height = 18f; position2.x += 17f; position2.width -= num7; EditorGUIUtility.labelWidth = labelWidth; if (this.m_SelectedSwatch.m_IsAlpha) { EditorGUIUtility.fieldWidth = 30f; EditorGUI.BeginChangeCheck(); float num8 = (float)EditorGUI.IntSlider(position2, GradientEditor.s_Styles.alphaText, (int)(this.m_SelectedSwatch.m_Value.r * 255f), 0, 255) / 255f; if (EditorGUI.EndChangeCheck()) { num8 = Mathf.Clamp01(num8); this.m_SelectedSwatch.m_Value.r = (this.m_SelectedSwatch.m_Value.g = (this.m_SelectedSwatch.m_Value.b = num8)); this.AssignBack(); HandleUtility.Repaint(); } } else { EditorGUI.BeginChangeCheck(); this.m_SelectedSwatch.m_Value = EditorGUI.ColorField(position2, GradientEditor.s_Styles.colorText, this.m_SelectedSwatch.m_Value, true, false); if (EditorGUI.EndChangeCheck()) { this.AssignBack(); HandleUtility.Repaint(); } } position2.x += position2.width + num6; position2.width = num4 + num5; EditorGUIUtility.labelWidth = num5; string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString; EditorGUI.kFloatFieldFormatString = "f1"; EditorGUI.BeginChangeCheck(); float value = EditorGUI.FloatField(position2, GradientEditor.s_Styles.locationText, this.m_SelectedSwatch.m_Time * 100f) / 100f; if (EditorGUI.EndChangeCheck()) { this.m_SelectedSwatch.m_Time = Mathf.Clamp(value, 0f, 1f); this.AssignBack(); } EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString; position2.x += position2.width; position2.width = 20f; GUI.Label(position2, GradientEditor.s_Styles.percentText); } }
private void ShowSwatchArray(Rect position, List <GradientEditor.Swatch> swatches, bool isAlpha) { int controlID = GUIUtility.GetControlID(652347689, FocusType.Passive); Event current = Event.current; float time = this.GetTime((Event.current.mousePosition.x - position.x) / position.width); Vector2 point = new Vector3(position.x + time * position.width, Event.current.mousePosition.y); EventType typeForControl = current.GetTypeForControl(controlID); switch (typeForControl) { case EventType.MouseDown: { Rect rect = position; rect.xMin -= 10f; rect.xMax += 10f; if (rect.Contains(current.mousePosition)) { GUIUtility.hotControl = controlID; current.Use(); if (swatches.Contains(this.m_SelectedSwatch) && !this.m_SelectedSwatch.m_IsAlpha && this.CalcSwatchRect(position, this.m_SelectedSwatch).Contains(current.mousePosition)) { if (current.clickCount == 2) { GUIUtility.keyboardControl = controlID; ColorPicker.Show(GUIView.current, this.m_SelectedSwatch.m_Value, false, false, null); GUIUtility.ExitGUI(); } } else { bool flag = false; foreach (GradientEditor.Swatch current2 in swatches) { if (this.CalcSwatchRect(position, current2).Contains(point)) { flag = true; this.m_SelectedSwatch = current2; break; } } if (!flag) { if (swatches.Count < 8) { Color value = this.m_Gradient.Evaluate(time); if (isAlpha) { value = new Color(value.a, value.a, value.a, 1f); } else { value.a = 1f; } this.m_SelectedSwatch = new GradientEditor.Swatch(time, value, isAlpha); swatches.Add(this.m_SelectedSwatch); this.AssignBack(); } else { Debug.LogWarning(string.Concat(new object[] { "Max ", 8, " color keys and ", 8, " alpha keys are allowed in a gradient." })); } } } } return; } case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; current.Use(); if (!swatches.Contains(this.m_SelectedSwatch)) { this.m_SelectedSwatch = null; } this.RemoveDuplicateOverlappingSwatches(); } return; case EventType.MouseMove: case EventType.KeyUp: case EventType.ScrollWheel: IL_9B: if (typeForControl == EventType.ValidateCommand) { if (current.commandName == "Delete") { Event.current.Use(); } return; } if (typeForControl != EventType.ExecuteCommand) { return; } if (current.commandName == "ColorPickerChanged") { GUI.changed = true; this.m_SelectedSwatch.m_Value = ColorPicker.color; this.AssignBack(); HandleUtility.Repaint(); } else if (current.commandName == "Delete" && swatches.Count > 1) { swatches.Remove(this.m_SelectedSwatch); this.AssignBack(); HandleUtility.Repaint(); } return; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID && this.m_SelectedSwatch != null) { current.Use(); if (current.mousePosition.y + 5f < position.y || current.mousePosition.y - 5f > position.yMax) { if (swatches.Count > 1) { swatches.Remove(this.m_SelectedSwatch); this.AssignBack(); return; } } else if (!swatches.Contains(this.m_SelectedSwatch)) { swatches.Add(this.m_SelectedSwatch); } this.m_SelectedSwatch.m_Time = time; this.AssignBack(); } return; case EventType.KeyDown: if (current.keyCode == KeyCode.Delete) { if (this.m_SelectedSwatch != null) { List <GradientEditor.Swatch> list; if (this.m_SelectedSwatch.m_IsAlpha) { list = this.m_AlphaSwatches; } else { list = this.m_RGBSwatches; } if (list.Count > 1) { list.Remove(this.m_SelectedSwatch); this.AssignBack(); HandleUtility.Repaint(); } } current.Use(); } return; case EventType.Repaint: { bool flag2 = false; foreach (GradientEditor.Swatch current3 in swatches) { if (this.m_SelectedSwatch == current3) { flag2 = true; } else { this.DrawSwatch(position, current3, !isAlpha); } } if (flag2 && this.m_SelectedSwatch != null) { this.DrawSwatch(position, this.m_SelectedSwatch, !isAlpha); } return; } } goto IL_9B; }
private static void DrawObjectFieldLargeThumb(Rect position, int id, Object obj, GUIContent content) { GUIStyle thumbStyle = EditorStyles.objectFieldThumb; thumbStyle.Draw(position, GUIContent.none, id, DragAndDrop.activeControlID == id, position.Contains(Event.current.mousePosition)); if (obj != null && !showMixedValue) { bool isCubemap = obj is Cubemap; bool isSprite = obj is Sprite; Rect thumbRect = thumbStyle.padding.Remove(position); if (isCubemap || isSprite) { Texture2D t2d = AssetPreview.GetAssetPreview(obj); if (t2d != null) { if (isSprite || t2d.alphaIsTransparency) { DrawTextureTransparent(thumbRect, t2d); } else { DrawPreviewTexture(thumbRect, t2d); } } else { // Preview not loaded -> Draw icon thumbRect.x += (thumbRect.width - content.image.width) / 2f; thumbRect.y += (thumbRect.height - content.image.width) / 2f; GUIStyle.none.Draw(thumbRect, content.image, false, false, false, false); // Keep repaint until the object field has a proper preview HandleUtility.Repaint(); } } else { // Draw texture Texture2D t2d = content.image as Texture2D; if (t2d != null && t2d.alphaIsTransparency) { DrawTextureTransparent(thumbRect, t2d); } else { DrawPreviewTexture(thumbRect, content.image); } } } else { GUIStyle s2 = thumbStyle.name + "Overlay"; BeginHandleMixedValueContentColor(); s2.Draw(position, content, id); EndHandleMixedValueContentColor(); } GUIStyle s3 = thumbStyle.name + "Overlay2"; s3.Draw(position, s_Select, id); }
internal static Object DoDropField(Rect position, int id, System.Type objType, ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style) { if (validator == null) { validator = ValidateObjectFieldAssignment; } Event evt = Event.current; EventType eventType = evt.type; // special case test, so we continue to ping/select objects with the object field disabled if (!GUI.enabled && GUIClip.enabled && (Event.current.rawType == EventType.MouseDown)) { eventType = Event.current.rawType; } switch (eventType) { case EventType.DragExited: if (GUI.enabled) { HandleUtility.Repaint(); } break; case EventType.DragUpdated: case EventType.DragPerform: if (position.Contains(Event.current.mousePosition) && GUI.enabled) { Object[] references = DragAndDrop.objectReferences; Object validatedObject = validator(references, objType, null, ObjectFieldValidatorOptions.None); if (validatedObject != null) { // If scene objects are not allowed and object is a scene object then clear if (!allowSceneObjects && !EditorUtility.IsPersistent(validatedObject)) { validatedObject = null; } } if (validatedObject != null) { DragAndDrop.visualMode = DragAndDropVisualMode.Generic; if (eventType == EventType.DragPerform) { GUI.changed = true; DragAndDrop.AcceptDrag(); DragAndDrop.activeControlID = 0; Event.current.Use(); return(validatedObject); } else { DragAndDrop.activeControlID = id; Event.current.Use(); } } } break; case EventType.Repaint: style.Draw(position, GUIContent.none, id, DragAndDrop.activeControlID == id); break; } return(null); }
public bool DoTimeline(Rect timeRect) { bool result = false; this.Init(); this.m_Rect = timeRect; float num = this.m_TimeArea.PixelToTime(timeRect.xMin, timeRect); float num2 = this.m_TimeArea.PixelToTime(timeRect.xMax, timeRect); if (!Mathf.Approximately(num, this.StartTime)) { this.StartTime = num; GUI.changed = true; } if (!Mathf.Approximately(num2, this.StopTime)) { this.StopTime = num2; GUI.changed = true; } this.Time = Mathf.Max(this.Time, 0f); if (Event.current.type == EventType.Repaint) { this.m_TimeArea.rect = timeRect; } this.m_TimeArea.BeginViewGUI(); this.m_TimeArea.EndViewGUI(); GUI.BeginGroup(timeRect); Event current = Event.current; Rect rect = new Rect(0f, 0f, timeRect.width, timeRect.height); Rect position = new Rect(0f, 0f, timeRect.width, 18f); Rect position2 = new Rect(0f, 18f, timeRect.width, 132f); float num3 = this.m_TimeArea.TimeToPixel(this.SrcStartTime, rect); float num4 = this.m_TimeArea.TimeToPixel(this.SrcStopTime, rect); float num5 = this.m_TimeArea.TimeToPixel(this.DstStartTime, rect) + this.m_DstDragOffset; float num6 = this.m_TimeArea.TimeToPixel(this.DstStopTime, rect) + this.m_DstDragOffset; float num7 = this.m_TimeArea.TimeToPixel(this.TransitionStartTime, rect) + this.m_LeftThumbOffset; float num8 = this.m_TimeArea.TimeToPixel(this.TransitionStopTime, rect) + this.m_RightThumbOffset; float num9 = this.m_TimeArea.TimeToPixel(this.Time, rect); Rect rect2 = new Rect(num3, 85f, num4 - num3, 32f); Rect rect3 = new Rect(num5, 117f, num6 - num5, 32f); Rect position3 = new Rect(num7, 0f, num8 - num7, 18f); Rect position4 = new Rect(num7, 18f, num8 - num7, rect.height - 18f); Rect position5 = new Rect(num7 - 9f, 5f, 9f, 15f); Rect position6 = new Rect(num8, 5f, 9f, 15f); Rect position7 = new Rect(num9 - 7f, 4f, 15f, 15f); if (current.type == EventType.KeyDown) { if (GUIUtility.keyboardControl == this.id && this.m_DragState == Timeline.DragStates.Destination) { this.m_DstDragOffset = 0f; } if (this.m_DragState == Timeline.DragStates.LeftSelection) { this.m_LeftThumbOffset = 0f; } if (this.m_DragState == Timeline.DragStates.RightSelection) { this.m_RightThumbOffset = 0f; } if (this.m_DragState == Timeline.DragStates.FullSelection) { this.m_LeftThumbOffset = 0f; this.m_RightThumbOffset = 0f; } } if (current.type == EventType.MouseDown && rect.Contains(current.mousePosition)) { GUIUtility.hotControl = this.id; GUIUtility.keyboardControl = this.id; if (position7.Contains(current.mousePosition)) { this.m_DragState = Timeline.DragStates.Playhead; } else if (rect2.Contains(current.mousePosition)) { this.m_DragState = Timeline.DragStates.Source; } else if (rect3.Contains(current.mousePosition)) { this.m_DragState = Timeline.DragStates.Destination; } else if (position5.Contains(current.mousePosition)) { this.m_DragState = Timeline.DragStates.LeftSelection; } else if (position6.Contains(current.mousePosition)) { this.m_DragState = Timeline.DragStates.RightSelection; } else if (position3.Contains(current.mousePosition)) { this.m_DragState = Timeline.DragStates.FullSelection; } else if (position.Contains(current.mousePosition)) { this.m_DragState = Timeline.DragStates.TimeArea; } else if (position2.Contains(current.mousePosition)) { this.m_DragState = Timeline.DragStates.TimeArea; } else { this.m_DragState = Timeline.DragStates.None; } current.Use(); } if (current.type == EventType.MouseDrag && GUIUtility.hotControl == this.id) { switch (this.m_DragState) { case Timeline.DragStates.LeftSelection: if ((current.delta.x > 0f && current.mousePosition.x > num3) || (current.delta.x < 0f && current.mousePosition.x < num8)) { this.m_LeftThumbOffset += current.delta.x; } this.EnforceConstraints(); break; case Timeline.DragStates.RightSelection: if ((current.delta.x > 0f && current.mousePosition.x > num7) || current.delta.x < 0f) { this.m_RightThumbOffset += current.delta.x; } this.EnforceConstraints(); break; case Timeline.DragStates.FullSelection: this.m_RightThumbOffset += current.delta.x; this.m_LeftThumbOffset += current.delta.x; this.EnforceConstraints(); break; case Timeline.DragStates.Destination: this.m_DstDragOffset += current.delta.x; this.EnforceConstraints(); break; case Timeline.DragStates.Source: { TimeArea expr_499_cp_0 = this.m_TimeArea; expr_499_cp_0.m_Translation.x = expr_499_cp_0.m_Translation.x + current.delta.x; break; } case Timeline.DragStates.Playhead: if ((current.delta.x > 0f && current.mousePosition.x > num3) || (current.delta.x < 0f && current.mousePosition.x <= this.m_TimeArea.TimeToPixel(this.SampleStopTime, rect))) { this.Time = this.m_TimeArea.PixelToTime(num9 + current.delta.x, rect); } break; case Timeline.DragStates.TimeArea: { TimeArea expr_4C4_cp_0 = this.m_TimeArea; expr_4C4_cp_0.m_Translation.x = expr_4C4_cp_0.m_Translation.x + current.delta.x; break; } } current.Use(); GUI.changed = true; } if (current.type == EventType.MouseUp && GUIUtility.hotControl == this.id) { this.SrcStartTime = this.m_TimeArea.PixelToTime(num3, rect); this.SrcStopTime = this.m_TimeArea.PixelToTime(num4, rect); this.DstStartTime = this.m_TimeArea.PixelToTime(num5, rect); this.DstStopTime = this.m_TimeArea.PixelToTime(num6, rect); this.TransitionStartTime = this.m_TimeArea.PixelToTime(num7, rect); this.TransitionStopTime = this.m_TimeArea.PixelToTime(num8, rect); GUI.changed = true; this.m_DragState = Timeline.DragStates.None; result = this.WasDraggingData(); this.m_LeftThumbOffset = 0f; this.m_RightThumbOffset = 0f; this.m_DstDragOffset = 0f; GUIUtility.hotControl = 0; current.Use(); } GUI.Box(position, GUIContent.none, this.styles.header); GUI.Box(position2, GUIContent.none, this.styles.background); this.m_TimeArea.DrawMajorTicks(position2, 30f); GUIContent content = EditorGUIUtility.TempContent(this.SrcName); int num10 = (!this.srcLoop) ? 1 : (1 + (int)((num8 - rect2.xMin) / (rect2.xMax - rect2.xMin))); Rect position8 = rect2; if (rect2.width < 10f) { position8 = new Rect(rect2.x, rect2.y, (rect2.xMax - rect2.xMin) * (float)num10, rect2.height); num10 = 1; } for (int i = 0; i < num10; i++) { GUI.BeginGroup(position8, GUIContent.none, this.styles.leftBlock); float num11 = num7 - position8.xMin; float num12 = num8 - num7; float num13 = position8.xMax - position8.xMin - (num11 + num12); if (num11 > 0f) { GUI.Box(new Rect(0f, 0f, num11, rect2.height), GUIContent.none, this.styles.onLeft); } if (num12 > 0f) { GUI.Box(new Rect(num11, 0f, num12, rect2.height), GUIContent.none, this.styles.onOff); } if (num13 > 0f) { GUI.Box(new Rect(num11 + num12, 0f, num13, rect2.height), GUIContent.none, this.styles.offRight); } float b = 1f; float x = this.styles.block.CalcSize(content).x; float num14 = Mathf.Max(0f, num11) - 20f; float num15 = num14 + 15f; if (num14 < x && num15 > 0f && this.m_DragState == Timeline.DragStates.LeftSelection) { b = 0f; } GUI.EndGroup(); float a = this.styles.leftBlock.normal.textColor.a; if (!Mathf.Approximately(a, b) && Event.current.type == EventType.Repaint) { a = Mathf.Lerp(a, b, 0.1f); this.styles.leftBlock.normal.textColor = new Color(this.styles.leftBlock.normal.textColor.r, this.styles.leftBlock.normal.textColor.g, this.styles.leftBlock.normal.textColor.b, a); HandleUtility.Repaint(); } GUI.Box(position8, content, this.styles.leftBlock); position8 = new Rect(position8.xMax, 85f, position8.xMax - position8.xMin, 32f); } GUIContent content2 = EditorGUIUtility.TempContent(this.DstName); int num16 = (!this.dstLoop) ? 1 : (1 + (int)((num8 - rect3.xMin) / (rect3.xMax - rect3.xMin))); position8 = rect3; if (rect3.width < 10f) { position8 = new Rect(rect3.x, rect3.y, (rect3.xMax - rect3.xMin) * (float)num16, rect3.height); num16 = 1; } for (int j = 0; j < num16; j++) { GUI.BeginGroup(position8, GUIContent.none, this.styles.rightBlock); float num17 = num7 - position8.xMin; float num18 = num8 - num7; float num19 = position8.xMax - position8.xMin - (num17 + num18); if (num17 > 0f) { GUI.Box(new Rect(0f, 0f, num17, rect3.height), GUIContent.none, this.styles.offLeft); } if (num18 > 0f) { GUI.Box(new Rect(num17, 0f, num18, rect3.height), GUIContent.none, this.styles.offOn); } if (num19 > 0f) { GUI.Box(new Rect(num17 + num18, 0f, num19, rect3.height), GUIContent.none, this.styles.onRight); } float b2 = 1f; float x2 = this.styles.block.CalcSize(content2).x; float num20 = Mathf.Max(0f, num17) - 20f; float num21 = num20 + 15f; if (num20 < x2 && num21 > 0f && (this.m_DragState == Timeline.DragStates.LeftSelection || this.m_DragState == Timeline.DragStates.Destination)) { b2 = 0f; } GUI.EndGroup(); float a2 = this.styles.rightBlock.normal.textColor.a; if (!Mathf.Approximately(a2, b2) && Event.current.type == EventType.Repaint) { a2 = Mathf.Lerp(a2, b2, 0.1f); this.styles.rightBlock.normal.textColor = new Color(this.styles.rightBlock.normal.textColor.r, this.styles.rightBlock.normal.textColor.g, this.styles.rightBlock.normal.textColor.b, a2); HandleUtility.Repaint(); } GUI.Box(position8, content2, this.styles.rightBlock); position8 = new Rect(position8.xMax, position8.yMin, position8.xMax - position8.xMin, 32f); } GUI.Box(position4, GUIContent.none, this.styles.select); GUI.Box(position3, GUIContent.none, this.styles.selectHead); this.m_TimeArea.TimeRuler(position, 30f); GUI.Box(position5, GUIContent.none, (!this.m_HasExitTime) ? this.styles.handLeftPrev : this.styles.handLeft); GUI.Box(position6, GUIContent.none, this.styles.handRight); GUI.Box(position7, GUIContent.none, this.styles.playhead); Color color = Handles.color; Handles.color = Color.white; Handles.DrawLine(new Vector3(num9, 19f, 0f), new Vector3(num9, rect.height, 0f)); Handles.color = color; bool flag = this.SrcStopTime - this.SrcStartTime < 0.0333333351f; bool flag2 = this.DstStopTime - this.DstStartTime < 0.0333333351f; if (this.m_DragState == Timeline.DragStates.Destination && !flag2) { Rect position9 = new Rect(num7 - 50f, rect3.y, 45f, rect3.height); string t = string.Format("{0:0%}", (num7 - num5) / (num6 - num5)); GUI.Box(position9, EditorGUIUtility.TempContent(t), this.styles.timeBlockRight); } if (this.m_DragState == Timeline.DragStates.LeftSelection) { if (!flag) { Rect position10 = new Rect(num7 - 50f, rect2.y, 45f, rect2.height); string t2 = string.Format("{0:0%}", (num7 - num3) / (num4 - num3)); GUI.Box(position10, EditorGUIUtility.TempContent(t2), this.styles.timeBlockRight); } if (!flag2) { Rect position11 = new Rect(num7 - 50f, rect3.y, 45f, rect3.height); string t3 = string.Format("{0:0%}", (num7 - num5) / (num6 - num5)); GUI.Box(position11, EditorGUIUtility.TempContent(t3), this.styles.timeBlockRight); } } if (this.m_DragState == Timeline.DragStates.RightSelection) { if (!flag) { Rect position12 = new Rect(num8 + 5f, rect2.y, 45f, rect2.height); string t4 = string.Format("{0:0%}", (num8 - num3) / (num4 - num3)); GUI.Box(position12, EditorGUIUtility.TempContent(t4), this.styles.timeBlockLeft); } if (!flag2) { Rect position13 = new Rect(num8 + 5f, rect3.y, 45f, rect3.height); string t5 = string.Format("{0:0%}", (num8 - num5) / (num6 - num5)); GUI.Box(position13, EditorGUIUtility.TempContent(t5), this.styles.timeBlockLeft); } } this.DoPivotCurves(); GUI.EndGroup(); return(result); }
void ShowSwatchArray(Rect position, List <Swatch> swatches, bool isAlpha) { int id = GUIUtility.GetControlID(652347689, FocusType.Passive); Event evt = Event.current; float mouseSwatchTime = GetTime((Event.current.mousePosition.x - position.x) / position.width); Vector2 fixedStepMousePosition = new Vector3(position.x + mouseSwatchTime * position.width, Event.current.mousePosition.y); switch (evt.GetTypeForControl(id)) { case EventType.Repaint: { bool hasSelection = false; foreach (Swatch s in swatches) { if (m_SelectedSwatch == s) { hasSelection = true; continue; } DrawSwatch(position, s, !isAlpha); } // selected swatch drawn last if (hasSelection && m_SelectedSwatch != null) { DrawSwatch(position, m_SelectedSwatch, !isAlpha); } break; } case EventType.MouseDown: { Rect clickRect = position; // Swatches have some thickness thus we enlarge the clickable area clickRect.xMin -= 10; clickRect.xMax += 10; if (clickRect.Contains(evt.mousePosition)) { GUIUtility.hotControl = id; evt.Use(); // Make sure selected is topmost for the click if (swatches.Contains(m_SelectedSwatch) && !m_SelectedSwatch.m_IsAlpha && CalcSwatchRect(position, m_SelectedSwatch).Contains(evt.mousePosition)) { if (evt.clickCount == 2) { GUIUtility.keyboardControl = id; ColorPicker.Show(GUIView.current, m_SelectedSwatch.m_Value, false, m_HDR); GUIUtility.ExitGUI(); } break; } bool found = false; foreach (Swatch s in swatches) { if (CalcSwatchRect(position, s).Contains(fixedStepMousePosition)) { found = true; m_SelectedSwatch = s; break; } } if (!found) { if (swatches.Count < k_MaxNumKeys) { Color currentColor = m_Gradient.Evaluate(mouseSwatchTime); if (isAlpha) { currentColor = new Color(currentColor.a, currentColor.a, currentColor.a, 1f); } else { currentColor.a = 1f; } m_SelectedSwatch = new Swatch(mouseSwatchTime, currentColor, isAlpha); swatches.Add(m_SelectedSwatch); AssignBack(); } else { Debug.LogWarning("Max " + k_MaxNumKeys + " color keys and " + k_MaxNumKeys + " alpha keys are allowed in a gradient."); } } } break; } case EventType.MouseDrag: if (GUIUtility.hotControl == id && m_SelectedSwatch != null) { evt.Use(); // If user drags swatch outside in vertical direction, we'll remove the swatch if ((evt.mousePosition.y + 5 < position.y || evt.mousePosition.y - 5 > position.yMax)) { if (swatches.Count > 1) { swatches.Remove(m_SelectedSwatch); AssignBack(); break; } } else if (!swatches.Contains(m_SelectedSwatch)) { swatches.Add(m_SelectedSwatch); } m_SelectedSwatch.m_Time = mouseSwatchTime; AssignBack(); } break; case EventType.MouseUp: if (GUIUtility.hotControl == id) { GUIUtility.hotControl = 0; evt.Use(); // If the dragged swatch is NOT in the timeline, it means it was dragged outside. // We just forget about it and let GC get it later. if (!swatches.Contains(m_SelectedSwatch)) { m_SelectedSwatch = null; } // Remove duplicate keys on mouse up so that we do not kill any keys during the drag RemoveDuplicateOverlappingSwatches(); } break; case EventType.KeyDown: if (evt.keyCode == KeyCode.Delete) { if (m_SelectedSwatch != null) { List <Swatch> listToDeleteFrom; if (m_SelectedSwatch.m_IsAlpha) { listToDeleteFrom = m_AlphaSwatches; } else { listToDeleteFrom = m_RGBSwatches; } if (listToDeleteFrom.Count > 1) { listToDeleteFrom.Remove(m_SelectedSwatch); AssignBack(); HandleUtility.Repaint(); } } evt.Use(); } break; case EventType.ValidateCommand: if (evt.commandName == EventCommandNames.Delete) { Event.current.Use(); } break; case EventType.ExecuteCommand: if (evt.commandName == EventCommandNames.ColorPickerChanged) { GUI.changed = true; m_SelectedSwatch.m_Value = ColorPicker.color; AssignBack(); HandleUtility.Repaint(); } else if (evt.commandName == EventCommandNames.Delete) { if (swatches.Count > 1) { swatches.Remove(m_SelectedSwatch); AssignBack(); HandleUtility.Repaint(); } } break; } }
void Repaint() { HandleUtility.Repaint(); // repaints current guiview (needs rename) }
internal static Gradient DoGradientField(Rect position, int id, Gradient value, SerializedProperty property, bool hdr, ColorSpace space) { Event evt = Event.current; switch (evt.GetTypeForControl(id)) { case EventType.MouseDown: if (position.Contains(evt.mousePosition)) { if (evt.button == 0) { s_GradientID = id; GUIUtility.keyboardControl = id; Gradient gradient = property != null ? property.gradientValue : value; GradientPicker.Show(gradient, hdr, space); GUIUtility.ExitGUI(); } else if (evt.button == 1) { if (property != null) { GradientContextMenu.Show(property.Copy()); } // TODO: make work for Gradient value } } break; case EventType.Repaint: { Rect r2 = new Rect(position.x + 1, position.y + 1, position.width - 2, position.height - 2); // Adjust for box drawn on top if (property != null) { GradientEditor.DrawGradientSwatch(r2, property, Color.white, space); } else { GradientEditor.DrawGradientSwatch(r2, value, Color.white, space); } EditorStyles.colorPickerBox.Draw(position, GUIContent.none, id); break; } case EventType.ExecuteCommand: if (s_GradientID == id && evt.commandName == GradientPicker.GradientPickerChangedCommand) { GUI.changed = true; GradientPreviewCache.ClearCache(); HandleUtility.Repaint(); if (property != null) { property.gradientValue = GradientPicker.gradient; } return(GradientPicker.gradient); } break; case EventType.ValidateCommand: if (s_GradientID == id && evt.commandName == EventCommandNames.UndoRedoPerformed) { if (property != null) { GradientPicker.SetCurrentGradient(property.gradientValue); } GradientPreviewCache.ClearCache(); return(value); } break; case EventType.KeyDown: if (GUIUtility.keyboardControl == id && (evt.keyCode == KeyCode.Space || evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)) { Event.current.Use(); Gradient gradient = property != null ? property.gradientValue : value; GradientPicker.Show(gradient, hdr, space); GUIUtility.ExitGUI(); } break; } return(value); }
public bool DoTimeline(Rect timeRect) { bool flag1 = false; this.Init(); this.m_Rect = timeRect; float time1 = this.m_TimeArea.PixelToTime(timeRect.xMin, timeRect); float time2 = this.m_TimeArea.PixelToTime(timeRect.xMax, timeRect); if (!Mathf.Approximately(time1, this.StartTime)) { this.StartTime = time1; GUI.changed = true; } if (!Mathf.Approximately(time2, this.StopTime)) { this.StopTime = time2; GUI.changed = true; } this.Time = Mathf.Max(this.Time, 0.0f); if (Event.current.type == EventType.Repaint) { this.m_TimeArea.rect = timeRect; } this.m_TimeArea.BeginViewGUI(); this.m_TimeArea.EndViewGUI(); GUI.BeginGroup(timeRect); Event current = Event.current; Rect rect1 = new Rect(0.0f, 0.0f, timeRect.width, timeRect.height); Rect position1 = new Rect(0.0f, 0.0f, timeRect.width, 18f); Rect position2 = new Rect(0.0f, 18f, timeRect.width, 132f); float pixel1 = this.m_TimeArea.TimeToPixel(this.SrcStartTime, rect1); float pixel2 = this.m_TimeArea.TimeToPixel(this.SrcStopTime, rect1); float num1 = this.m_TimeArea.TimeToPixel(this.DstStartTime, rect1) + this.m_DstDragOffset; float pixelX = this.m_TimeArea.TimeToPixel(this.DstStopTime, rect1) + this.m_DstDragOffset; float num2 = this.m_TimeArea.TimeToPixel(this.TransitionStartTime, rect1) + this.m_LeftThumbOffset; float num3 = this.m_TimeArea.TimeToPixel(this.TransitionStopTime, rect1) + this.m_RightThumbOffset; float pixel3 = this.m_TimeArea.TimeToPixel(this.Time, rect1); Rect rect2 = new Rect(pixel1, 85f, pixel2 - pixel1, 32f); Rect rect3 = new Rect(num1, 117f, pixelX - num1, 32f); Rect position3 = new Rect(num2, 0.0f, num3 - num2, 18f); Rect position4 = new Rect(num2, 18f, num3 - num2, rect1.height - 18f); Rect position5 = new Rect(num2 - 9f, 5f, 9f, 15f); Rect position6 = new Rect(num3, 5f, 9f, 15f); Rect position7 = new Rect(pixel3 - 7f, 4f, 15f, 15f); if (current.type == EventType.KeyDown) { if (GUIUtility.keyboardControl == this.id && this.m_DragState == Timeline.DragStates.Destination) { this.m_DstDragOffset = 0.0f; } if (this.m_DragState == Timeline.DragStates.LeftSelection) { this.m_LeftThumbOffset = 0.0f; } if (this.m_DragState == Timeline.DragStates.RightSelection) { this.m_RightThumbOffset = 0.0f; } if (this.m_DragState == Timeline.DragStates.FullSelection) { this.m_LeftThumbOffset = 0.0f; this.m_RightThumbOffset = 0.0f; } } if (current.type == EventType.MouseDown && rect1.Contains(current.mousePosition)) { GUIUtility.hotControl = this.id; GUIUtility.keyboardControl = this.id; this.m_DragState = !position7.Contains(current.mousePosition) ? (!rect2.Contains(current.mousePosition) ? (!rect3.Contains(current.mousePosition) ? (!position5.Contains(current.mousePosition) ? (!position6.Contains(current.mousePosition) ? (!position3.Contains(current.mousePosition) ? (!position1.Contains(current.mousePosition) ? (!position2.Contains(current.mousePosition) ? Timeline.DragStates.None : Timeline.DragStates.TimeArea) : Timeline.DragStates.TimeArea) : Timeline.DragStates.FullSelection) : Timeline.DragStates.RightSelection) : Timeline.DragStates.LeftSelection) : Timeline.DragStates.Destination) : Timeline.DragStates.Source) : Timeline.DragStates.Playhead; current.Use(); } if (current.type == EventType.MouseDrag && GUIUtility.hotControl == this.id) { switch (this.m_DragState) { case Timeline.DragStates.LeftSelection: if ((double)current.delta.x > 0.0 && (double)current.mousePosition.x > (double)pixel1 || (double)current.delta.x < 0.0 && (double)current.mousePosition.x < (double)num3) { this.m_LeftThumbOffset += current.delta.x; } this.EnforceConstraints(); break; case Timeline.DragStates.RightSelection: if ((double)current.delta.x > 0.0 && (double)current.mousePosition.x > (double)num2 || (double)current.delta.x < 0.0) { this.m_RightThumbOffset += current.delta.x; } this.EnforceConstraints(); break; case Timeline.DragStates.FullSelection: this.m_RightThumbOffset += current.delta.x; this.m_LeftThumbOffset += current.delta.x; this.EnforceConstraints(); break; case Timeline.DragStates.Destination: this.m_DstDragOffset += current.delta.x; this.EnforceConstraints(); break; case Timeline.DragStates.Source: this.m_TimeArea.m_Translation.x += current.delta.x; break; case Timeline.DragStates.Playhead: if ((double)current.delta.x > 0.0 && (double)current.mousePosition.x > (double)pixel1 || (double)current.delta.x < 0.0 && (double)current.mousePosition.x <= (double)this.m_TimeArea.TimeToPixel(this.SampleStopTime, rect1)) { this.Time = this.m_TimeArea.PixelToTime(pixel3 + current.delta.x, rect1); break; } break; case Timeline.DragStates.TimeArea: this.m_TimeArea.m_Translation.x += current.delta.x; break; } current.Use(); GUI.changed = true; } if (current.type == EventType.MouseUp && GUIUtility.hotControl == this.id) { this.SrcStartTime = this.m_TimeArea.PixelToTime(pixel1, rect1); this.SrcStopTime = this.m_TimeArea.PixelToTime(pixel2, rect1); this.DstStartTime = this.m_TimeArea.PixelToTime(num1, rect1); this.DstStopTime = this.m_TimeArea.PixelToTime(pixelX, rect1); this.TransitionStartTime = this.m_TimeArea.PixelToTime(num2, rect1); this.TransitionStopTime = this.m_TimeArea.PixelToTime(num3, rect1); GUI.changed = true; this.m_DragState = Timeline.DragStates.None; flag1 = this.WasDraggingData(); this.m_LeftThumbOffset = 0.0f; this.m_RightThumbOffset = 0.0f; this.m_DstDragOffset = 0.0f; GUIUtility.hotControl = 0; current.Use(); } GUI.Box(position1, GUIContent.none, this.styles.header); GUI.Box(position2, GUIContent.none, this.styles.background); this.m_TimeArea.DrawMajorTicks(position2, 30f); GUIContent content1 = EditorGUIUtility.TempContent(this.SrcName); int num4 = !this.srcLoop ? 1 : 1 + (int)(((double)num3 - (double)rect2.xMin) / ((double)rect2.xMax - (double)rect2.xMin)); Rect position8 = rect2; if ((double)rect2.width < 10.0) { position8 = new Rect(rect2.x, rect2.y, (rect2.xMax - rect2.xMin) * (float)num4, rect2.height); num4 = 1; } for (int index = 0; index < num4; ++index) { GUI.BeginGroup(position8, GUIContent.none, this.styles.leftBlock); float num5 = num2 - position8.xMin; float width1 = num3 - num2; float width2 = (float)((double)position8.xMax - (double)position8.xMin - ((double)num5 + (double)width1)); if ((double)num5 > 0.0) { GUI.Box(new Rect(0.0f, 0.0f, num5, rect2.height), GUIContent.none, this.styles.onLeft); } if ((double)width1 > 0.0) { GUI.Box(new Rect(num5, 0.0f, width1, rect2.height), GUIContent.none, this.styles.onOff); } if ((double)width2 > 0.0) { GUI.Box(new Rect(num5 + width1, 0.0f, width2, rect2.height), GUIContent.none, this.styles.offRight); } float b = 1f; float x = this.styles.block.CalcSize(content1).x; float num6 = Mathf.Max(0.0f, num5) - 20f; float num7 = num6 + 15f; if ((double)num6 < (double)x && (double)num7 > 0.0 && this.m_DragState == Timeline.DragStates.LeftSelection) { b = 0.0f; } GUI.EndGroup(); float a = this.styles.leftBlock.normal.textColor.a; if (!Mathf.Approximately(a, b) && Event.current.type == EventType.Repaint) { this.styles.leftBlock.normal.textColor = new Color(this.styles.leftBlock.normal.textColor.r, this.styles.leftBlock.normal.textColor.g, this.styles.leftBlock.normal.textColor.b, Mathf.Lerp(a, b, 0.1f)); HandleUtility.Repaint(); } GUI.Box(position8, content1, this.styles.leftBlock); position8 = new Rect(position8.xMax, 85f, position8.xMax - position8.xMin, 32f); } GUIContent content2 = EditorGUIUtility.TempContent(this.DstName); int num8 = !this.dstLoop ? 1 : 1 + (int)(((double)num3 - (double)rect3.xMin) / ((double)rect3.xMax - (double)rect3.xMin)); position8 = rect3; if ((double)rect3.width < 10.0) { position8 = new Rect(rect3.x, rect3.y, (rect3.xMax - rect3.xMin) * (float)num8, rect3.height); num8 = 1; } for (int index = 0; index < num8; ++index) { GUI.BeginGroup(position8, GUIContent.none, this.styles.rightBlock); float num5 = num2 - position8.xMin; float width1 = num3 - num2; float width2 = (float)((double)position8.xMax - (double)position8.xMin - ((double)num5 + (double)width1)); if ((double)num5 > 0.0) { GUI.Box(new Rect(0.0f, 0.0f, num5, rect3.height), GUIContent.none, this.styles.offLeft); } if ((double)width1 > 0.0) { GUI.Box(new Rect(num5, 0.0f, width1, rect3.height), GUIContent.none, this.styles.offOn); } if ((double)width2 > 0.0) { GUI.Box(new Rect(num5 + width1, 0.0f, width2, rect3.height), GUIContent.none, this.styles.onRight); } float b = 1f; float x = this.styles.block.CalcSize(content2).x; float num6 = Mathf.Max(0.0f, num5) - 20f; float num7 = num6 + 15f; if ((double)num6 < (double)x && (double)num7 > 0.0 && (this.m_DragState == Timeline.DragStates.LeftSelection || this.m_DragState == Timeline.DragStates.Destination)) { b = 0.0f; } GUI.EndGroup(); float a = this.styles.rightBlock.normal.textColor.a; if (!Mathf.Approximately(a, b) && Event.current.type == EventType.Repaint) { this.styles.rightBlock.normal.textColor = new Color(this.styles.rightBlock.normal.textColor.r, this.styles.rightBlock.normal.textColor.g, this.styles.rightBlock.normal.textColor.b, Mathf.Lerp(a, b, 0.1f)); HandleUtility.Repaint(); } GUI.Box(position8, content2, this.styles.rightBlock); position8 = new Rect(position8.xMax, position8.yMin, position8.xMax - position8.xMin, 32f); } GUI.Box(position4, GUIContent.none, this.styles.select); GUI.Box(position3, GUIContent.none, this.styles.selectHead); this.m_TimeArea.TimeRuler(position1, 30f); GUI.Box(position5, GUIContent.none, !this.m_HasExitTime ? this.styles.handLeftPrev : this.styles.handLeft); GUI.Box(position6, GUIContent.none, this.styles.handRight); GUI.Box(position7, GUIContent.none, this.styles.playhead); Color color = Handles.color; Handles.color = Color.white; Handles.DrawLine(new Vector3(pixel3, 19f, 0.0f), new Vector3(pixel3, rect1.height, 0.0f)); Handles.color = color; bool flag2 = (double)this.SrcStopTime - (double)this.SrcStartTime < 0.0333333350718021; bool flag3 = (double)this.DstStopTime - (double)this.DstStartTime < 0.0333333350718021; if (this.m_DragState == Timeline.DragStates.Destination && !flag3) { GUI.Box(new Rect(num2 - 50f, rect3.y, 45f, rect3.height), EditorGUIUtility.TempContent(string.Format("{0:0%}", (object)(float)(((double)num2 - (double)num1) / ((double)pixelX - (double)num1)))), this.styles.timeBlockRight); } if (this.m_DragState == Timeline.DragStates.LeftSelection) { if (!flag2) { GUI.Box(new Rect(num2 - 50f, rect2.y, 45f, rect2.height), EditorGUIUtility.TempContent(string.Format("{0:0%}", (object)(float)(((double)num2 - (double)pixel1) / ((double)pixel2 - (double)pixel1)))), this.styles.timeBlockRight); } if (!flag3) { GUI.Box(new Rect(num2 - 50f, rect3.y, 45f, rect3.height), EditorGUIUtility.TempContent(string.Format("{0:0%}", (object)(float)(((double)num2 - (double)num1) / ((double)pixelX - (double)num1)))), this.styles.timeBlockRight); } } if (this.m_DragState == Timeline.DragStates.RightSelection) { if (!flag2) { GUI.Box(new Rect(num3 + 5f, rect2.y, 45f, rect2.height), EditorGUIUtility.TempContent(string.Format("{0:0%}", (object)(float)(((double)num3 - (double)pixel1) / ((double)pixel2 - (double)pixel1)))), this.styles.timeBlockLeft); } if (!flag3) { GUI.Box(new Rect(num3 + 5f, rect3.y, 45f, rect3.height), EditorGUIUtility.TempContent(string.Format("{0:0%}", (object)(float)(((double)num3 - (double)num1) / ((double)pixelX - (double)num1)))), this.styles.timeBlockLeft); } } this.DoPivotCurves(); GUI.EndGroup(); return(flag1); }
private void ShowSwatchArray(Rect position, List <Swatch> swatches, bool isAlpha) { bool flag2; int controlID = GUIUtility.GetControlID(0x26e20929, FocusType.Passive); Event current = Event.current; float time = this.GetTime((Event.current.mousePosition.x - position.x) / position.width); Vector2 point = new Vector3(position.x + (time * position.width), Event.current.mousePosition.y); EventType typeForControl = current.GetTypeForControl(controlID); switch (typeForControl) { case EventType.MouseDown: { Rect rect = position; rect.xMin -= 10f; rect.xMax += 10f; if (rect.Contains(current.mousePosition)) { GUIUtility.hotControl = controlID; current.Use(); if ((!swatches.Contains(this.m_SelectedSwatch) || this.m_SelectedSwatch.m_IsAlpha) || !this.CalcSwatchRect(position, this.m_SelectedSwatch).Contains(current.mousePosition)) { flag2 = false; foreach (Swatch swatch2 in swatches) { if (this.CalcSwatchRect(position, swatch2).Contains(point)) { flag2 = true; this.m_SelectedSwatch = swatch2; break; } } break; } if (current.clickCount == 2) { GUIUtility.keyboardControl = controlID; ColorPicker.Show(GUIView.current, this.m_SelectedSwatch.m_Value, false, false, null); GUIUtility.ExitGUI(); } } return; } case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; current.Use(); if (!swatches.Contains(this.m_SelectedSwatch)) { this.m_SelectedSwatch = null; } this.RemoveDuplicateOverlappingSwatches(); } return; case EventType.MouseDrag: if ((GUIUtility.hotControl == controlID) && (this.m_SelectedSwatch != null)) { current.Use(); if (((current.mousePosition.y + 5f) >= position.y) && ((current.mousePosition.y - 5f) <= position.yMax)) { if (!swatches.Contains(this.m_SelectedSwatch)) { swatches.Add(this.m_SelectedSwatch); } goto Label_03B1; } if (swatches.Count <= 1) { goto Label_03B1; } swatches.Remove(this.m_SelectedSwatch); this.AssignBack(); } return; case EventType.KeyDown: if (current.keyCode == KeyCode.Delete) { if (this.m_SelectedSwatch != null) { List <Swatch> rGBSwatches; if (!this.m_SelectedSwatch.m_IsAlpha) { rGBSwatches = this.m_RGBSwatches; } else { rGBSwatches = this.m_AlphaSwatches; } if (rGBSwatches.Count > 1) { rGBSwatches.Remove(this.m_SelectedSwatch); this.AssignBack(); HandleUtility.Repaint(); } } current.Use(); } return; case EventType.Repaint: { bool flag = false; foreach (Swatch swatch in swatches) { if (this.m_SelectedSwatch == swatch) { flag = true; } else { this.DrawSwatch(position, swatch, !isAlpha); } } if (flag && (this.m_SelectedSwatch != null)) { this.DrawSwatch(position, this.m_SelectedSwatch, !isAlpha); } return; } default: switch (typeForControl) { case EventType.ValidateCommand: if (current.commandName == "Delete") { Event.current.Use(); } return; case EventType.ExecuteCommand: if (current.commandName == "ColorPickerChanged") { GUI.changed = true; this.m_SelectedSwatch.m_Value = ColorPicker.color; this.AssignBack(); HandleUtility.Repaint(); } else if ((current.commandName == "Delete") && (swatches.Count > 1)) { swatches.Remove(this.m_SelectedSwatch); this.AssignBack(); HandleUtility.Repaint(); } return; default: return; } break; } if (!flag2) { if (swatches.Count < 8) { Color color = this.m_Gradient.Evaluate(time); if (isAlpha) { color = new Color(color.a, color.a, color.a, 1f); } else { color.a = 1f; } this.m_SelectedSwatch = new Swatch(time, color, isAlpha); swatches.Add(this.m_SelectedSwatch); this.AssignBack(); } else { Debug.LogWarning(string.Concat(new object[] { "Max ", 8, " color keys and ", 8, " alpha keys are allowed in a gradient." })); } } return; Label_03B1: this.m_SelectedSwatch.m_Time = time; this.AssignBack(); }
public void DoEffectGUI(int effectIndex, AudioMixerGroupController group, List <AudioMixerGroupController> allGroups, Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap, ref int highlightEffectIndex) { Event evt = Event.current; AudioMixerController controller = group.controller; AudioMixerEffectController effect = group.effects[effectIndex]; MixerParameterDefinition[] paramDefs = MixerEffectDefinitions.GetEffectParameters(effect.effectName); // This rect is valid after every layout event Rect totalRect = EditorGUILayout.BeginVertical(); bool hovering = totalRect.Contains(evt.mousePosition); EventType evtType = evt.GetTypeForControl(m_EffectDragging.dragControlID); if (evtType == EventType.MouseMove && hovering && highlightEffectIndex != effectIndex) { highlightEffectIndex = effectIndex; AudioMixerUtility.RepaintAudioMixerAndInspectors(); } // Header const float colorCodeWidth = 6f; var gearSize = EditorStyles.iconButton.CalcSize(EditorGUI.GUIContents.titleSettingsIcon); Rect headerRect = GUILayoutUtility.GetRect(1, 17f); Rect colorCodeRect = new Rect(headerRect.x + 6f, headerRect.y + 5f, colorCodeWidth, colorCodeWidth); Rect labelRect = new Rect(headerRect.x + 8f + colorCodeWidth, headerRect.y, headerRect.width - 8f - colorCodeWidth - gearSize.x - 5f, headerRect.height); Rect gearRect = new Rect(labelRect.xMax, headerRect.y, gearSize.x, gearSize.y); Rect dragRect = new Rect(headerRect.x, headerRect.y, headerRect.width - gearSize.x - 5f, headerRect.height); { bool showCPU = EditorPrefs.GetBool(AudioMixerGroupEditor.kPrefKeyForShowCpuUsage, false) && EditorUtility.audioProfilingEnabled; float val = EditorGUIUtility.isProSkin ? 0.1f : 1.0f; Color headerColor = new Color(val, val, val, 0.2f); Color origColor = GUI.color; GUI.color = headerColor; GUI.DrawTexture(headerRect, EditorGUIUtility.whiteTexture); GUI.color = origColor; Color effectColorCode = AudioMixerDrawUtils.GetEffectColor(effect); EditorGUI.DrawRect(colorCodeRect, effectColorCode); GUI.Label(labelRect, showCPU ? effect.effectName + string.Format(Texts.cpuFormatString, effect.GetCPUUsage(controller)) : effect.effectName, EditorStyles.boldLabel); if (EditorGUI.DropdownButton(gearRect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.iconButton)) { ShowEffectContextMenu(group, effect, effectIndex, controller, gearRect); } // Show context menu if right clicking in header rect (for convenience) if (evt.type == EventType.ContextClick && headerRect.Contains(evt.mousePosition)) { ShowEffectContextMenu(group, effect, effectIndex, controller, new Rect(evt.mousePosition.x, headerRect.y, 1, headerRect.height)); evt.Use(); } if (evtType == EventType.Repaint) { EditorGUIUtility.AddCursorRect(dragRect, MouseCursor.ResizeVertical, m_EffectDragging.dragControlID); } } using (new EditorGUI.DisabledScope(effect.bypass || group.bypassEffects)) { EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins); if (effect.IsAttenuation()) { EditorGUILayout.BeginVertical(); float value = group.GetValueForVolume(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(Texts.volume, ref value, 1.0f, 1.0f, Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume(), controller, new AudioGroupParameterPath(group, group.GetGUIDForVolume()))) { Undo.RecordObject(controller.TargetSnapshot, "Change Volume Fader"); group.SetValueForVolume(controller, controller.TargetSnapshot, value); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } //FIXME // 1) The VUMeter used is not in the same style that fits the rest of the Audio UI // 2) The layout of the VU meters is hacked together and a lot of magic numbers are used. int numChannels = 0; float[] vuinfo_level = new float[9]; float[] vuinfo_peak = new float[9]; numChannels = group.controller.GetGroupVUInfo(group.groupID, true, vuinfo_level, vuinfo_peak); if (evt.type == EventType.Layout) { m_LastNumChannels = numChannels; } else { if (numChannels != m_LastNumChannels) { HandleUtility.Repaint(); // Repaint to ensure correct rendered num channels } // Ensure same num channels as in layout event to not break IMGUI controlID handling numChannels = m_LastNumChannels; } GUILayout.Space(4f); for (int c = 0; c < numChannels; ++c) { float level = 1 - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(vuinfo_level[c], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1, true); float peak = 1 - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(vuinfo_peak[c], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1, true); EditorGUILayout.VUMeterHorizontal(level, peak, GUILayout.Height(10)); //This allows the meters to drop to 0 after PlayMode has stopped. if (!EditorApplication.isPlaying && peak > 0.0F) { AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } GUILayout.Space(4f); EditorGUILayout.EndVertical(); } if (effect.IsSend()) { Rect buttonRect; GUIContent buttonContent = (effect.sendTarget == null) ? Texts.none : GUIContent.Temp(effect.GetSendTargetDisplayString(effectMap)); if (AudioMixerEffectGUI.PopupButton(Texts.bus, buttonContent, EditorStyles.popup, out buttonRect)) { ShowBusPopupMenu(effectIndex, @group, allGroups, effectMap, effect, buttonRect); } if (effect.sendTarget != null) { float wetLevel = effect.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(Texts.sendLevel, ref wetLevel, 1.0f, 1.0f, Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioGroupParameterPath(group, group.GetGUIDForSend()))) { Undo.RecordObject(controller.TargetSnapshot, "Change Send Level"); effect.SetValueForMixLevel(controller, controller.TargetSnapshot, wetLevel); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } } if (MixerEffectDefinitions.EffectCanBeSidechainTarget(effect)) { bool anyTargetsFound = false; foreach (var g in allGroups) { foreach (var e in g.effects) { if (e.IsSend() && e.sendTarget == effect) { anyTargetsFound = true; break; } } if (anyTargetsFound) { break; } } if (!anyTargetsFound) { GUILayout.Label(EditorGUIUtility.TrTextContent("No Send sources connected.", EditorGUIUtility.warningIcon)); } } // Wet mix if (effect.enableWetMix && !effect.IsReceive() && !effect.IsDuckVolume() && !effect.IsAttenuation() && !effect.IsSend()) { float wetLevel = effect.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(Texts.wet, ref wetLevel, 1.0f, 1.0f, Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioEffectParameterPath(group, effect, effect.GetGUIDForMixLevel()))) { Undo.RecordObject(controller.TargetSnapshot, "Change Mix Level"); effect.SetValueForMixLevel(controller, controller.TargetSnapshot, wetLevel); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } // All other effects bool drawDefaultGUI = true; if (m_CustomEffectGUIs.ContainsKey(effect.effectName)) { var customGUI = m_CustomEffectGUIs[effect.effectName]; m_SharedPlugin.m_Controller = controller; m_SharedPlugin.m_Effect = effect; m_SharedPlugin.m_ParamDefs = paramDefs; drawDefaultGUI = customGUI.OnGUI(m_SharedPlugin); } if (drawDefaultGUI) { foreach (var p in paramDefs) { float value = effect.GetValueForParameter(controller, controller.TargetSnapshot, p.name); if (AudioMixerEffectGUI.Slider(GUIContent.Temp(p.name, p.description), ref value, p.displayScale, p.displayExponent, p.units, p.minRange, p.maxRange, controller, new AudioEffectParameterPath(group, effect, effect.GetGUIDForParameter(p.name)))) { Undo.RecordObject(controller.TargetSnapshot, "Change " + p.name); effect.SetValueForParameter(controller, controller.TargetSnapshot, p.name, value); } } if (paramDefs.Length > 0) { GUILayout.Space(6f); } } } m_EffectDragging.HandleDragElement(effectIndex, totalRect, dragRect, group, allGroups); EditorGUILayout.EndVertical(); // indented effect contents EditorGUILayout.EndVertical(); // calc total size AudioMixerDrawUtils.DrawSplitter(); }
public bool DoTimeline(Rect timeRect) { bool flag = false; this.Init(); this.m_Rect = timeRect; float a = this.m_TimeArea.PixelToTime(timeRect.xMin, timeRect); float num2 = this.m_TimeArea.PixelToTime(timeRect.xMax, timeRect); if (!Mathf.Approximately(a, this.StartTime)) { this.StartTime = a; GUI.changed = true; } if (!Mathf.Approximately(num2, this.StopTime)) { this.StopTime = num2; GUI.changed = true; } this.Time = Mathf.Max(this.Time, 0f); if (Event.current.type == EventType.Repaint) { this.m_TimeArea.rect = timeRect; } this.m_TimeArea.BeginViewGUI(); this.m_TimeArea.EndViewGUI(); GUI.BeginGroup(timeRect); Event current = Event.current; Rect rect = new Rect(0f, 0f, timeRect.width, timeRect.height); Rect position = new Rect(0f, 0f, timeRect.width, 18f); Rect rect3 = new Rect(0f, 18f, timeRect.width, 132f); float x = this.m_TimeArea.TimeToPixel(this.SrcStartTime, rect); float pixelX = this.m_TimeArea.TimeToPixel(this.SrcStopTime, rect); float num5 = this.m_TimeArea.TimeToPixel(this.DstStartTime, rect) + this.m_DstDragOffset; float num6 = this.m_TimeArea.TimeToPixel(this.DstStopTime, rect) + this.m_DstDragOffset; float num7 = this.m_TimeArea.TimeToPixel(this.TransitionStartTime, rect) + this.m_LeftThumbOffset; float num8 = this.m_TimeArea.TimeToPixel(this.TransitionStopTime, rect) + this.m_RightThumbOffset; float num9 = this.m_TimeArea.TimeToPixel(this.Time, rect); Rect rect4 = new Rect(x, 85f, pixelX - x, 32f); Rect rect5 = new Rect(num5, 117f, num6 - num5, 32f); Rect rect6 = new Rect(num7, 0f, num8 - num7, 18f); Rect rect7 = new Rect(num7, 18f, num8 - num7, rect.height - 18f); Rect rect8 = new Rect(num7 - 9f, 5f, 9f, 15f); Rect rect9 = new Rect(num8, 5f, 9f, 15f); Rect rect10 = new Rect(num9 - 7f, 4f, 15f, 15f); if (current.type == EventType.KeyDown) { if ((GUIUtility.keyboardControl == this.id) && (this.m_DragState == DragStates.Destination)) { this.m_DstDragOffset = 0f; } if (this.m_DragState == DragStates.LeftSelection) { this.m_LeftThumbOffset = 0f; } if (this.m_DragState == DragStates.RightSelection) { this.m_RightThumbOffset = 0f; } if (this.m_DragState == DragStates.FullSelection) { this.m_LeftThumbOffset = 0f; this.m_RightThumbOffset = 0f; } } if ((current.type == EventType.MouseDown) && rect.Contains(current.mousePosition)) { GUIUtility.hotControl = this.id; GUIUtility.keyboardControl = this.id; if (rect10.Contains(current.mousePosition)) { this.m_DragState = DragStates.Playhead; } else if (rect4.Contains(current.mousePosition)) { this.m_DragState = DragStates.Source; } else if (rect5.Contains(current.mousePosition)) { this.m_DragState = DragStates.Destination; } else if (rect8.Contains(current.mousePosition)) { this.m_DragState = DragStates.LeftSelection; } else if (rect9.Contains(current.mousePosition)) { this.m_DragState = DragStates.RightSelection; } else if (rect6.Contains(current.mousePosition)) { this.m_DragState = DragStates.FullSelection; } else if (position.Contains(current.mousePosition)) { this.m_DragState = DragStates.TimeArea; } else if (rect3.Contains(current.mousePosition)) { this.m_DragState = DragStates.TimeArea; } else { this.m_DragState = DragStates.None; } current.Use(); } if ((current.type == EventType.MouseDrag) && (GUIUtility.hotControl == this.id)) { switch (this.m_DragState) { case DragStates.LeftSelection: if (((current.delta.x > 0f) && (current.mousePosition.x > x)) || ((current.delta.x < 0f) && (current.mousePosition.x < num8))) { this.m_LeftThumbOffset += current.delta.x; } this.EnforceConstraints(); break; case DragStates.RightSelection: if (((current.delta.x > 0f) && (current.mousePosition.x > num7)) || (current.delta.x < 0f)) { this.m_RightThumbOffset += current.delta.x; } this.EnforceConstraints(); break; case DragStates.FullSelection: this.m_RightThumbOffset += current.delta.x; this.m_LeftThumbOffset += current.delta.x; this.EnforceConstraints(); break; case DragStates.Destination: this.m_DstDragOffset += current.delta.x; this.EnforceConstraints(); break; case DragStates.Source: this.m_TimeArea.m_Translation.x += current.delta.x; break; case DragStates.Playhead: this.Time = this.m_TimeArea.PixelToTime(num9 + current.delta.x, rect); break; case DragStates.TimeArea: this.m_TimeArea.m_Translation.x += current.delta.x; break; } current.Use(); GUI.changed = true; } if ((current.type == EventType.MouseUp) && (GUIUtility.hotControl == this.id)) { this.SrcStartTime = this.m_TimeArea.PixelToTime(x, rect); this.SrcStopTime = this.m_TimeArea.PixelToTime(pixelX, rect); this.DstStartTime = this.m_TimeArea.PixelToTime(num5, rect); this.DstStopTime = this.m_TimeArea.PixelToTime(num6, rect); this.TransitionStartTime = this.m_TimeArea.PixelToTime(num7, rect); this.TransitionStopTime = this.m_TimeArea.PixelToTime(num8, rect); GUI.changed = true; this.m_DragState = DragStates.None; flag = this.WasDraggingData(); this.m_LeftThumbOffset = 0f; this.m_RightThumbOffset = 0f; this.m_DstDragOffset = 0f; GUIUtility.hotControl = 0; current.Use(); } GUI.Box(position, GUIContent.none, this.styles.header); GUI.Box(rect3, GUIContent.none, this.styles.background); this.m_TimeArea.DrawMajorTicks(rect3, 30f); GUIContent content = EditorGUIUtility.TempContent(this.SrcName); int num10 = !this.srcLoop ? 1 : (1 + ((int)((num8 - rect4.xMin) / (rect4.xMax - rect4.xMin)))); Rect rect11 = rect4; if (rect4.width < 10f) { rect11 = new Rect(rect4.x, rect4.y, (rect4.xMax - rect4.xMin) * num10, rect4.height); num10 = 1; } for (int i = 0; i < num10; i++) { GUI.BeginGroup(rect11, GUIContent.none, this.styles.leftBlock); float width = num7 - rect11.xMin; float num13 = num8 - num7; float num14 = (rect11.xMax - rect11.xMin) - (width + num13); if (width > 0f) { GUI.Box(new Rect(0f, 0f, width, rect4.height), GUIContent.none, this.styles.onLeft); } if (num13 > 0f) { GUI.Box(new Rect(width, 0f, num13, rect4.height), GUIContent.none, this.styles.onOff); } if (num14 > 0f) { GUI.Box(new Rect(width + num13, 0f, num14, rect4.height), GUIContent.none, this.styles.offRight); } float b = 1f; float num16 = this.styles.block.CalcSize(content).x; float num17 = Mathf.Max(0f, width) - 20f; float num18 = num17 + 15f; if (((num17 < num16) && (num18 > 0f)) && (this.m_DragState == DragStates.LeftSelection)) { b = 0f; } GUI.EndGroup(); float num19 = this.styles.leftBlock.normal.textColor.a; if (!Mathf.Approximately(num19, b) && (Event.current.type == EventType.Repaint)) { num19 = Mathf.Lerp(num19, b, 0.1f); this.styles.leftBlock.normal.textColor = new Color(this.styles.leftBlock.normal.textColor.r, this.styles.leftBlock.normal.textColor.g, this.styles.leftBlock.normal.textColor.b, num19); HandleUtility.Repaint(); } GUI.Box(rect11, content, this.styles.leftBlock); rect11 = new Rect(rect11.xMax, 85f, rect11.xMax - rect11.xMin, 32f); } GUIContent content2 = EditorGUIUtility.TempContent(this.DstName); int num20 = !this.dstLoop ? 1 : (1 + ((int)((num8 - rect5.xMin) / (rect5.xMax - rect5.xMin)))); rect11 = rect5; if (rect5.width < 10f) { rect11 = new Rect(rect5.x, rect5.y, (rect5.xMax - rect5.xMin) * num20, rect5.height); num20 = 1; } for (int j = 0; j < num20; j++) { GUI.BeginGroup(rect11, GUIContent.none, this.styles.rightBlock); float num22 = num7 - rect11.xMin; float num23 = num8 - num7; float num24 = (rect11.xMax - rect11.xMin) - (num22 + num23); if (num22 > 0f) { GUI.Box(new Rect(0f, 0f, num22, rect5.height), GUIContent.none, this.styles.offLeft); } if (num23 > 0f) { GUI.Box(new Rect(num22, 0f, num23, rect5.height), GUIContent.none, this.styles.offOn); } if (num24 > 0f) { GUI.Box(new Rect(num22 + num23, 0f, num24, rect5.height), GUIContent.none, this.styles.onRight); } float num25 = 1f; float num26 = this.styles.block.CalcSize(content2).x; float num27 = Mathf.Max(0f, num22) - 20f; float num28 = num27 + 15f; if (((num27 < num26) && (num28 > 0f)) && ((this.m_DragState == DragStates.LeftSelection) || (this.m_DragState == DragStates.Destination))) { num25 = 0f; } GUI.EndGroup(); float num29 = this.styles.rightBlock.normal.textColor.a; if (!Mathf.Approximately(num29, num25) && (Event.current.type == EventType.Repaint)) { num29 = Mathf.Lerp(num29, num25, 0.1f); this.styles.rightBlock.normal.textColor = new Color(this.styles.rightBlock.normal.textColor.r, this.styles.rightBlock.normal.textColor.g, this.styles.rightBlock.normal.textColor.b, num29); HandleUtility.Repaint(); } GUI.Box(rect11, content2, this.styles.rightBlock); rect11 = new Rect(rect11.xMax, rect11.yMin, rect11.xMax - rect11.xMin, 32f); } GUI.Box(rect7, GUIContent.none, this.styles.select); GUI.Box(rect6, GUIContent.none, this.styles.selectHead); this.m_TimeArea.TimeRuler(position, 30f); GUI.Box(rect8, GUIContent.none, !this.m_HasExitTime ? this.styles.handLeftPrev : this.styles.handLeft); GUI.Box(rect9, GUIContent.none, this.styles.handRight); GUI.Box(rect10, GUIContent.none, this.styles.playhead); Color color = Handles.color; Handles.color = Color.white; Handles.DrawLine(new Vector3(num9, 19f, 0f), new Vector3(num9, rect.height, 0f)); Handles.color = color; bool flag2 = (this.SrcStopTime - this.SrcStartTime) < 0.03333334f; bool flag3 = (this.DstStopTime - this.DstStartTime) < 0.03333334f; if ((this.m_DragState == DragStates.Destination) && !flag3) { Rect rect12 = new Rect(num7 - 50f, rect5.y, 45f, rect5.height); string t = string.Format("{0:0%}", (num7 - num5) / (num6 - num5)); GUI.Box(rect12, EditorGUIUtility.TempContent(t), this.styles.timeBlockRight); } if (this.m_DragState == DragStates.LeftSelection) { if (!flag2) { Rect rect13 = new Rect(num7 - 50f, rect4.y, 45f, rect4.height); string str2 = string.Format("{0:0%}", (num7 - x) / (pixelX - x)); GUI.Box(rect13, EditorGUIUtility.TempContent(str2), this.styles.timeBlockRight); } if (!flag3) { Rect rect14 = new Rect(num7 - 50f, rect5.y, 45f, rect5.height); string str3 = string.Format("{0:0%}", (num7 - num5) / (num6 - num5)); GUI.Box(rect14, EditorGUIUtility.TempContent(str3), this.styles.timeBlockRight); } } if (this.m_DragState == DragStates.RightSelection) { if (!flag2) { Rect rect15 = new Rect(num8 + 5f, rect4.y, 45f, rect4.height); string str4 = string.Format("{0:0%}", (num8 - x) / (pixelX - x)); GUI.Box(rect15, EditorGUIUtility.TempContent(str4), this.styles.timeBlockLeft); } if (!flag3) { Rect rect16 = new Rect(num8 + 5f, rect5.y, 45f, rect5.height); string str5 = string.Format("{0:0%}", (num8 - num5) / (num6 - num5)); GUI.Box(rect16, EditorGUIUtility.TempContent(str5), this.styles.timeBlockLeft); } } this.DoPivotCurves(); GUI.EndGroup(); return(flag); }
private void ShowSwatchArray(Rect position, List <GradientEditor.Swatch> swatches, bool isAlpha) { int controlId = GUIUtility.GetControlID(652347689, FocusType.Passive); Event current1 = Event.current; float time = this.GetTime((Event.current.mousePosition.x - position.x) / position.width); Vector2 point = (Vector2) new Vector3(position.x + time * position.width, Event.current.mousePosition.y); EventType typeForControl = current1.GetTypeForControl(controlId); switch (typeForControl) { case EventType.MouseDown: Rect rect = position; rect.xMin -= 10f; rect.xMax += 10f; if (!rect.Contains(current1.mousePosition)) { break; } GUIUtility.hotControl = controlId; current1.Use(); if (swatches.Contains(this.m_SelectedSwatch) && !this.m_SelectedSwatch.m_IsAlpha && this.CalcSwatchRect(position, this.m_SelectedSwatch).Contains(current1.mousePosition)) { if (current1.clickCount != 2) { break; } GUIUtility.keyboardControl = controlId; ColorPicker.Show(GUIView.current, this.m_SelectedSwatch.m_Value, false, false, (ColorPickerHDRConfig)null); GUIUtility.ExitGUI(); break; } bool flag1 = false; using (List <GradientEditor.Swatch> .Enumerator enumerator = swatches.GetEnumerator()) { while (enumerator.MoveNext()) { GradientEditor.Swatch current2 = enumerator.Current; if (this.CalcSwatchRect(position, current2).Contains(point)) { flag1 = true; this.m_SelectedSwatch = current2; break; } } } if (flag1) { break; } if (swatches.Count < 8) { Color color = this.m_Gradient.Evaluate(time); if (isAlpha) { color = new Color(color.a, color.a, color.a, 1f); } else { color.a = 1f; } this.m_SelectedSwatch = new GradientEditor.Swatch(time, color, isAlpha); swatches.Add(this.m_SelectedSwatch); this.AssignBack(); break; } Debug.LogWarning((object)("Max " + (object)8 + " color keys and " + (object)8 + " alpha keys are allowed in a gradient.")); break; case EventType.MouseUp: if (GUIUtility.hotControl != controlId) { break; } GUIUtility.hotControl = 0; current1.Use(); if (!swatches.Contains(this.m_SelectedSwatch)) { this.m_SelectedSwatch = (GradientEditor.Swatch)null; } this.RemoveDuplicateOverlappingSwatches(); break; case EventType.MouseDrag: if (GUIUtility.hotControl != controlId || this.m_SelectedSwatch == null) { break; } current1.Use(); if ((double)current1.mousePosition.y + 5.0 < (double)position.y || (double)current1.mousePosition.y - 5.0 > (double)position.yMax) { if (swatches.Count > 1) { swatches.Remove(this.m_SelectedSwatch); this.AssignBack(); break; } } else if (!swatches.Contains(this.m_SelectedSwatch)) { swatches.Add(this.m_SelectedSwatch); } this.m_SelectedSwatch.m_Time = time; this.AssignBack(); break; case EventType.KeyDown: if (current1.keyCode != KeyCode.Delete) { break; } if (this.m_SelectedSwatch != null) { List <GradientEditor.Swatch> swatchList = !this.m_SelectedSwatch.m_IsAlpha ? this.m_RGBSwatches : this.m_AlphaSwatches; if (swatchList.Count > 1) { swatchList.Remove(this.m_SelectedSwatch); this.AssignBack(); HandleUtility.Repaint(); } } current1.Use(); break; case EventType.Repaint: bool flag2 = false; using (List <GradientEditor.Swatch> .Enumerator enumerator = swatches.GetEnumerator()) { while (enumerator.MoveNext()) { GradientEditor.Swatch current2 = enumerator.Current; if (this.m_SelectedSwatch == current2) { flag2 = true; } else { this.DrawSwatch(position, current2, !isAlpha); } } } if (!flag2 || this.m_SelectedSwatch == null) { break; } this.DrawSwatch(position, this.m_SelectedSwatch, !isAlpha); break; default: if (typeForControl != EventType.ValidateCommand) { if (typeForControl != EventType.ExecuteCommand) { break; } if (current1.commandName == "ColorPickerChanged") { GUI.changed = true; this.m_SelectedSwatch.m_Value = ColorPicker.color; this.AssignBack(); HandleUtility.Repaint(); break; } if (!(current1.commandName == "Delete") || swatches.Count <= 1) { break; } swatches.Remove(this.m_SelectedSwatch); this.AssignBack(); HandleUtility.Repaint(); break; } if (!(current1.commandName == "Delete")) { break; } Event.current.Use(); break; } }
void Repaint() { // Repaints current view HandleUtility.Repaint(); }
public bool DoGUI(bool hasFocus) { bool enabled = GUI.enabled; if (ASHistoryWindow.ms_Style == null) { ASHistoryWindow.ms_Style = new ASHistoryWindow.Constants(); ASHistoryWindow.ms_Style.entryEven = new GUIStyle(ASHistoryWindow.ms_Style.entryEven); ASHistoryWindow.ms_Style.entryEven.padding.left = 3; ASHistoryWindow.ms_Style.entryOdd = new GUIStyle(ASHistoryWindow.ms_Style.entryOdd); ASHistoryWindow.ms_Style.entryOdd.padding.left = 3; ASHistoryWindow.ms_Style.label = new GUIStyle(ASHistoryWindow.ms_Style.label); ASHistoryWindow.ms_Style.boldLabel = new GUIStyle(ASHistoryWindow.ms_Style.boldLabel); ASHistoryWindow.ms_Style.label.padding.left = 3; ASHistoryWindow.ms_Style.boldLabel.padding.left = 3; ASHistoryWindow.ms_Style.boldLabel.padding.top = 0; ASHistoryWindow.ms_Style.boldLabel.padding.bottom = 0; this.DoLocalSelectionChange(); } EditorGUIUtility.SetIconSize(ASHistoryWindow.ms_IconSize); if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { this.CancelShowCustomDiff(); Event.current.Use(); } SplitterGUILayout.BeginHorizontalSplit(this.m_HorSplit, new GUILayoutOption[0]); GUILayout.BeginVertical(new GUILayoutOption[0]); Rect rect = GUILayoutUtility.GetRect(0f, 0f, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); this.m_FileViewWin.DoGUI(this, rect, hasFocus); GUILayout.EndVertical(); GUILayout.BeginVertical(new GUILayoutOption[0]); this.WebLikeHistory(hasFocus); GUILayout.EndVertical(); SplitterGUILayout.EndHorizontalSplit(); if (Event.current.type == EventType.Repaint) { Handles.color = Color.black; Handles.DrawLine(new Vector3((float)(this.m_HorSplit.realSizes[0] - 1), rect.y, 0f), new Vector3((float)(this.m_HorSplit.realSizes[0] - 1), rect.yMax, 0f)); Handles.DrawLine(new Vector3(0f, rect.yMax, 0f), new Vector3((float)Screen.width, rect.yMax, 0f)); } GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.enabled = (this.m_FileViewWin.SelType == ASHistoryFileView.SelectionType.DeletedItems && enabled); if (GUILayout.Button(EditorGUIUtility.TextContent("Recover"), ASHistoryWindow.ms_Style.button, new GUILayoutOption[0])) { this.m_FileViewWin.DoRecover(); } GUILayout.FlexibleSpace(); if (this.m_InRevisionSelectMode) { GUI.enabled = enabled; GUILayout.Label(EditorGUIUtility.TextContent("Select revision to compare to"), ASHistoryWindow.ms_Style.boldLabel, new GUILayoutOption[0]); } GUILayout.Space(10f); GUI.enabled = (this.IsComparableAssetSelected() && enabled); if (GUILayout.Button(EditorGUIUtility.TextContent("Compare to Local Version"), ASHistoryWindow.ms_Style.button, new GUILayoutOption[0])) { this.DoShowDiff(false, this.ChangeLogSelectionRev, -1); GUIUtility.ExitGUI(); } GUI.enabled = (this.ChangeLogSelectionRev > 0 && this.m_ChangeLogSelectionGUID != string.Empty && enabled); if (GUILayout.Button(EditorGUIUtility.TextContent("Download Selected File"), ASHistoryWindow.ms_Style.button, new GUILayoutOption[0])) { this.DownloadFile(); } GUILayout.Space(10f); GUI.enabled = (this.ChangeLogSelectionRev > 0 && enabled); if (GUILayout.Button((this.ChangeLogSelectionRev <= 0) ? "Revert Entire Project" : ("Revert Entire Project to " + this.ChangeLogSelectionRev), ASHistoryWindow.ms_Style.button, new GUILayoutOption[0])) { this.DoRevertProject(); } GUI.enabled = enabled; GUILayout.EndHorizontal(); GUILayout.Space(10f); if (!this.m_SplittersOk && Event.current.type == EventType.Repaint) { this.m_SplittersOk = true; HandleUtility.Repaint(); } EditorGUIUtility.SetIconSize(Vector2.zero); return(true); }
private void Repaint() { HandleUtility.Repaint(); }
internal static void DoBoneHandle(Transform target, Dictionary <Transform, bool> validBones, BoneRenderer renderer) { int id = target.name.GetHashCode(); Event evt = Event.current; bool hasValidChildBones = false; if (validBones != null) { foreach (Transform child in target) { if (validBones.ContainsKey(child)) { hasValidChildBones = true; break; } } } Vector3 basePoint = target.position; List <Vector3> endPoints = new List <Vector3>(); // [case 525602] do not draw root. if (!hasValidChildBones && target.parent != null) { endPoints.Add(target.position + (target.position - target.parent.position) * 0.4f); } else { foreach (Transform child in target) { // Only render bone connections to valid bones // (except if no child bones are valid - then draw all connections) if (validBones != null && !validBones.ContainsKey(child)) { continue; } endPoints.Add(child.position); } } for (int i = 0; i < endPoints.Count; i++) { Vector3 endPoint = endPoints[i]; switch (evt.GetTypeForControl(id)) { case EventType.Layout: { // TODO : This is slow and should be revisited prior to exposing bone handles Vector3[] vertices = BoneRenderer.GetBoneWireVertices(basePoint, endPoint); if (vertices != null) { HandleUtility.AddControl(id, DistanceToPolygone(vertices)); } break; } case EventType.MouseMove: if (id == HandleUtility.nearestControl) { HandleUtility.Repaint(); } break; case EventType.MouseDown: { // am I closest to the thingy? if (!evt.alt && HandleUtility.nearestControl == id && evt.button == 0) { GUIUtility.hotControl = id; // Grab mouse focus if (evt.shift) { Object[] selected = Selection.objects; if (ArrayUtility.Contains(selected, target) == false) { ArrayUtility.Add(ref selected, target); Selection.objects = selected; } } else { Selection.activeObject = target; } EditorGUIUtility.PingObject(target); evt.Use(); } break; } case EventType.MouseDrag: { if (!evt.alt && GUIUtility.hotControl == id) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new UnityEngine.Object[] { target }; DragAndDrop.StartDrag(ObjectNames.GetDragAndDropTitle(target)); // having a hot control set during drag makes the control eat the drag events // and dragging of bones no longer works over the avatar configure window // see case 912016 GUIUtility.hotControl = 0; evt.Use(); } break; } case EventType.MouseUp: { if (GUIUtility.hotControl == id && (evt.button == 0 || evt.button == 2)) { GUIUtility.hotControl = 0; evt.Use(); } break; } case EventType.Repaint: { color = GUIUtility.hotControl == 0 && HandleUtility.nearestControl == id ? Handles.preselectionColor : color; if (hasValidChildBones) { renderer.AddBoneInstance(basePoint, endPoint, color); } else { renderer.AddBoneLeafInstance(basePoint, target.rotation, (endPoint - basePoint).magnitude, color); } } break; } } }
// Should be called when IsRenaming () returns true to draw the overlay and handle events. // Returns true if renaming is still active, false if not (user canceled, accepted, clicked outside edit rect etc). // If textFieldStyle == null then a default style is used. public bool OnGUI(GUIStyle textFieldStyle) { if (m_IsWaitingForDelay) { // Delayed start return(true); } // Ended from outside if (!m_IsRenaming) { return(false); } if (m_UndoRedoWasPerformed) { m_UndoRedoWasPerformed = false; EndRename(false); return(false); } if (m_EditFieldRect.width <= 0 || m_EditFieldRect.height <= 0 || m_TextFieldControlID == 0) { // Due to call order dependency we might not have a valid rect to render yet or have called OnEvent when renaming was active and therefore controlID can be uninitialzied so // we ensure to issue repaints until these states are valid HandleUtility.Repaint(); return(true); } Event evt = Event.current; if (evt.type == EventType.KeyDown) { if (evt.keyCode == KeyCode.Escape) { evt.Use(); EndRename(false); return(false); } if (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter) { evt.Use(); EndRename(true); return(false); } } // Detect if we clicked outside the text field (must be before text field below which steals keyboard control) if (m_OriginalEventType == EventType.MouseDown && !m_EditFieldRect.Contains(Event.current.mousePosition)) { EndRename(true); return(false); } m_Name = DoTextField(m_Name, textFieldStyle); if (evt.type == EventType.ScrollWheel) { evt.Use(); } return(true); }
// This method takes either object reference directly, or via SerializedObject. // Since it's not easy to know which parameters are mutually exclusively used, this method is // private and internal/public methods instead EITHER take SerializedObject OR direct reference. static Object DoObjectField(Rect position, Rect dropRect, int id, Object obj, Object objBeingEdited, System.Type objType, SerializedProperty property, ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style) { if (validator == null) { validator = ValidateObjectFieldAssignment; } if (property != null) { obj = property.objectReferenceValue; } Event evt = Event.current; EventType eventType = evt.type; // special case test, so we continue to ping/select objects with the object field disabled if (!GUI.enabled && GUIClip.enabled && (Event.current.rawType == EventType.MouseDown)) { eventType = Event.current.rawType; } bool hasThumbnail = EditorGUIUtility.HasObjectThumbnail(objType); // Determine visual type ObjectFieldVisualType visualType = ObjectFieldVisualType.IconAndText; if (hasThumbnail && position.height <= kObjectFieldMiniThumbnailHeight && position.width <= kObjectFieldMiniThumbnailWidth) { visualType = ObjectFieldVisualType.MiniPreview; } else if (hasThumbnail && position.height > kSingleLineHeight) { visualType = ObjectFieldVisualType.LargePreview; } Vector2 oldIconSize = EditorGUIUtility.GetIconSize(); if (visualType == ObjectFieldVisualType.IconAndText) { EditorGUIUtility.SetIconSize(new Vector2(12, 12)); // Have to be this small to fit inside a single line height ObjectField } else if (visualType == ObjectFieldVisualType.LargePreview) { EditorGUIUtility.SetIconSize(new Vector2(64, 64)); } switch (eventType) { case EventType.DragExited: if (GUI.enabled) { HandleUtility.Repaint(); } break; case EventType.DragUpdated: case EventType.DragPerform: if (eventType == EventType.DragPerform) { string errorString; if (!ValidDroppedObject(DragAndDrop.objectReferences, objType, out errorString)) { Object reference = DragAndDrop.objectReferences[0]; EditorUtility.DisplayDialog("Can't assign script", errorString, "OK"); break; } } if (dropRect.Contains(Event.current.mousePosition) && GUI.enabled) { Object[] references = DragAndDrop.objectReferences; Object validatedObject = validator(references, objType, property, ObjectFieldValidatorOptions.None); if (validatedObject != null) { // If scene objects are not allowed and object is a scene object then clear if (!allowSceneObjects && !EditorUtility.IsPersistent(validatedObject)) { validatedObject = null; } } if (validatedObject != null) { DragAndDrop.visualMode = DragAndDropVisualMode.Generic; if (eventType == EventType.DragPerform) { if (property != null) { property.objectReferenceValue = validatedObject; } else { obj = validatedObject; } GUI.changed = true; DragAndDrop.AcceptDrag(); DragAndDrop.activeControlID = 0; } else { DragAndDrop.activeControlID = id; } Event.current.Use(); } } break; case EventType.MouseDown: // Ignore right clicks if (Event.current.button != 0) { break; } if (position.Contains(Event.current.mousePosition)) { // Get button rect for Object Selector Rect buttonRect = GetButtonRect(visualType, position); EditorGUIUtility.editingTextField = false; if (buttonRect.Contains(Event.current.mousePosition)) { if (GUI.enabled) { GUIUtility.keyboardControl = id; if (property != null) { ObjectSelector.get.Show(objType, property, allowSceneObjects); } else { ObjectSelector.get.Show(obj, objType, objBeingEdited, allowSceneObjects); } ObjectSelector.get.objectSelectorID = id; evt.Use(); GUIUtility.ExitGUI(); } } else { Object actualTargetObject = property != null ? property.objectReferenceValue : obj; Component com = actualTargetObject as Component; if (com) { actualTargetObject = com.gameObject; } if (showMixedValue) { actualTargetObject = null; } // One click shows where the referenced object is, or pops up a preview if (Event.current.clickCount == 1) { GUIUtility.keyboardControl = id; PingObjectOrShowPreviewOnClick(actualTargetObject, position); evt.Use(); } // Double click opens the asset in external app or changes selection to referenced object else if (Event.current.clickCount == 2) { if (actualTargetObject) { AssetDatabase.OpenAsset(actualTargetObject); GUIUtility.ExitGUI(); } evt.Use(); } } } break; case EventType.ExecuteCommand: string commandName = evt.commandName; if (commandName == ObjectSelector.ObjectSelectorUpdatedCommand && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id && (property == null || !property.isScript)) { return(AssignSelectedObject(property, validator, objType, evt)); } else if (commandName == ObjectSelector.ObjectSelectorClosedCommand && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id && property != null && property.isScript) { if (ObjectSelector.get.GetInstanceID() == 0) { // User canceled object selection; don't apply evt.Use(); break; } return(AssignSelectedObject(property, validator, objType, evt)); } break; case EventType.KeyDown: if (GUIUtility.keyboardControl == id) { if (evt.keyCode == KeyCode.Backspace || (evt.keyCode == KeyCode.Delete && (evt.modifiers & EventModifiers.Shift) == 0)) { if (property != null) { property.objectReferenceValue = null; } else { obj = null; } GUI.changed = true; evt.Use(); } // Apparently we have to check for the character being space instead of the keyCode, // otherwise the Inspector will maximize upon pressing space. if (evt.MainActionKeyForControl(id)) { if (property != null) { ObjectSelector.get.Show(objType, property, allowSceneObjects); } else { ObjectSelector.get.Show(obj, objType, objBeingEdited, allowSceneObjects); } ObjectSelector.get.objectSelectorID = id; evt.Use(); GUIUtility.ExitGUI(); } } break; case EventType.Repaint: GUIContent temp; if (showMixedValue) { temp = s_MixedValueContent; } else { // If obj or objType are both null, we have to rely on // property.objectReferenceStringValue to display None/Missing and the // correct type. But if not, EditorGUIUtility.ObjectContent is more reliable. // It can take a more specific object type specified as argument into account, // and it gets the icon at the same time. if (obj == null && objType == null && property != null) { temp = EditorGUIUtility.TempContent(property.objectReferenceStringValue); } else { // In order for ObjectContext to be able to distinguish between None/Missing, // we need to supply an instanceID. For some reason, getting the instanceID // from property.objectReferenceValue is not reliable, so we have to // explicitly check property.objectReferenceInstanceIDValue if a property exists. if (property != null) { temp = EditorGUIUtility.ObjectContent(obj, objType, property.objectReferenceInstanceIDValue); } else { temp = EditorGUIUtility.ObjectContent(obj, objType); } } if (property != null) { if (obj != null) { Object[] references = { obj }; if (EditorSceneManager.preventCrossSceneReferences && CheckForCrossSceneReferencing(obj, property.serializedObject.targetObject)) { if (!EditorApplication.isPlaying) { temp = s_SceneMismatch; } else { temp.text = temp.text + string.Format(" ({0})", GetGameObjectFromObject(obj).scene.name); } } else if (validator(references, objType, property, ObjectFieldValidatorOptions.ExactObjectTypeValidation) == null) { temp = s_TypeMismatch; } } } } switch (visualType) { case ObjectFieldVisualType.IconAndText: BeginHandleMixedValueContentColor(); style.Draw(position, temp, id, DragAndDrop.activeControlID == id, position.Contains(Event.current.mousePosition)); Rect buttonRect = EditorStyles.objectFieldButton.margin.Remove(GetButtonRect(visualType, position)); EditorStyles.objectFieldButton.Draw(buttonRect, GUIContent.none, id, DragAndDrop.activeControlID == id, buttonRect.Contains(Event.current.mousePosition)); EndHandleMixedValueContentColor(); break; case ObjectFieldVisualType.LargePreview: DrawObjectFieldLargeThumb(position, id, obj, temp); break; case ObjectFieldVisualType.MiniPreview: DrawObjectFieldMiniThumb(position, id, obj, temp); break; default: throw new ArgumentOutOfRangeException(); } break; } EditorGUIUtility.SetIconSize(oldIconSize); return(obj); }
public void DoEffectGUI(int effectIndex, AudioMixerGroupController group, List <AudioMixerGroupController> allGroups, Dictionary <AudioMixerEffectController, AudioMixerGroupController> effectMap, ref int highlightEffectIndex) { Event current = Event.current; AudioMixerController controller = group.controller; AudioMixerEffectController audioMixerEffectController = group.effects[effectIndex]; MixerParameterDefinition[] effectParameters = MixerEffectDefinitions.GetEffectParameters(audioMixerEffectController.effectName); Rect effectRect = EditorGUILayout.BeginVertical(new GUILayoutOption[0]); bool flag = effectRect.Contains(current.mousePosition); EventType typeForControl = current.GetTypeForControl(this.m_EffectDragging.dragControlID); if (typeForControl == EventType.MouseMove && flag && highlightEffectIndex != effectIndex) { highlightEffectIndex = effectIndex; AudioMixerUtility.RepaintAudioMixerAndInspectors(); } Rect rect = GUILayoutUtility.GetRect(1f, 17f); Rect rect2 = new Rect(rect.x + 6f, rect.y + 5f, 6f, 6f); Rect position = new Rect(rect.x + 8f + 6f, rect.y, rect.width - 8f - 6f - 14f - 5f, rect.height); Rect rect3 = new Rect(position.xMax, rect.y, 14f, 14f); Rect rect4 = new Rect(rect.x, rect.y, rect.width - 14f - 5f, rect.height); bool flag2 = EditorPrefs.GetBool(AudioMixerGroupEditor.kPrefKeyForShowCpuUsage, false) && EditorUtility.audioProfilingEnabled; float num = (!EditorGUIUtility.isProSkin) ? 1f : 0.1f; Color color = new Color(num, num, num, 0.2f); Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture); GUI.color = color2; Color effectColor = AudioMixerDrawUtils.GetEffectColor(audioMixerEffectController); EditorGUI.DrawRect(rect2, effectColor); GUI.Label(position, (!flag2) ? audioMixerEffectController.effectName : (audioMixerEffectController.effectName + string.Format(AudioMixerEffectView.Texts.cpuFormatString, audioMixerEffectController.GetCPUUsage(controller))), EditorStyles.boldLabel); if (EditorGUI.ButtonMouseDown(rect3, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.inspectorTitlebarText)) { AudioMixerEffectView.ShowEffectContextMenu(group, audioMixerEffectController, effectIndex, controller, rect3); } if (current.type == EventType.ContextClick && rect.Contains(current.mousePosition)) { AudioMixerEffectView.ShowEffectContextMenu(group, audioMixerEffectController, effectIndex, controller, new Rect(current.mousePosition.x, rect.y, 1f, rect.height)); current.Use(); } if (typeForControl == EventType.Repaint) { EditorGUIUtility.AddCursorRect(rect4, MouseCursor.ResizeVertical, this.m_EffectDragging.dragControlID); } EditorGUI.BeginDisabledGroup(audioMixerEffectController.bypass || group.bypassEffects); EditorGUILayout.BeginVertical(EditorStyles.inspectorDefaultMargins, new GUILayoutOption[0]); if (audioMixerEffectController.IsAttenuation()) { EditorGUILayout.BeginVertical(new GUILayoutOption[0]); float valueForVolume = group.GetValueForVolume(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.volume, ref valueForVolume, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume(), controller, new AudioGroupParameterPath(group, group.GetGUIDForVolume()), new GUILayoutOption[0])) { group.SetValueForVolume(controller, controller.TargetSnapshot, valueForVolume); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } float[] array = new float[9]; float[] array2 = new float[9]; int num2 = group.controller.GetGroupVUInfo(group.groupID, true, ref array, ref array2); if (current.type == EventType.Layout) { this.m_LastNumChannels = num2; } else { if (num2 != this.m_LastNumChannels) { HandleUtility.Repaint(); } num2 = this.m_LastNumChannels; } GUILayout.Space(4f); for (int i = 0; i < num2; i++) { float value = 1f - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(array[i], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1f, true); float num3 = 1f - AudioMixerController.VolumeToScreenMapping(Mathf.Clamp(array2[i], AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume()), 1f, true); EditorGUILayout.VUMeterHorizontal(value, num3, new GUILayoutOption[] { GUILayout.Height(10f) }); if (!EditorApplication.isPlaying && num3 > 0f) { AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } GUILayout.Space(4f); EditorGUILayout.EndVertical(); } if (audioMixerEffectController.IsSend()) { GUIContent buttonContent = (!(audioMixerEffectController.sendTarget == null)) ? GUIContent.Temp(audioMixerEffectController.GetSendTargetDisplayString(effectMap)) : AudioMixerEffectView.Texts.none; Rect buttonRect; if (AudioMixerEffectGUI.PopupButton(AudioMixerEffectView.Texts.bus, buttonContent, EditorStyles.popup, out buttonRect, new GUILayoutOption[0])) { AudioMixerEffectView.ShowBusPopupMenu(effectIndex, group, allGroups, effectMap, audioMixerEffectController, buttonRect); } if (audioMixerEffectController.sendTarget != null) { float valueForMixLevel = audioMixerEffectController.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.sendLevel, ref valueForMixLevel, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioEffectParameterPath(group, audioMixerEffectController, audioMixerEffectController.GetGUIDForMixLevel()), new GUILayoutOption[0])) { audioMixerEffectController.SetValueForMixLevel(controller, controller.TargetSnapshot, valueForMixLevel); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } } if (MixerEffectDefinitions.EffectCanBeSidechainTarget(audioMixerEffectController)) { bool flag3 = false; foreach (AudioMixerGroupController current2 in allGroups) { AudioMixerEffectController[] effects = current2.effects; for (int j = 0; j < effects.Length; j++) { AudioMixerEffectController audioMixerEffectController2 = effects[j]; if (audioMixerEffectController2.IsSend() && audioMixerEffectController2.sendTarget == audioMixerEffectController) { flag3 = true; break; } if (flag3) { break; } } if (flag3) { break; } } if (!flag3) { GUILayout.Label(new GUIContent("No Send sources connected.", EditorGUIUtility.warningIcon), new GUILayoutOption[0]); } } if (audioMixerEffectController.enableWetMix && !audioMixerEffectController.IsReceive() && !audioMixerEffectController.IsDuckVolume() && !audioMixerEffectController.IsAttenuation() && !audioMixerEffectController.IsSend()) { float valueForMixLevel2 = audioMixerEffectController.GetValueForMixLevel(controller, controller.TargetSnapshot); if (AudioMixerEffectGUI.Slider(AudioMixerEffectView.Texts.wet, ref valueForMixLevel2, 1f, 1f, AudioMixerEffectView.Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioEffectParameterPath(group, audioMixerEffectController, audioMixerEffectController.GetGUIDForMixLevel()), new GUILayoutOption[0])) { audioMixerEffectController.SetValueForMixLevel(controller, controller.TargetSnapshot, valueForMixLevel2); AudioMixerUtility.RepaintAudioMixerAndInspectors(); } } bool flag4 = true; if (this.m_CustomEffectGUIs.ContainsKey(audioMixerEffectController.effectName)) { IAudioEffectPluginGUI audioEffectPluginGUI = this.m_CustomEffectGUIs[audioMixerEffectController.effectName]; this.m_SharedPlugin.m_Controller = controller; this.m_SharedPlugin.m_Effect = audioMixerEffectController; this.m_SharedPlugin.m_ParamDefs = effectParameters; flag4 = audioEffectPluginGUI.OnGUI(this.m_SharedPlugin); } if (flag4) { MixerParameterDefinition[] array3 = effectParameters; for (int k = 0; k < array3.Length; k++) { MixerParameterDefinition mixerParameterDefinition = array3[k]; float valueForParameter = audioMixerEffectController.GetValueForParameter(controller, controller.TargetSnapshot, mixerParameterDefinition.name); if (AudioMixerEffectGUI.Slider(GUIContent.Temp(mixerParameterDefinition.name, mixerParameterDefinition.description), ref valueForParameter, mixerParameterDefinition.displayScale, mixerParameterDefinition.displayExponent, mixerParameterDefinition.units, mixerParameterDefinition.minRange, mixerParameterDefinition.maxRange, controller, new AudioEffectParameterPath(group, audioMixerEffectController, audioMixerEffectController.GetGUIDForParameter(mixerParameterDefinition.name)), new GUILayoutOption[0])) { audioMixerEffectController.SetValueForParameter(controller, controller.TargetSnapshot, mixerParameterDefinition.name, valueForParameter); } } if (effectParameters.Length > 0) { GUILayout.Space(6f); } } EditorGUI.EndDisabledGroup(); this.m_EffectDragging.HandleDragElement(effectIndex, effectRect, rect4, group, allGroups); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); AudioMixerDrawUtils.DrawSplitter(); }
public void OnGUI(Rect position) { if (s_Styles == null) { s_Styles = new Styles(); } float modeHeight = 24f; float swatchHeight = 16f; float editSectionHeight = 26f; float gradientTextureHeight = position.height - 2 * swatchHeight - editSectionHeight - modeHeight; position.height = modeHeight; m_GradientMode = (GradientMode)EditorGUI.EnumPopup(position, s_Styles.modeText, m_GradientMode); if (m_GradientMode != m_Gradient.mode) { AssignBack(); } position.y += modeHeight; position.height = swatchHeight; // Alpha swatches (no idea why they're top, but that's what Adobe & Apple seem to agree on) ShowSwatchArray(position, m_AlphaSwatches, true); // Gradient texture position.y += swatchHeight; if (Event.current.type == EventType.Repaint) { position.height = gradientTextureHeight; DrawGradientWithBackground(position, m_Gradient); } position.y += gradientTextureHeight; position.height = swatchHeight; // Color swatches (bottom) ShowSwatchArray(position, m_RGBSwatches, false); if (m_SelectedSwatch != null) { position.y += swatchHeight; position.height = editSectionHeight; position.y += 10; float locationWidth = 45; float locationTextWidth = 60; float space = 20; float alphaOrColorTextWidth = 50; float totalLocationWidth = locationTextWidth + space + locationTextWidth + locationWidth; // Alpha or Color field Rect rect = position; rect.height = 18; rect.x += 17; rect.width -= totalLocationWidth; EditorGUIUtility.labelWidth = alphaOrColorTextWidth; if (m_SelectedSwatch.m_IsAlpha) { EditorGUIUtility.fieldWidth = 30; EditorGUI.BeginChangeCheck(); float sliderValue = EditorGUI.IntSlider(rect, s_Styles.alphaText, (int)(m_SelectedSwatch.m_Value.r * 255), 0, 255) / 255f; if (EditorGUI.EndChangeCheck()) { sliderValue = Mathf.Clamp01(sliderValue); m_SelectedSwatch.m_Value.r = m_SelectedSwatch.m_Value.g = m_SelectedSwatch.m_Value.b = sliderValue; AssignBack(); HandleUtility.Repaint(); } } else { EditorGUI.BeginChangeCheck(); m_SelectedSwatch.m_Value = EditorGUI.ColorField(rect, s_Styles.colorText, m_SelectedSwatch.m_Value, true, false, m_HDR); if (EditorGUI.EndChangeCheck()) { AssignBack(); HandleUtility.Repaint(); } } // Location of key rect.x += rect.width + space; rect.width = locationWidth + locationTextWidth; EditorGUIUtility.labelWidth = locationTextWidth; string orgFormatString = EditorGUI.kFloatFieldFormatString; EditorGUI.kFloatFieldFormatString = "f1"; EditorGUI.BeginChangeCheck(); float newLocation = EditorGUI.FloatField(rect, s_Styles.locationText, m_SelectedSwatch.m_Time * 100.0f) / 100.0f; if (EditorGUI.EndChangeCheck()) { m_SelectedSwatch.m_Time = Mathf.Clamp(newLocation, 0f, 1f); AssignBack(); } EditorGUI.kFloatFieldFormatString = orgFormatString; rect.x += rect.width; rect.width = 20; GUI.Label(rect, s_Styles.percentText); } }