public static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions) { GUILayout.Label("Cascade splits"); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG, new GUILayoutOption[2] { GUILayout.Height(28f), GUILayout.ExpandWidth(true) }); GUI.Box(rect, GUIContent.none); float x = rect.x; float y = rect.y + 2f; float num1 = rect.width - (float)(normalizedCascadePartitions.Length * 2); Color color = GUI.color; Color backgroundColor = GUI.backgroundColor; int index1 = -1; float[] numArray = new float[normalizedCascadePartitions.Length + 1]; Array.Copy((Array)normalizedCascadePartitions, (Array)numArray, normalizedCascadePartitions.Length); numArray[numArray.Length - 1] = 1f - ((IEnumerable <float>)normalizedCascadePartitions).Sum(); int controlId = GUIUtility.GetControlID(ShadowCascadeSplitGUI.s_CascadeSliderId, FocusType.Passive); Event current = Event.current; int activePartition = -1; for (int index2 = 0; index2 < numArray.Length; ++index2) { float num2 = numArray[index2]; index1 = (index1 + 1) % ShadowCascadeSplitGUI.kCascadeColors.Length; GUI.backgroundColor = ShadowCascadeSplitGUI.kCascadeColors[index1]; float width = num1 * num2; Rect position1 = new Rect(x, y, width, 24f); GUI.Box(position1, GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG); float num3 = x + width; GUI.color = Color.white; Rect position2 = position1; string str = string.Format("{0}\n{1:F1}%", (object)index2, (object)(float)((double)num2 * 100.0)); GUI.Label(position2, GUIContent.Temp(str, str), ShadowCascadeSplitGUI.s_TextCenteredStyle); if (index2 != numArray.Length - 1) { GUI.backgroundColor = Color.black; Rect position3 = position1; position3.x = num3; position3.width = 2f; GUI.Box(position3, GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG); Rect position4 = position3; position4.xMin -= 2f; position4.xMax += 2f; if (position4.Contains(current.mousePosition)) { activePartition = index2; } if (ShadowCascadeSplitGUI.s_DragCache == null) { EditorGUIUtility.AddCursorRect(position4, MouseCursor.ResizeHorizontal, controlId); } x = num3 + 2f; } else { break; } } GUI.color = color; GUI.backgroundColor = backgroundColor; switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if (activePartition < 0) { break; } ShadowCascadeSplitGUI.s_DragCache = new ShadowCascadeSplitGUI.DragCache(activePartition, normalizedCascadePartitions[activePartition], current.mousePosition); if (GUIUtility.hotControl == 0) { GUIUtility.hotControl = controlId; } current.Use(); if (!((UnityEngine.Object)ShadowCascadeSplitGUI.s_RestoreSceneView == (UnityEngine.Object)null)) { break; } ShadowCascadeSplitGUI.s_RestoreSceneView = SceneView.lastActiveSceneView; if (!((UnityEngine.Object)ShadowCascadeSplitGUI.s_RestoreSceneView != (UnityEngine.Object)null)) { break; } ShadowCascadeSplitGUI.s_OldSceneDrawMode = ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode; ShadowCascadeSplitGUI.s_OldSceneLightingMode = ShadowCascadeSplitGUI.s_RestoreSceneView.m_SceneLighting; ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode = DrawCameraMode.ShadowCascades; break; case EventType.MouseUp: if (GUIUtility.hotControl == controlId) { GUIUtility.hotControl = 0; current.Use(); } ShadowCascadeSplitGUI.s_DragCache = (ShadowCascadeSplitGUI.DragCache)null; if (!((UnityEngine.Object)ShadowCascadeSplitGUI.s_RestoreSceneView != (UnityEngine.Object)null)) { break; } ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode = ShadowCascadeSplitGUI.s_OldSceneDrawMode; ShadowCascadeSplitGUI.s_RestoreSceneView.m_SceneLighting = ShadowCascadeSplitGUI.s_OldSceneLightingMode; ShadowCascadeSplitGUI.s_RestoreSceneView = (SceneView)null; break; case EventType.MouseDrag: if (GUIUtility.hotControl != controlId) { break; } float num4 = (current.mousePosition - ShadowCascadeSplitGUI.s_DragCache.m_LastCachedMousePosition).x / num1; if ((double)numArray[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition] + (double)num4 > 0.0 && (double)numArray[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition + 1] - (double)num4 > 0.0) { ShadowCascadeSplitGUI.s_DragCache.m_NormalizedPartitionSize += num4; normalizedCascadePartitions[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition] = ShadowCascadeSplitGUI.s_DragCache.m_NormalizedPartitionSize; if (ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition < normalizedCascadePartitions.Length - 1) { normalizedCascadePartitions[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition + 1] -= num4; } } ShadowCascadeSplitGUI.s_DragCache.m_LastCachedMousePosition = current.mousePosition; current.Use(); break; } }
public static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions) { GUILayout.Label("Cascade splits"); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG, new GUILayoutOption[2]{ GUILayout.Height(28f), GUILayout.ExpandWidth(true) }); GUI.Box(rect, GUIContent.none); float x = rect.x; float y = rect.y + 2f; float num1 = rect.width - (float) (normalizedCascadePartitions.Length * 2); Color color = GUI.color; Color backgroundColor = GUI.backgroundColor; int index1 = -1; float[] numArray = new float[normalizedCascadePartitions.Length + 1]; Array.Copy((Array) normalizedCascadePartitions, (Array) numArray, normalizedCascadePartitions.Length); numArray[numArray.Length - 1] = 1f - ((IEnumerable<float>) normalizedCascadePartitions).Sum(); int controlId = GUIUtility.GetControlID(ShadowCascadeSplitGUI.s_CascadeSliderId, FocusType.Passive); Event current = Event.current; int activePartition = -1; for (int index2 = 0; index2 < numArray.Length; ++index2) { float num2 = numArray[index2]; index1 = (index1 + 1) % ShadowCascadeSplitGUI.kCascadeColors.Length; GUI.backgroundColor = ShadowCascadeSplitGUI.kCascadeColors[index1]; float width = num1 * num2; Rect position1 = new Rect(x, y, width, 24f); GUI.Box(position1, GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG); float num3 = x + width; GUI.color = Color.white; Rect position2 = position1; string str = string.Format("{0}\n{1:F1}%", (object) index2, (object) (float) ((double) num2 * 100.0)); GUI.Label(position2, GUIContent.Temp(str, str), ShadowCascadeSplitGUI.s_TextCenteredStyle); if (index2 != numArray.Length - 1) { GUI.backgroundColor = Color.black; Rect position3 = position1; position3.x = num3; position3.width = 2f; GUI.Box(position3, GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG); Rect position4 = position3; position4.xMin -= 2f; position4.xMax += 2f; if (position4.Contains(current.mousePosition)) activePartition = index2; if (ShadowCascadeSplitGUI.s_DragCache == null) EditorGUIUtility.AddCursorRect(position4, MouseCursor.ResizeHorizontal, controlId); x = num3 + 2f; } else break; } GUI.color = color; GUI.backgroundColor = backgroundColor; switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: if (activePartition < 0) break; ShadowCascadeSplitGUI.s_DragCache = new ShadowCascadeSplitGUI.DragCache(activePartition, normalizedCascadePartitions[activePartition], current.mousePosition); if (GUIUtility.hotControl == 0) GUIUtility.hotControl = controlId; current.Use(); if (!((UnityEngine.Object) ShadowCascadeSplitGUI.s_RestoreSceneView == (UnityEngine.Object) null)) break; ShadowCascadeSplitGUI.s_RestoreSceneView = SceneView.lastActiveSceneView; if (!((UnityEngine.Object) ShadowCascadeSplitGUI.s_RestoreSceneView != (UnityEngine.Object) null)) break; ShadowCascadeSplitGUI.s_OldSceneDrawMode = ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode; ShadowCascadeSplitGUI.s_OldSceneLightingMode = ShadowCascadeSplitGUI.s_RestoreSceneView.m_SceneLighting; ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode = DrawCameraMode.ShadowCascades; break; case EventType.MouseUp: if (GUIUtility.hotControl == controlId) { GUIUtility.hotControl = 0; current.Use(); } ShadowCascadeSplitGUI.s_DragCache = (ShadowCascadeSplitGUI.DragCache) null; if (!((UnityEngine.Object) ShadowCascadeSplitGUI.s_RestoreSceneView != (UnityEngine.Object) null)) break; ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode = ShadowCascadeSplitGUI.s_OldSceneDrawMode; ShadowCascadeSplitGUI.s_RestoreSceneView.m_SceneLighting = ShadowCascadeSplitGUI.s_OldSceneLightingMode; ShadowCascadeSplitGUI.s_RestoreSceneView = (SceneView) null; break; case EventType.MouseDrag: if (GUIUtility.hotControl != controlId) break; float num4 = (current.mousePosition - ShadowCascadeSplitGUI.s_DragCache.m_LastCachedMousePosition).x / num1; if ((double) numArray[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition] + (double) num4 > 0.0 && (double) numArray[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition + 1] - (double) num4 > 0.0) { ShadowCascadeSplitGUI.s_DragCache.m_NormalizedPartitionSize += num4; normalizedCascadePartitions[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition] = ShadowCascadeSplitGUI.s_DragCache.m_NormalizedPartitionSize; if (ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition < normalizedCascadePartitions.Length - 1) normalizedCascadePartitions[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition + 1] -= num4; } ShadowCascadeSplitGUI.s_DragCache.m_LastCachedMousePosition = current.mousePosition; current.Use(); break; } }
public static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions) { GUILayout.Label("Cascade splits", new GUILayoutOption[0]); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG, new GUILayoutOption[] { GUILayout.Height(28f), GUILayout.ExpandWidth(true) }); GUI.Box(rect, GUIContent.none); float num = rect.x; float y = rect.y + 2f; float num2 = rect.width - (float)(normalizedCascadePartitions.Length * 2); Color color = GUI.color; Color backgroundColor = GUI.backgroundColor; int num3 = -1; float[] array = new float[normalizedCascadePartitions.Length + 1]; Array.Copy(normalizedCascadePartitions, array, normalizedCascadePartitions.Length); array[array.Length - 1] = 1f - normalizedCascadePartitions.Sum(); int controlID = GUIUtility.GetControlID(ShadowCascadeSplitGUI.s_CascadeSliderId, FocusType.Passive); Event current = Event.current; int num4 = -1; for (int i = 0; i < array.Length; i++) { float num5 = array[i]; num3 = (num3 + 1) % ShadowCascadeSplitGUI.kCascadeColors.Length; GUI.backgroundColor = ShadowCascadeSplitGUI.kCascadeColors[num3]; float num6 = num2 * num5; Rect rect2 = new Rect(num, y, num6, 24f); GUI.Box(rect2, GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG); num += num6; GUI.color = Color.white; Rect position = rect2; string text = string.Format("{0}\n{1:F1}%", i, num5 * 100f); GUI.Label(position, GUIContent.Temp(text, text), ShadowCascadeSplitGUI.s_TextCenteredStyle); if (i == array.Length - 1) { break; } GUI.backgroundColor = Color.black; Rect rect3 = rect2; rect3.x = num; rect3.width = 2f; GUI.Box(rect3, GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG); Rect position2 = rect3; position2.xMin -= 2f; position2.xMax += 2f; if (position2.Contains(current.mousePosition)) { num4 = i; } if (ShadowCascadeSplitGUI.s_DragCache == null) { EditorGUIUtility.AddCursorRect(position2, MouseCursor.ResizeHorizontal, controlID); } num += 2f; } GUI.color = color; GUI.backgroundColor = backgroundColor; EventType typeForControl = current.GetTypeForControl(controlID); if (typeForControl != EventType.MouseDown) { if (typeForControl != EventType.MouseUp) { if (typeForControl == EventType.MouseDrag) { if (GUIUtility.hotControl == controlID) { float num7 = (current.mousePosition - ShadowCascadeSplitGUI.s_DragCache.m_LastCachedMousePosition).x / num2; bool flag = array[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition] + num7 > 0f; bool flag2 = array[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition + 1] - num7 > 0f; if (flag && flag2) { ShadowCascadeSplitGUI.s_DragCache.m_NormalizedPartitionSize += num7; normalizedCascadePartitions[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition] = ShadowCascadeSplitGUI.s_DragCache.m_NormalizedPartitionSize; if (ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition < normalizedCascadePartitions.Length - 1) { normalizedCascadePartitions[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition + 1] -= num7; } GUI.changed = true; } ShadowCascadeSplitGUI.s_DragCache.m_LastCachedMousePosition = current.mousePosition; current.Use(); } } } else { if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; current.Use(); } ShadowCascadeSplitGUI.s_DragCache = null; if (ShadowCascadeSplitGUI.s_RestoreSceneView != null) { ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode = ShadowCascadeSplitGUI.s_OldSceneDrawMode; ShadowCascadeSplitGUI.s_RestoreSceneView.m_SceneLighting = ShadowCascadeSplitGUI.s_OldSceneLightingMode; ShadowCascadeSplitGUI.s_RestoreSceneView = null; } } } else if (num4 >= 0) { ShadowCascadeSplitGUI.s_DragCache = new ShadowCascadeSplitGUI.DragCache(num4, normalizedCascadePartitions[num4], current.mousePosition); if (GUIUtility.hotControl == 0) { GUIUtility.hotControl = controlID; } current.Use(); if (ShadowCascadeSplitGUI.s_RestoreSceneView == null) { ShadowCascadeSplitGUI.s_RestoreSceneView = SceneView.lastActiveSceneView; if (ShadowCascadeSplitGUI.s_RestoreSceneView != null) { ShadowCascadeSplitGUI.s_OldSceneDrawMode = ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode; ShadowCascadeSplitGUI.s_OldSceneLightingMode = ShadowCascadeSplitGUI.s_RestoreSceneView.m_SceneLighting; ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode = DrawCameraMode.ShadowCascades; } } } }
public static void HandleCascadeSliderGUI(ref float[] normalizedCascadePartitions) { GUILayout.Label("Cascade splits", new GUILayoutOption[0]); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG, new GUILayoutOption[] { GUILayout.Height(28f), GUILayout.ExpandWidth(true) }); GUI.Box(rect, GUIContent.none); float num = rect.x; float top = rect.y + 2f; float num2 = rect.width - (float)(normalizedCascadePartitions.Length * 2); Color color = GUI.color; Color backgroundColor = GUI.backgroundColor; int num3 = -1; float[] array = new float[normalizedCascadePartitions.Length + 1]; Array.Copy(normalizedCascadePartitions, array, normalizedCascadePartitions.Length); array[array.Length - 1] = 1f - normalizedCascadePartitions.Sum(); int controlID = GUIUtility.GetControlID(ShadowCascadeSplitGUI.s_CascadeSliderId, FocusType.Passive); Event current = Event.current; int num4 = -1; for (int i = 0; i < array.Length; i++) { float num5 = array[i]; num3 = (num3 + 1) % ShadowCascadeSplitGUI.kCascadeColors.Length; GUI.backgroundColor = ShadowCascadeSplitGUI.kCascadeColors[num3]; float num6 = num2 * num5; Rect rect2 = new Rect(num, top, num6, 24f); GUI.Box(rect2, GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG); num += num6; GUI.color = Color.white; Rect position = rect2; string text = string.Format("{0}\n{1:F1}%", i, num5 * 100f); GUI.Label(position, GUIContent.Temp(text, text), ShadowCascadeSplitGUI.s_TextCenteredStyle); if (i == array.Length - 1) { break; } GUI.backgroundColor = Color.black; Rect rect3 = rect2; rect3.x = num; rect3.width = 2f; GUI.Box(rect3, GUIContent.none, ShadowCascadeSplitGUI.s_CascadeSliderBG); Rect position2 = rect3; position2.xMin -= 2f; position2.xMax += 2f; if (position2.Contains(current.mousePosition)) { num4 = i; } if (ShadowCascadeSplitGUI.s_DragCache == null) { EditorGUIUtility.AddCursorRect(position2, MouseCursor.ResizeHorizontal, controlID); } num += 2f; } GUI.color = color; GUI.backgroundColor = backgroundColor; switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: if (num4 >= 0) { ShadowCascadeSplitGUI.s_DragCache = new ShadowCascadeSplitGUI.DragCache(num4, normalizedCascadePartitions[num4], current.mousePosition); if (GUIUtility.hotControl == 0) { GUIUtility.hotControl = controlID; } current.Use(); if (ShadowCascadeSplitGUI.s_RestoreSceneView == null) { ShadowCascadeSplitGUI.s_RestoreSceneView = SceneView.lastActiveSceneView; if (ShadowCascadeSplitGUI.s_RestoreSceneView != null) { ShadowCascadeSplitGUI.s_OldSceneDrawMode = ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode; ShadowCascadeSplitGUI.s_OldSceneLightingMode = ShadowCascadeSplitGUI.s_RestoreSceneView.m_SceneLighting; ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode = DrawCameraMode.ShadowCascades; } } } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; current.Use(); } ShadowCascadeSplitGUI.s_DragCache = null; if (ShadowCascadeSplitGUI.s_RestoreSceneView != null) { ShadowCascadeSplitGUI.s_RestoreSceneView.renderMode = ShadowCascadeSplitGUI.s_OldSceneDrawMode; ShadowCascadeSplitGUI.s_RestoreSceneView.m_SceneLighting = ShadowCascadeSplitGUI.s_OldSceneLightingMode; ShadowCascadeSplitGUI.s_RestoreSceneView = null; } break; case EventType.MouseDrag: if (GUIUtility.hotControl == controlID) { float num7 = (current.mousePosition - ShadowCascadeSplitGUI.s_DragCache.m_LastCachedMousePosition).x / num2; bool flag = array[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition] + num7 > 0f; bool flag2 = array[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition + 1] - num7 > 0f; if (flag && flag2) { ShadowCascadeSplitGUI.s_DragCache.m_NormalizedPartitionSize += num7; normalizedCascadePartitions[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition] = ShadowCascadeSplitGUI.s_DragCache.m_NormalizedPartitionSize; if (ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition < normalizedCascadePartitions.Length - 1) { normalizedCascadePartitions[ShadowCascadeSplitGUI.s_DragCache.m_ActivePartition + 1] -= num7; } } ShadowCascadeSplitGUI.s_DragCache.m_LastCachedMousePosition = current.mousePosition; current.Use(); } break; } }