diff --git a/CHANGELOG.md b/CHANGELOG.md index f41cff1..7e61aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [10.2.1] - 2020-11-30 + +Version Updated +The version number for this package has increased due to a version update of a related graphics package. + ## [10.2.0] - 2020-10-19 Version Updated diff --git a/Editor/LookDev/CameraController.cs b/Editor/LookDev/CameraController.cs index a9761a0..87fbbb3 100644 --- a/Editor/LookDev/CameraController.cs +++ b/Editor/LookDev/CameraController.cs @@ -38,9 +38,24 @@ enum Direction bool m_InFlyMotion; bool m_IsDragging; - ViewTool m_BehaviorState; static TimeHelper s_Timer = new TimeHelper(); + ViewTool m_BehaviorState; + ViewTool behaviorState + { + get { return m_BehaviorState; } + set + { + if (value != m_BehaviorState && m_BehaviorState == ViewTool.FPS) + { + isDragging = false; + inFlyMotion = false; + m_DirectionKeyPressed = Direction.None; + } + m_BehaviorState = value; + } + } + protected CameraState m_CameraState; DisplayWindow m_Window; protected Action m_Focused; @@ -125,13 +140,13 @@ private void ResetCameraControl() { isDragging = false; inFlyMotion = false; - m_BehaviorState = ViewTool.None; + behaviorState = ViewTool.None; } protected virtual void OnScrollWheel(WheelEvent evt) { // See UnityEditor.SceneViewMotion.HandleScrollWheel - switch (m_BehaviorState) + switch (behaviorState) { case ViewTool.FPS: OnChangeFPSCameraSpeed(evt); break; default: OnZoom(evt); break; @@ -140,7 +155,7 @@ protected virtual void OnScrollWheel(WheelEvent evt) void OnMouseDrag(MouseMoveEvent evt) { - switch (m_BehaviorState) + switch (behaviorState) { case ViewTool.Orbit: OnMouseDragOrbit(evt); break; case ViewTool.FPS: OnMouseDragFPS(evt); break; @@ -241,7 +256,7 @@ void OnKeyDownReset(KeyDownEvent evt) void OnKeyUpOrDownFPS(KeyboardEventBase evt) where T : KeyboardEventBase, new() { - if (m_BehaviorState != ViewTool.FPS) + if (behaviorState != ViewTool.FPS) return; //Note: Keydown is called in loop but between first occurence of the @@ -318,30 +333,41 @@ bool GetKeyCombinationByID(string ID, out KeyCombination combination) return false; } } - + + ViewTool GetBehaviorTool(MouseEventBase evt, bool onMac) where T : MouseEventBase, new() + { + if (evt.button == 2) + return ViewTool.Pan; + else if (evt.button == 0 && evt.ctrlKey && onMac || evt.button == 1 && evt.altKey) + return ViewTool.Zoom; + else if (evt.button == 0) + return ViewTool.Orbit; + else if (evt.button == 1 && !evt.altKey) + return ViewTool.FPS; + return ViewTool.None; + } + void OnMouseUp(MouseUpEvent evt) { - ResetCameraControl(); + bool onMac = Application.platform == RuntimePlatform.OSXEditor; + var state = GetBehaviorTool(evt, onMac); + + if (state == behaviorState) + ResetCameraControl(); evt.StopPropagation(); } void OnMouseDown(MouseDownEvent evt) { bool onMac = Application.platform == RuntimePlatform.OSXEditor; + behaviorState = GetBehaviorTool(evt, onMac); - if (evt.button == 2) - m_BehaviorState = ViewTool.Pan; - else if (evt.button == 0 && evt.ctrlKey && onMac || evt.button == 1 && evt.altKey) + if (behaviorState == ViewTool.Zoom) { - m_BehaviorState = ViewTool.Zoom; m_StartZoom = m_CameraState.viewSize; m_ZoomSpeed = Mathf.Max(Mathf.Abs(m_StartZoom), .3f); m_TotalMotion = 0; } - else if (evt.button == 0) - m_BehaviorState = ViewTool.Orbit; - else if (evt.button == 1 && !evt.altKey) - m_BehaviorState = ViewTool.FPS; // see also SceneView.HandleClickAndDragToFocus() if (evt.button == 1 && onMac) diff --git a/Editor/LookDev/Compositor.cs b/Editor/LookDev/Compositor.cs index 75ef4ca..909ee29 100644 --- a/Editor/LookDev/Compositor.cs +++ b/Editor/LookDev/Compositor.cs @@ -200,25 +200,22 @@ public void Render() if (UnityEditorInternal.RenderDoc.IsLoaded() && UnityEditorInternal.RenderDoc.IsSupported() && m_RenderDocAcquisitionRequested) UnityEditorInternal.RenderDoc.BeginCaptureRenderDoc(m_Displayer as EditorWindow); - using (new UnityEngine.Rendering.VolumeIsolationScope(true)) + switch (m_Contexts.layout.viewLayout) { - switch (m_Contexts.layout.viewLayout) - { - case Layout.FullFirstView: - RenderSingleAndOutput(ViewIndex.First); - break; - case Layout.FullSecondView: - RenderSingleAndOutput(ViewIndex.Second); - break; - case Layout.HorizontalSplit: - case Layout.VerticalSplit: - RenderSingleAndOutput(ViewIndex.First); - RenderSingleAndOutput(ViewIndex.Second); - break; - case Layout.CustomSplit: - RenderCompositeAndOutput(); - break; - } + case Layout.FullFirstView: + RenderSingleAndOutput(ViewIndex.First); + break; + case Layout.FullSecondView: + RenderSingleAndOutput(ViewIndex.Second); + break; + case Layout.HorizontalSplit: + case Layout.VerticalSplit: + RenderSingleAndOutput(ViewIndex.First); + RenderSingleAndOutput(ViewIndex.Second); + break; + case Layout.CustomSplit: + RenderCompositeAndOutput(); + break; } //TODO: make integration EditorWindow agnostic! diff --git a/Editor/LookDev/DisplayWindow.cs b/Editor/LookDev/DisplayWindow.cs index d301482..27ad36a 100644 --- a/Editor/LookDev/DisplayWindow.cs +++ b/Editor/LookDev/DisplayWindow.cs @@ -249,16 +249,10 @@ void ReloadStyleSheets() rootVisualElement.styleSheets.Add(styleSheetLight); } } - - void OnEnable() + + void CreateGUI() { - //Stylesheet - // Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692). - // In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets. - // Waiting for filter on stylesheet (case 1228706) to remove last error. - // On Editor Skin change, OnEnable is called and stylesheets need to be reloaded (case 1278802). - if(EditorApplication.isUpdating) - ReloadStyleSheets(); + ReloadStyleSheets(); //Call the open function to configure LookDev // in case the window where open when last editor session finished. @@ -284,7 +278,10 @@ void OnEnable() ApplyLayout(viewLayout); ApplySidePanelChange(layout.showedSidePanel); + } + void OnEnable() + { Undo.undoRedoPerformed += FullRefreshEnvironmentList; } @@ -672,60 +669,6 @@ void Update() void OnGUI() { - //Stylesheet - // [case 1219692] if LookDev is open while reimporting CoreRP package, - // stylesheet can be null. In this case, we can have a null stylesheet - // registered as it got destroyed. Reloading it. As we cannot just - // remove a null entry, we must filter and reconstruct the while list. - if (styleSheet == null || styleSheet.Equals(null) - || (!EditorGUIUtility.isProSkin && (styleSheetLight == null || styleSheetLight.Equals(null)))) - { - // While (case 1228706) is still on going, we sill close and reopen the look dev. - // This will prevent spawning error at frame. - // Note 2: This actually causes the lookdev to break completely with light theme. - // Until the actual issue is fixed, we'll comment this fix out as it only concerns an upgrade problem. - //LookDev.Close(); - //LookDev.Open(); - //return; - - // Following lines is the correct fix if UIElement filter garbage collected Stylesheet. - - //System.Collections.Generic.List usedStyleSheets = new System.Collections.Generic.List(); - //int currentCount = rootVisualElement.styleSheets.count; - //for (int i = 0; i < currentCount; ++i) - //{ - // StyleSheet sheet = rootVisualElement.styleSheets[i]; - // if (sheet != null && !sheet.Equals(null)) - // usedStyleSheets.Add(sheet); - //} - //rootVisualElement.styleSheets.Clear(); - //foreach (StyleSheet sheet in usedStyleSheets) - // rootVisualElement.styleSheets.Add(sheet); - - //styleSheet = AssetDatabase.LoadAssetAtPath(Style.k_uss); - //if (styleSheet != null && !styleSheet.Equals(null)) - //{ - // rootVisualElement.styleSheets.Add(styleSheet); - // if (!EditorGUIUtility.isProSkin) - // { - // rootVisualElement.styleSheets.Add( - // AssetDatabase.LoadAssetAtPath(Style.k_uss_personal_overload)); - // } - //} - - //if (styleSheet == null || styleSheet.Equals(null)) - //{ - // styleSheet = AssetDatabase.LoadAssetAtPath(Style.k_uss); - // if (styleSheet != null && !styleSheet.Equals(null)) - // rootVisualElement.styleSheets.Add(styleSheet); - //} - //if (!EditorGUIUtility.isProSkin && styleSheetLight != null && !styleSheetLight.Equals(null)) - //{ - // styleSheetLight = AssetDatabase.LoadAssetAtPath(Style.k_uss_personal_overload); - // if (styleSheetLight != null && !styleSheetLight.Equals(null)) - // rootVisualElement.styleSheets.Add(styleSheetLight); - //} - } if(EditorApplication.isUpdating) return; diff --git a/Editor/RenderGraph/RenderGraphViewer.cs b/Editor/RenderGraph/RenderGraphViewer.cs index d945e37..bf654c8 100644 --- a/Editor/RenderGraph/RenderGraphViewer.cs +++ b/Editor/RenderGraph/RenderGraphViewer.cs @@ -111,8 +111,19 @@ void RenderPassLabelChanged(GeometryChangedEvent evt) var topRowElement = m_GraphViewerElement.Q("GraphViewer.TopRowElement"); topRowElement.style.minHeight = passNamesContainerHeight; + } + void LastRenderPassLabelChanged(GeometryChangedEvent evt) + { + var label = evt.currentTarget as Label; + Vector2 textSize = label.MeasureTextSize(label.text, 0, VisualElement.MeasureMode.Undefined, 10, VisualElement.MeasureMode.Undefined); + float textWidth = Mathf.Max(kRenderPassWidth, textSize.x); + + // Keep a margin on the right of the container to avoid label being clipped. + var viewerContainer = m_GraphViewerElement.Q("GraphViewer.ViewerContainer"); + viewerContainer.style.marginRight = Mathf.Max(viewerContainer.style.marginRight.value.value, (textWidth - kRenderPassWidth)); + } void UpdateResourceLifetimeColor(int passIndex, StyleColor colorRead, StyleColor colorWrite) { @@ -164,7 +175,7 @@ void UpdatePassColor((int index, int resourceType) resInfo, StyleColor colorRead VisualElement passElement = m_PassElementsInfo[consumer].pass; if (passElement != null) { - VisualElement passButton = passElement.Q("PassCell"); + VisualElement passButton = passElement.Q("RenderPass.Cell"); passButton.style.backgroundColor = colorRead; } } @@ -178,7 +189,7 @@ void UpdatePassColor((int index, int resourceType) resInfo, StyleColor colorRead VisualElement passElement = m_PassElementsInfo[producer].pass; if (passElement != null) { - VisualElement passButton = passElement.Q("PassCell"); + VisualElement passButton = passElement.Q("RenderPass.Cell"); passButton.style.backgroundColor = colorWrite; } } @@ -215,13 +226,14 @@ void MouseLeaveResourceCallback(MouseLeaveEvent evt, (int index, int resourceTyp VisualElement CreateRenderPass(string name, int index, bool culled) { var container = new VisualElement(); + container.name = "RenderPass"; container.style.width = kRenderPassWidth; container.style.overflow = Overflow.Visible; container.style.flexDirection = FlexDirection.ColumnReverse; container.style.minWidth = kRenderPassWidth; var cell = new Button(); - cell.name = "PassCell"; + cell.name = "RenderPass.Cell"; cell.style.marginBottom = 0.0f; cell.style.marginLeft = 0.0f; cell.style.marginRight = 0.0f; @@ -237,6 +249,7 @@ VisualElement CreateRenderPass(string name, int index, bool culled) container.Add(cell); var label = new Label(name); + label.name = "RenderPass.Label"; label.transform.rotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, -45.0f)); container.Add(label); @@ -247,21 +260,24 @@ VisualElement CreateRenderPass(string name, int index, bool culled) void ResourceNamesContainerChanged(GeometryChangedEvent evt) { + var label = evt.currentTarget as Label; + float textWidth = label.MeasureTextSize(label.text, 0, VisualElement.MeasureMode.Undefined, 10, VisualElement.MeasureMode.Undefined).x; + var cornerElement = m_GraphViewerElement.Q("GraphViewer.Corner"); - cornerElement.style.width = Mathf.Max(evt.newRect.width, cornerElement.style.width.value.value); - cornerElement.style.minWidth = Mathf.Max(evt.newRect.width, cornerElement.style.minWidth.value.value); + cornerElement.style.width = Mathf.Max(textWidth, cornerElement.style.width.value.value); + cornerElement.style.minWidth = Mathf.Max(textWidth, cornerElement.style.minWidth.value.value); // We need to make sure all resource types have the same width m_GraphViewerElement.Query("GraphViewer.Resources.ResourceNames").Build().ForEach((elem) => { - elem.style.width = Mathf.Max(evt.newRect.width, elem.style.width.value.value); - elem.style.minWidth = Mathf.Max(evt.newRect.width, elem.style.minWidth.value.value); + elem.style.width = Mathf.Max(textWidth, elem.style.width.value.value); + elem.style.minWidth = Mathf.Max(textWidth, elem.style.minWidth.value.value); }); m_GraphViewerElement.Query("GraphViewer.Resources.ResourceTypeName").Build().ForEach((elem) => { - elem.style.width = Mathf.Max(evt.newRect.width, elem.style.width.value.value); - elem.style.minWidth = Mathf.Max(evt.newRect.width, elem.style.minWidth.value.value); + elem.style.width = Mathf.Max(textWidth, elem.style.width.value.value); + elem.style.minWidth = Mathf.Max(textWidth, elem.style.minWidth.value.value); }); } @@ -269,6 +285,9 @@ VisualElement CreateResourceLabel(string name, bool imported) { var label = new Label(name); label.style.height = kResourceHeight; + label.style.overflow = Overflow.Hidden; + label.style.textOverflow = TextOverflow.Ellipsis; + label.style.unityTextOverflowPosition = TextOverflowPosition.End; if (imported) label.style.color = m_ImportedResourceColor; else @@ -388,6 +407,7 @@ VisualElement CreateTopRowWithPasses(RenderGraphDebugData debugData, out int fin int passIndex = 0; finalPassCount = 0; + int lastValidPassIndex = -1; foreach (var pass in debugData.passList) { if ((pass.culled && !m_Filter.HasFlag(Filter.CulledPasses)) || !pass.generateDebugData) @@ -401,10 +421,17 @@ VisualElement CreateTopRowWithPasses(RenderGraphDebugData debugData, out int fin m_PassElementsInfo[passIndex].remap = finalPassCount; passNamesElement.Add(passElement); finalPassCount++; + lastValidPassIndex = passIndex; } passIndex++; } + if (lastValidPassIndex > 0) + { + var label = m_PassElementsInfo[lastValidPassIndex].pass.Q