Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal/2021.3/staging #8075

Merged
merged 6 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,19 @@ sealed class DebugWindowSettings : ScriptableObject
// Keep these settings in a separate scriptable object so we can handle undo/redo on them
// without the rest of the debug window interfering
public int currentStateHash;
public int selectedPanel;

public int selectedPanel
{
get => Mathf.Max(0, DebugManager.instance.PanelIndex(selectedPanelDisplayName));
set
{
var displayName = DebugManager.instance.PanelDiplayName(value);
if (!string.IsNullOrEmpty(displayName))
selectedPanelDisplayName = displayName;
}
}

public string selectedPanelDisplayName;

void OnEnable()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using UnityEngine.Assertions;
using UnityEngine.Rendering.UI;
using UnityEngine.UI;
Expand Down Expand Up @@ -214,7 +216,7 @@ public void ReDrawOnScreenDebug()
/// <summary>
/// Get hashcode state of the Debug Window.
/// </summary>
/// <returns></returns>
/// <returns>The calculated hashcode for the current state of the Debug Window.</returns>
public int GetState()
{
int hash = 17;
Expand Down Expand Up @@ -285,6 +287,37 @@ void OnPanelDirty(DebugUI.Panel panel)
onSetDirty();
}

/// <summary>
/// Returns the panel index
/// </summary>
/// <param name="displayName">The displayname for the panel</param>
/// <returns>The index for the panel or -1 if not found.</returns>
public int PanelIndex([DisallowNull] string displayName)
{
displayName ??= string.Empty;

for (int i = 0; i < m_Panels.Count; ++i)
{
if (displayName.Equals(m_Panels[i].displayName, StringComparison.InvariantCultureIgnoreCase))
return i;
}

return -1;
}

/// <summary>
/// Returns the panel display name
/// </summary>
/// <param name="panelIndex">The panelIndex for the panel to get the name</param>
/// <returns>The display name of the panel, or empty string otherwise</returns>
public string PanelDiplayName([DisallowNull] int panelIndex)
{
if (panelIndex < 0 || panelIndex > m_Panels.Count - 1)
return string.Empty;

return m_Panels[panelIndex].displayName;
}

