private void DeactivateControlAndFlushCache() { if (GUIUtility.hotControl == _sliderControlId) { GUIUtility.hotControl = 0; Event.current.Use(); } _dragCache = null; }
private void CreateCacheAndActivateControl() { if (_hotPartitionHandleIndex < 0) { return; } _dragCache = new DragCache(_hotPartitionHandleIndex, Event.current.mousePosition); if (GUIUtility.hotControl == 0) { GUIUtility.hotControl = _sliderControlId; } Event.current.Use(); }
/** * Static function to handle the GUI and User input related to the cascade slider. * * @param normalizedCascadePartition The array of partition sizes in the range 0.0f - 1.0f; expects ONE entry if cascades = 2, and THREE if cascades=4 * The last entry will be automatically determined by summing up the array, and doing 1.0f - sum */ public static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions) { EditorGUILayout.LabelField("Cascade splits"); // get the inspector width since we need it while drawing the partition rects. // Only way currently is to reserve the block in the layout using GetRect(), and then immediately drawing the empty box // to match the call to GetRect. // From this point on, we move to non-layout based code. var sliderRect = GUILayoutUtility.GetRect(GUIContent.none , s_CascadeSliderBG , GUILayout.Height(kSliderbarTopMargin + kSliderbarHeight + kSliderbarBottomMargin) , GUILayout.ExpandWidth(true)); GUI.Box(sliderRect, GUIContent.none); float currentX = sliderRect.x; float cascadeBoxStartY = sliderRect.y + kSliderbarTopMargin; float cascadeSliderWidth = sliderRect.width - (normalizedCascadePartitions.Length * kPartitionHandleWidth); Color origTextColor = GUI.color; Color origBackgroundColor = GUI.backgroundColor; int colorIndex = -1; // setup the array locally with the last partition float[] adjustedCascadePartitions = new float[normalizedCascadePartitions.Length + 1]; System.Array.Copy(normalizedCascadePartitions, adjustedCascadePartitions, normalizedCascadePartitions.Length); adjustedCascadePartitions[adjustedCascadePartitions.Length - 1] = 1.0f - normalizedCascadePartitions.Sum(); // check for user input on any of the partition handles // this mechanism gets the current event in the queue... make sure that the mouse is over our control before consuming the event int sliderControlId = GUIUtility.GetControlID(s_CascadeSliderId, FocusType.Passive); Event currentEvent = Event.current; int hotPartitionHandleIndex = -1; // the index of any partition handle that we are hovering over or dragging // draw each cascade partition for (int i = 0; i < adjustedCascadePartitions.Length; ++i) { float currentPartition = adjustedCascadePartitions[i]; colorIndex = (colorIndex + 1) % kCascadeColors.Length; GUI.backgroundColor = kCascadeColors[colorIndex]; float boxLength = (cascadeSliderWidth * currentPartition); // main cascade box Rect partitionRect = new Rect(currentX, cascadeBoxStartY, boxLength, kSliderbarHeight); GUI.Box(partitionRect, GUIContent.none, s_CascadeSliderBG); currentX += boxLength; // cascade box percentage text GUI.color = Color.white; Rect textRect = partitionRect; var cascadeText = string.Format("{0}\n{1:F1}%", i, currentPartition * 100.0f); GUI.Label(textRect, cascadeText, s_TextCenteredStyle); // no need to draw the partition handle for last box if (i == adjustedCascadePartitions.Length - 1) { break; } // partition handle GUI.backgroundColor = Color.black; Rect handleRect = partitionRect; handleRect.x = currentX; handleRect.width = kPartitionHandleWidth; GUI.Box(handleRect, GUIContent.none, s_CascadeSliderBG); // we want a thin handle visually (since wide black bar looks bad), but a slightly larger // hit area for easier manipulation Rect handleHitRect = handleRect; handleHitRect.xMin -= kPartitionHandleExtraHitAreaWidth; handleHitRect.xMax += kPartitionHandleExtraHitAreaWidth; if (handleHitRect.Contains(currentEvent.mousePosition)) { hotPartitionHandleIndex = i; } // add regions to slider where the cursor changes to Resize-Horizontal if (s_DragCache == null) { EditorGUIUtility.AddCursorRect(handleHitRect, MouseCursor.ResizeHorizontal, sliderControlId); } currentX += kPartitionHandleWidth; } GUI.color = origTextColor; GUI.backgroundColor = origBackgroundColor; EventType eventType = currentEvent.GetTypeForControl(sliderControlId); switch (eventType) { case EventType.MouseDown: if (hotPartitionHandleIndex >= 0) { s_DragCache = new DragCache(hotPartitionHandleIndex, normalizedCascadePartitions[hotPartitionHandleIndex], currentEvent.mousePosition); if (GUIUtility.hotControl == 0) { GUIUtility.hotControl = sliderControlId; } currentEvent.Use(); // Switch active scene view into shadow cascades visualization mode, once we start // tweaking cascade splits. if (s_RestoreSceneView == null) { s_RestoreSceneView = SceneView.lastActiveSceneView; if (s_RestoreSceneView != null) { s_OldSceneDrawMode = s_RestoreSceneView.cameraMode; s_OldSceneLightingMode = s_RestoreSceneView.m_SceneLighting; s_RestoreSceneView.cameraMode = SceneView.GetBuiltinCameraMode(DrawCameraMode.ShadowCascades); } } } break; case EventType.MouseUp: // mouseUp event anywhere should release the hotcontrol (if it belongs to us), drags (if any) if (GUIUtility.hotControl == sliderControlId) { GUIUtility.hotControl = 0; currentEvent.Use(); } s_DragCache = null; // Restore previous scene view drawing mode once we stop tweaking cascade splits. if (s_RestoreSceneView != null) { s_RestoreSceneView.cameraMode = s_OldSceneDrawMode; s_RestoreSceneView.m_SceneLighting = s_OldSceneLightingMode; s_RestoreSceneView = null; } break; case EventType.MouseDrag: if (GUIUtility.hotControl != sliderControlId) { break; } // convert the mouse movement to normalized cascade width. Make sure that we are safe to apply the delta before using it. float delta = (currentEvent.mousePosition - s_DragCache.m_LastCachedMousePosition).x / cascadeSliderWidth; bool isLeftPartitionHappy = ((adjustedCascadePartitions[s_DragCache.m_ActivePartition] + delta) > 0.0f); bool isRightPartitionHappy = ((adjustedCascadePartitions[s_DragCache.m_ActivePartition + 1] - delta) > 0.0f); if (isLeftPartitionHappy && isRightPartitionHappy) { s_DragCache.m_NormalizedPartitionSize += delta; normalizedCascadePartitions[s_DragCache.m_ActivePartition] = s_DragCache.m_NormalizedPartitionSize; if (s_DragCache.m_ActivePartition < normalizedCascadePartitions.Length - 1) { normalizedCascadePartitions[s_DragCache.m_ActivePartition + 1] -= delta; } GUI.changed = true; } s_DragCache.m_LastCachedMousePosition = currentEvent.mousePosition; currentEvent.Use(); break; } }
/** * Static function to handle the GUI and User input related to the cascade slider. * * @param normalizedCascadePartition The array of partition sizes in the range 0.0f - 1.0f; expects ONE entry if cascades = 2, and THREE if cascades=4 * The last entry will be automatically determined by summing up the array, and doing 1.0f - sum */ static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions, ref float[] endPartitionBordersPercent, bool[] enabledCascadePartitionHandles, bool[] enabledEndPartitionBorderHandles, bool drawEndPartitionHandles, bool useMetric, float baseMetric) { EditorGUILayout.BeginVertical(); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); // get the inspector width since we need it while drawing the partition rects. // Only way currently is to reserve the block in the layout using GetRect(), and then immediately drawing the empty box // to match the call to GetRect. // From this point on, we move to non-layout based code. var sliderRect = GUILayoutUtility.GetRect(GUIContent.none , s_CascadeSliderBG , GUILayout.Height(kSliderbarTopMargin + kSliderbarHeight + kSliderbarBottomMargin) , GUILayout.ExpandWidth(true)); GUI.Box(sliderRect, GUIContent.none); float currentX = sliderRect.x + 3; float cascadeBoxStartY = sliderRect.y + kSliderbarTopMargin; int borderAdjustment = (3 - normalizedCascadePartitions.Length) * 2; float cascadeSliderWidth = sliderRect.width - (normalizedCascadePartitions.Length * kPartitionHandleWidth) - borderAdjustment; Color origTextColor = GUI.color; Color origBackgroundColor = GUI.backgroundColor; int colorIndex = -1; // setup the array locally with the last partition float[] adjustedCascadePartitions = new float[normalizedCascadePartitions.Length + 1]; Array.Copy(normalizedCascadePartitions, adjustedCascadePartitions, normalizedCascadePartitions.Length); adjustedCascadePartitions[adjustedCascadePartitions.Length - 1] = 1.0f - normalizedCascadePartitions.Sum(); // check for user input on any of the partition handles // this mechanism gets the current event in the queue... make sure that the mouse is over our control before consuming the event int sliderControlId = GUIUtility.GetControlID(s_CascadeSliderId, FocusType.Passive); Event currentEvent = Event.current; int hotPartitionHandleIndex = -1; // the index of any partition handle that we are hovering over or dragging EventType eventType = currentEvent.GetTypeForControl(sliderControlId); // draw each cascade partition for (int i = 0; i < adjustedCascadePartitions.Length; ++i) { float currentPartition = adjustedCascadePartitions[i]; colorIndex = (colorIndex + 1) % kCascadeColors.Length; GUI.backgroundColor = kCascadeColors[colorIndex]; float boxLength = Mathf.RoundToInt(cascadeSliderWidth * currentPartition); // main cascade box Rect partitionRect = new Rect(currentX, cascadeBoxStartY, boxLength, kSliderbarHeight); GUI.Box(partitionRect, GUIContent.none, s_CascadeSliderBG); currentX += boxLength; // cascade box texts preparation Rect fullCascadeText = partitionRect; Rect blendCascadeText = partitionRect; blendCascadeText.x += partitionRect.width; blendCascadeText.width = 0f; float fullCascadeValue = currentPartition * 100.0f; float blendCascadeValue = 0f; Rect separationRect = partitionRect; if (i < endPartitionBordersPercent.Length) { // partition blend background and separators GUI.backgroundColor = Color.black; separationRect.width = Mathf.Max(kPartitionHandleWidth, Mathf.CeilToInt(endPartitionBordersPercent[i] * partitionRect.width)); separationRect.x = Mathf.CeilToInt(partitionRect.x + partitionRect.width - separationRect.width); GUI.Box(separationRect, GUIContent.none, s_CascadeSliderBG); //update cascade box texts update blendCascadeValue = endPartitionBordersPercent[i] * currentPartition * 100f; fullCascadeValue -= blendCascadeValue; blendCascadeText.x -= separationRect.width - 1; //remove left border blendCascadeText.width = endPartitionBordersPercent[i] * boxLength; fullCascadeText.width -= separationRect.width; blendCascadeText.width -= 3; //remove right border } // full cascade box text GUI.color = Color.white; float textValue = fullCascadeValue; if (useMetric) { textValue *= baseMetric / 100; } var cascadeText = String.Format(System.Globalization.CultureInfo.InvariantCulture.NumberFormat, "{0}\n{1:F1}{2}", i, textValue, useMetric ? 'm' : '%'); GUI.Label(fullCascadeText, TempGUIContent(cascadeText, cascadeText), s_TextCenteredStyle); if (i >= endPartitionBordersPercent.Length) { break; } // partition blend gradient Rect gradientRect = separationRect; gradientRect.x += 1; gradientRect.width -= 3; if (gradientRect.width > 0) { kBorderBlends[i].Resize((int)gradientRect.width, 1); FillWithGradient(kBorderBlends[i], kCascadeColors[i], i < adjustedCascadePartitions.Length - 1 ? kCascadeColors[i + 1] : Color.black); GUI.DrawTexture(gradientRect, kBorderBlends[i]); } // blend cascade box text textValue = blendCascadeValue; if (useMetric) { textValue *= baseMetric / 100; } if (i == normalizedCascadePartitions.Length) { cascadeText = String.Format(System.Globalization.CultureInfo.InvariantCulture.NumberFormat, "{0}\u2192{1}\n{2:F1}{3}", i, blendCascadeText.width < 57 ? "F." : "Fallback", textValue, useMetric ? 'm' : '%'); string cascadeToolTip = String.Format(System.Globalization.CultureInfo.InvariantCulture.NumberFormat, "{0}\u2192{1}\n{2:F1}{3}", i, "Fallback", textValue, useMetric ? 'm' : '%'); GUI.Label(blendCascadeText, TempGUIContent(cascadeText, cascadeToolTip), s_TextCenteredStyle); } else { cascadeText = String.Format(System.Globalization.CultureInfo.InvariantCulture.NumberFormat, "{0}\u2192{1}\n{2:F1}{3}", i, i + 1, textValue, useMetric ? 'm' : '%'); GUI.Label(blendCascadeText, TempGUIContent(cascadeText, cascadeText), s_TextCenteredStyle); } // init rect for Swatches Rect cascadeHandleRect = default; if (i < normalizedCascadePartitions.Length) { cascadeHandleRect = separationRect; cascadeHandleRect.x += separationRect.width - 6f; cascadeHandleRect.width = enabledCascadePartitionHandles[i] ? 10 : 0; cascadeHandleRect.y -= 14; cascadeHandleRect.height = 15; } Rect blendHandleRect = default; if (drawEndPartitionHandles) { blendHandleRect = separationRect; blendHandleRect.x -= 5f; blendHandleRect.width = enabledEndPartitionBorderHandles[i] ? 10 : 0; blendHandleRect.y += 22; blendHandleRect.height = 15; } if (eventType == EventType.Repaint) //Can only draw the snatch in repaint event { // Add handle to change end of cascade if (i < normalizedCascadePartitions.Length) { GUI.backgroundColor = enabledCascadePartitionHandles[i] ? kCascadeColors[colorIndex + 1] : kDisabledColor; s_DownSwatch.Draw(cascadeHandleRect, false, false, s_BlendHandleSelected == i, false); } if (drawEndPartitionHandles) { GUI.backgroundColor = enabledEndPartitionBorderHandles[i] ? kCascadeColors[colorIndex] : kDisabledColor; s_UpSwatch.Draw(blendHandleRect, false, false, s_BlendHandleSelected == i + 100, false); } } if (cascadeHandleRect.Contains(currentEvent.mousePosition)) { hotPartitionHandleIndex = i; } if (blendHandleRect.Contains(currentEvent.mousePosition)) { hotPartitionHandleIndex = i + 100; } // add regions to slider where the cursor changes to Resize-Horizontal EditorGUIUtility.AddCursorRect(cascadeHandleRect, MouseCursor.ResizeHorizontal, sliderControlId); EditorGUIUtility.AddCursorRect(blendHandleRect, MouseCursor.ResizeHorizontal, sliderControlId); } GUI.color = origTextColor; GUI.backgroundColor = origBackgroundColor; switch (eventType) { case EventType.MouseDown: if (hotPartitionHandleIndex >= 0) { if (hotPartitionHandleIndex < 100) { s_DragCache = new DragCache(hotPartitionHandleIndex, normalizedCascadePartitions[hotPartitionHandleIndex], hotPartitionHandleIndex >= endPartitionBordersPercent.Length ? 0f : endPartitionBordersPercent[hotPartitionHandleIndex], currentEvent.mousePosition, isEndBlendArea: false); } else { int endIndex = hotPartitionHandleIndex - 100; s_DragCache = new DragCache(endIndex, adjustedCascadePartitions[endIndex], endPartitionBordersPercent[endIndex], currentEvent.mousePosition, isEndBlendArea: true); } if (GUIUtility.hotControl == 0) { GUIUtility.hotControl = sliderControlId; } currentEvent.Use(); } break; case EventType.MouseUp: // mouseUp event anywhere should release the hotcontrol (if it belongs to us), drags (if any) if (GUIUtility.hotControl == sliderControlId) { GUIUtility.hotControl = 0; currentEvent.Use(); } s_DragCache = null; break; case EventType.MouseDrag: if (GUIUtility.hotControl != sliderControlId) { break; } // convert the mouse movement to normalized cascade width. Make sure that we are safe to apply the delta before using it. if (s_DragCache.isEndBlendArea) { float delta = (currentEvent.mousePosition - s_DragCache.lastCachedMousePosition).x / (cascadeSliderWidth * adjustedCascadePartitions[s_DragCache.activePartition]); s_DragCache.endBlendAreaPercent = Mathf.Clamp01(s_DragCache.endBlendAreaPercent - delta); endPartitionBordersPercent[s_DragCache.activePartition] = s_DragCache.endBlendAreaPercent; GUI.changed = true; } else { float delta = (currentEvent.mousePosition - s_DragCache.lastCachedMousePosition).x / cascadeSliderWidth; bool isLeftPartitionPositive = ((adjustedCascadePartitions[s_DragCache.activePartition] + delta) > 0.0f); bool isRightPartitionPositive = ((adjustedCascadePartitions[s_DragCache.activePartition + 1] - delta) > 0.0f); if (isLeftPartitionPositive && isRightPartitionPositive) { s_DragCache.normalizedPartitionSize += delta; normalizedCascadePartitions[s_DragCache.activePartition] = s_DragCache.normalizedPartitionSize; if (s_DragCache.activePartition < normalizedCascadePartitions.Length - 1) { normalizedCascadePartitions[s_DragCache.activePartition + 1] -= delta; } GUI.changed = true; } } s_DragCache.lastCachedMousePosition = currentEvent.mousePosition; currentEvent.Use(); break; } EditorGUILayout.EndHorizontal(); GUILayout.Space(6); EditorGUILayout.EndVertical(); }
public static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions) { GUILayout.Label("Cascade splits", new GUILayoutOption[0]); GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Height(28f), GUILayout.ExpandWidth(true) }; Rect position = GUILayoutUtility.GetRect(GUIContent.none, s_CascadeSliderBG, options); GUI.Box(position, GUIContent.none); float x = position.x; float y = position.y + 2f; float num3 = position.width - (normalizedCascadePartitions.Length * 2); Color color = GUI.color; Color backgroundColor = GUI.backgroundColor; int index = -1; float[] destinationArray = new float[normalizedCascadePartitions.Length + 1]; Array.Copy(normalizedCascadePartitions, destinationArray, normalizedCascadePartitions.Length); destinationArray[destinationArray.Length - 1] = 1f - normalizedCascadePartitions.Sum(); int controlID = GUIUtility.GetControlID(s_CascadeSliderId, FocusType.Passive); Event current = Event.current; int activePartition = -1; for (int i = 0; i < destinationArray.Length; i++) { float num8 = destinationArray[i]; index = (index + 1) % kCascadeColors.Length; GUI.backgroundColor = kCascadeColors[index]; float width = num3 * num8; Rect rect2 = new Rect(x, y, width, 24f); GUI.Box(rect2, GUIContent.none, s_CascadeSliderBG); x += width; GUI.color = Color.white; Rect rect3 = rect2; string t = string.Format("{0}\n{1:F1}%", i, num8 * 100f); GUI.Label(rect3, GUIContent.Temp(t, t), s_TextCenteredStyle); if (i == (destinationArray.Length - 1)) { break; } GUI.backgroundColor = Color.black; Rect rect4 = rect2; rect4.x = x; rect4.width = 2f; GUI.Box(rect4, GUIContent.none, s_CascadeSliderBG); Rect rect5 = rect4; rect5.xMin -= 2f; rect5.xMax += 2f; if (rect5.Contains(current.mousePosition)) { activePartition = i; } if (s_DragCache == null) { EditorGUIUtility.AddCursorRect(rect5, MouseCursor.ResizeHorizontal, controlID); } x += 2f; } GUI.color = color; GUI.backgroundColor = backgroundColor; switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: if (activePartition >= 0) { s_DragCache = new DragCache(activePartition, normalizedCascadePartitions[activePartition], current.mousePosition); if (GUIUtility.hotControl == 0) { GUIUtility.hotControl = controlID; } current.Use(); if (s_RestoreSceneView == null) { s_RestoreSceneView = SceneView.lastActiveSceneView; if (s_RestoreSceneView != null) { s_OldSceneDrawMode = s_RestoreSceneView.renderMode; s_OldSceneLightingMode = s_RestoreSceneView.m_SceneLighting; s_RestoreSceneView.renderMode = DrawCameraMode.ShadowCascades; } } } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; current.Use(); } s_DragCache = null; if (s_RestoreSceneView != null) { s_RestoreSceneView.renderMode = s_OldSceneDrawMode; s_RestoreSceneView.m_SceneLighting = s_OldSceneLightingMode; s_RestoreSceneView = null; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { Vector2 vector = current.mousePosition - s_DragCache.m_LastCachedMousePosition; float num10 = vector.x / num3; bool flag = (destinationArray[s_DragCache.m_ActivePartition] + num10) > 0f; bool flag2 = (destinationArray[s_DragCache.m_ActivePartition + 1] - num10) > 0f; if (flag && flag2) { s_DragCache.m_NormalizedPartitionSize += num10; normalizedCascadePartitions[s_DragCache.m_ActivePartition] = s_DragCache.m_NormalizedPartitionSize; if (s_DragCache.m_ActivePartition < (normalizedCascadePartitions.Length - 1)) { normalizedCascadePartitions[s_DragCache.m_ActivePartition + 1] -= num10; } } s_DragCache.m_LastCachedMousePosition = current.mousePosition; current.Use(); break; } break; } }
public static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions) { GUILayout.Label("Cascade splits", new GUILayoutOption[0]); GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Height(28f), GUILayout.ExpandWidth(true) }; Rect position = GUILayoutUtility.GetRect(GUIContent.none, s_CascadeSliderBG, options); GUI.Box(position, GUIContent.none); float x = position.x; float y = position.y + 2f; float num3 = position.width - (normalizedCascadePartitions.Length * 2); Color color = GUI.color; Color backgroundColor = GUI.backgroundColor; int index = -1; float[] destinationArray = new float[normalizedCascadePartitions.Length + 1]; Array.Copy(normalizedCascadePartitions, destinationArray, normalizedCascadePartitions.Length); destinationArray[destinationArray.Length - 1] = 1f - Enumerable.Sum(normalizedCascadePartitions); int controlID = GUIUtility.GetControlID(s_CascadeSliderId, FocusType.Passive); Event current = Event.current; int activePartition = -1; for (int i = 0; i < destinationArray.Length; i++) { float num8 = destinationArray[i]; index = (index + 1) % kCascadeColors.Length; GUI.backgroundColor = kCascadeColors[index]; float width = num3 * num8; Rect rect2 = new Rect(x, y, width, 24f); GUI.Box(rect2, GUIContent.none, s_CascadeSliderBG); x += width; GUI.color = Color.white; Rect rect3 = rect2; string t = string.Format("{0}\n{1:F1}%", i, num8 * 100f); GUI.Label(rect3, GUIContent.Temp(t, t), s_TextCenteredStyle); if (i == (destinationArray.Length - 1)) { break; } GUI.backgroundColor = Color.black; Rect rect4 = rect2; rect4.x = x; rect4.width = 2f; GUI.Box(rect4, GUIContent.none, s_CascadeSliderBG); Rect rect5 = rect4; rect5.xMin -= 2f; rect5.xMax += 2f; if (rect5.Contains(current.mousePosition)) { activePartition = i; } if (s_DragCache == null) { EditorGUIUtility.AddCursorRect(rect5, MouseCursor.ResizeHorizontal, controlID); } x += 2f; } GUI.color = color; GUI.backgroundColor = backgroundColor; EventType typeForControl = current.GetTypeForControl(controlID); if (typeForControl == EventType.MouseDown) { if (activePartition >= 0) { s_DragCache = new DragCache(activePartition, normalizedCascadePartitions[activePartition], current.mousePosition); if (GUIUtility.hotControl == 0) { GUIUtility.hotControl = controlID; } current.Use(); if (s_RestoreSceneView == null) { s_RestoreSceneView = SceneView.lastActiveSceneView; if (s_RestoreSceneView != null) { s_OldSceneDrawMode = s_RestoreSceneView.renderMode; s_OldSceneLightingMode = s_RestoreSceneView.m_SceneLighting; s_RestoreSceneView.renderMode = DrawCameraMode.ShadowCascades; } } } } else if (typeForControl == EventType.MouseUp) { if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; current.Use(); } s_DragCache = null; if (s_RestoreSceneView != null) { s_RestoreSceneView.renderMode = s_OldSceneDrawMode; s_RestoreSceneView.m_SceneLighting = s_OldSceneLightingMode; s_RestoreSceneView = null; } } else if ((typeForControl == EventType.MouseDrag) && (GUIUtility.hotControl == controlID)) { Vector2 vector = current.mousePosition - s_DragCache.m_LastCachedMousePosition; float num10 = vector.x / num3; bool flag = (destinationArray[s_DragCache.m_ActivePartition] + num10) > 0f; bool flag2 = (destinationArray[s_DragCache.m_ActivePartition + 1] - num10) > 0f; if (flag && flag2) { s_DragCache.m_NormalizedPartitionSize += num10; normalizedCascadePartitions[s_DragCache.m_ActivePartition] = s_DragCache.m_NormalizedPartitionSize; if (s_DragCache.m_ActivePartition < (normalizedCascadePartitions.Length - 1)) { normalizedCascadePartitions[s_DragCache.m_ActivePartition + 1] -= num10; } GUI.changed = true; } s_DragCache.m_LastCachedMousePosition = current.mousePosition; current.Use(); } }