/// <summary>
/// Request DebugWindow to open the specified panel.
/// </summary>
Expand Down Expand Up @@ -312,19 +345,11 @@ public void RequestEditorWindowPanelIndex(int index)
/// <param name="createIfNull">Create the panel if it does not exists.</param>
/// <param name="groupIndex">Group index.</param>
/// <param name="overrideIfExist">Replace an existing panel.</param>
/// <returns></returns>
/// <returns>The requested debug panel or null if it does not exist and createIfNull is set to false</returns>
public DebugUI.Panel GetPanel(string displayName, bool createIfNull = false, int groupIndex = 0, bool overrideIfExist = false)
{
DebugUI.Panel p = null;

foreach (var panel in m_Panels)
{
if (panel.displayName == displayName)
{
p = panel;
break;
}
}
int panelIndex = PanelIndex(displayName);
DebugUI.Panel p = panelIndex >= 0 ? m_Panels[panelIndex] : null;

if (p != null)
{
Expand All @@ -349,6 +374,14 @@ public DebugUI.Panel GetPanel(string displayName, bool createIfNull = false, int
return p;
}

/// <summary>
/// Find the index of the panel from it's display name.
/// </summary>
/// <param name="displayName">The display name of the panel to find.</param>
/// <returns>The index of the panel in the list. -1 if not found.</returns>
public int FindPanelIndex(string displayName)
=> m_Panels.FindIndex(p => p.displayName == displayName);

// TODO: Use a query path here as well instead of a display name
/// <summary>
/// Remove a debug panel.
Expand Down Expand Up @@ -414,8 +447,7 @@ DebugUI.Widget GetItem(string queryPath, DebugUI.IContainer container)
if (child.queryPath == queryPath)
return child;

var containerChild = child as DebugUI.IContainer;
if (containerChild != null)
if (child is DebugUI.IContainer containerChild)
{
var w = GetItem(queryPath, containerChild);
if (w != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ real3 UnpackNormalOctRectEncode(real2 f)
// Ref: http://jcgt.org/published/0003/02/01/paper.pdf "A Survey of Efficient Representations for Independent Unit Vectors"
// Encode with Oct, this function work with any size of output
// return float between [-1, 1]
real2 PackNormalOctQuadEncode(float3 n)
float2 PackNormalOctQuadEncode(float3 n)
{
//float l1norm = dot(abs(n), 1.0);
//float2 res0 = n.xy * (1.0 / l1norm);
Expand All @@ -64,20 +64,21 @@ real2 PackNormalOctQuadEncode(float3 n)

// Optimized version of above code:
n *= rcp(max(dot(abs(n), 1.0), 1e-6));
real t = saturate(-n.z);
return n.xy + real2(n.x >= 0.0 ? t : -t, n.y >= 0.0 ? t : -t);
float t = saturate(-n.z);
return n.xy + float2(n.x >= 0.0 ? t : -t, n.y >= 0.0 ? t : -t);
}

real3 UnpackNormalOctQuadEncode(real2 f)
float3 UnpackNormalOctQuadEncode(float2 f)
{
real3 n = real3(f.x, f.y, 1.0 - abs(f.x) - abs(f.y));
// NOTE: Do NOT use abs() in this line. It causes miscompilations. (UUM-62216, UUM-70600)
float3 n = float3(f.x, f.y, 1.0 - (f.x < 0 ? -f.x : f.x) - (f.y < 0 ? -f.y : f.y));

//float2 val = 1.0 - abs(n.yx);
//n.xy = (n.zz < float2(0.0, 0.0) ? (n.xy >= 0.0 ? val : -val) : n.xy);

// Optimized version of above code:
real t = max(-n.z, 0.0);
n.xy += real2(n.x >= 0.0 ? -t : t, n.y >= 0.0 ? -t : t);
float t = max(-n.z, 0.0);
n.xy += float2(n.x >= 0.0 ? -t : t, n.y >= 0.0 ? -t : t);

return normalize(n);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@
* [Light Layers](lighting/light-layers.md)
* [Lens Flare asset](shared/lens-flare/lens-flare-asset.md)
* [Cameras](cameras.md)
* [The Universal Additional Camera Data component](universal-additional-camera-data.md)
* [Render Type](camera-types-and-render-type.md)
* [Working with multiple cameras](cameras-multiple.md)
* [Camera Stacking](camera-stacking.md)
* [Rendering from multiple Cameras to the same render target](rendering-to-the-same-render-target.md)
* [Rendering to a Render Texture](rendering-to-a-render-texture.md)
* [Clearing, rendering order and overdraw](cameras-advanced.md)
* [Anti-aliasing](anti-aliasing.md)
* [Camera component reference](camera-component-reference.md)

* [Cameras in URP](cameras/camera-differences-in-urp.md)
* [Understand camera render order](cameras-advanced.md)
* [Camera render types](camera-types-and-render-type.md)
* [Anti-aliasing in URP](anti-aliasing.md)
* [Use multiple cameras](cameras-multiple.md)
* [Understand camera stacking](cameras/camera-stacking-concepts.md)
* [Set up a camera stack](camera-stacking.md)
* [Add and remove cameras in a camera stack](cameras/add-and-remove-cameras-in-a-stack.md)
* [Set up split-screen rendering](rendering-to-the-same-render-target.md)
* [Apply different post processing effects to separate cameras](cameras/apply-different-post-proc-to-cameras.md)
* [Render a camera's output to a Render Texture](rendering-to-a-render-texture.md)
* [Customize a camera](universal-additional-camera-data.md)
* [Camera component properties](camera-component-reference.md)
* [Physical Camera properties](cameras/physical-camera-reference.md)
* [Post-processing](integration-with-post-processing.md)
* [How to configure](integration-with-post-processing.md#post-proc-how-to)
* [Volumes](Volumes.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ To enable MSAA:

For more information on the available settings, see the [MSAA setings in the URP Asset](universalrp-asset.md#quality).

**Note**: On mobile platforms that don't support the [StoreAndResolve](https://docs.unity3d.com/ScriptReference/Rendering.RenderBufferStoreAction.StoreAndResolve.html) store action, if **Opaque Texture** is selected in the **URP Asset**, Unity ignores the **MSAA** property at runtime (as if **MSAA** is set to **Disabled**).
> [!NOTE]
> On mobile platforms that don't support the [StoreAndResolve](https://docs.unity3d.com/ScriptReference/Rendering.RenderBufferStoreAction.StoreAndResolve.html) store action, if **Opaque Texture** is selected in the **URP Asset**, Unity ignores the **MSAA** property at runtime (as if **MSAA** is set to **Disabled**).
Loading
Loading