267 changes: 0 additions & 267 deletions Editor/Mono/Display/EditorDisplayManager.cs

This file was deleted.

79 changes: 0 additions & 79 deletions Editor/Mono/Display/EditorDisplaySettingsProfile.cs

This file was deleted.

41 changes: 0 additions & 41 deletions Editor/Mono/Display/EditorDisplayUtility.bindings.cs

This file was deleted.

1,237 changes: 0 additions & 1,237 deletions Editor/Mono/Display/EditorFullscreenController.cs

This file was deleted.

21 changes: 0 additions & 21 deletions Editor/Mono/Display/FullscreenSettingsForAttribute.cs

This file was deleted.

81 changes: 0 additions & 81 deletions Editor/Mono/Display/GameViewFullscreenSettings.cs

This file was deleted.

21 changes: 0 additions & 21 deletions Editor/Mono/Display/IPlayModeViewFullscreenSettings.cs

This file was deleted.

67 changes: 56 additions & 11 deletions Editor/Mono/EditorGUI.cs
Expand Up @@ -2901,7 +2901,7 @@ internal static float Slider(Rect position, GUIContent label, float value, float
var id = GUIUtility.GetControlID(s_SliderHash, FocusType.Keyboard, position);
var controlRect = PrefixLabel(position, id, label);
var dragZone = LabelHasContent(label) ? EditorGUIUtility.DragZoneRect(position) : new Rect(); // Ensure dragzone is empty when we have no label
return DoSlider(controlRect, dragZone, id, value, sliderMin, sliderMax, kFloatFieldFormatString, textFieldMin, textFieldMax, 1f,
return DoSlider(controlRect, dragZone, id, value, sliderMin, sliderMax, kFloatFieldFormatString, textFieldMin, textFieldMax, 1f, 1f,
textfieldStyle, sliderStyle, thumbStyle, sliderBackground, thumbStyleExtent);
}

Expand All @@ -2925,6 +2925,24 @@ internal static float PowerSlider(Rect position, GUIContent label, float sliderV
return DoSlider(controlRect, dragZone, id, sliderValue, leftValue, rightValue, kFloatFieldFormatString, textfieldStyle, power);
}

internal static int LogarithmicIntSlider(Rect position, string label, int sliderValue, int leftValue, int rightValue, int logbase, int textFieldMin, int textFieldMax)
{
return LogarithmicIntSlider(position, EditorGUIUtility.TempContent(label), sliderValue, leftValue, rightValue, logbase, textFieldMin, textFieldMax);
}

internal static int LogarithmicIntSlider(Rect position, GUIContent label, int sliderValue, int leftValue, int rightValue, int logbase, int textFieldMin, int textFieldMax)
{
return LogarithmicIntSlider(position, label, sliderValue, leftValue, rightValue, EditorStyles.numberField, logbase, textFieldMin, textFieldMax);
}

internal static int LogarithmicIntSlider(Rect position, GUIContent label, int sliderValue, int leftValue, int rightValue, GUIStyle textfieldStyle, int logbase, int textFieldMin, int textFieldMax)
{
int id = GUIUtility.GetControlID(s_SliderHash, FocusType.Keyboard, position);
Rect controlRect = PrefixLabel(position, id, label);
Rect dragZone = LabelHasContent(label) ? EditorGUIUtility.DragZoneRect(position) : new Rect(); // Ensure dragzone is empty when we have no label
return Mathf.RoundToInt(DoSlider(controlRect, dragZone, id, (float) sliderValue, (float) leftValue, (float) rightValue, kIntFieldFormatString, power:1, logbase: logbase, textFieldMin: textFieldMin, textFieldMax: textFieldMax));
}

private static float PowPreserveSign(float f, float p)
{
var result = Mathf.Pow(Mathf.Abs(f), p);
Expand Down Expand Up @@ -3319,11 +3337,11 @@ internal static void Slider(Rect position, SerializedProperty property, float sl
EndProperty();
}

internal static int IntSlider(Rect position, int value, int leftValue, int rightValue, float power = -1,
internal static int IntSlider(Rect position, int value, int leftValue, int rightValue, float power = -1, float logbase = 1,
GUIStyle textfieldStyle = null, GUIStyle sliderStyle = null, GUIStyle thumbStyle = null, Texture2D sliderBackground = null, GUIStyle thumbStyleExtent = null)
{
int id = GUIUtility.GetControlID(s_SliderHash, FocusType.Keyboard, position);
return Mathf.RoundToInt(DoSlider(IndentedRect(position), EditorGUIUtility.DragZoneRect(position), id, value, leftValue, rightValue, kIntFieldFormatString, power,
return Mathf.RoundToInt(DoSlider(IndentedRect(position), EditorGUIUtility.DragZoneRect(position), id, value, leftValue, rightValue, kIntFieldFormatString, power, logbase,
textfieldStyle ?? EditorStyles.numberField,
sliderStyle ?? GUI.skin.horizontalSlider,
thumbStyle ?? GUI.skin.horizontalSliderThumb,
Expand Down Expand Up @@ -3392,24 +3410,29 @@ internal static void DoTwoLabels(Rect rect, GUIContent leftLabel, GUIContent rig
labelStyle.alignment = oldAlignment;
}

internal static float DoSlider(Rect position, Rect dragZonePosition, int id, float value, float left, float right, string formatString, float power = 1f)
internal static float DoSlider(Rect position, Rect dragZonePosition, int id, float value, float left, float right, string formatString, float power = 1f, float logbase = 1f)
{
return DoSlider(position, dragZonePosition, id, value, left, right, formatString, power, EditorStyles.numberField, GUI.skin.horizontalSlider, GUI.skin.horizontalSliderThumb, null, GUI.skin.horizontalSliderThumbExtent);
return DoSlider(position, dragZonePosition, id, value, left, right, formatString, power, logbase, EditorStyles.numberField, GUI.skin.horizontalSlider, GUI.skin.horizontalSliderThumb, null, GUI.skin.horizontalSliderThumbExtent);
}

internal static float DoSlider(Rect position, Rect dragZonePosition, int id, float value, float left, float right, string formatString, GUIStyle textfieldStyle, float power = 1f)
internal static float DoSlider(Rect position, Rect dragZonePosition, int id, float value, float left, float right, string formatString, float textFieldMin, float textFieldMax, float power = 1f, float logbase = 1f)
{
return DoSlider(position, dragZonePosition, id, value, left, right, formatString, power, textfieldStyle, GUI.skin.horizontalSlider, GUI.skin.horizontalSliderThumb, null, GUI.skin.horizontalSliderThumbExtent);
return DoSlider(position, dragZonePosition, id, value, left, right, formatString, textFieldMin, textFieldMax, power, logbase, EditorStyles.numberField, GUI.skin.horizontalSlider, GUI.skin.horizontalSliderThumb, null, GUI.skin.horizontalSliderThumbExtent);
}

private static float DoSlider(Rect position, Rect dragZonePosition, int id, float value, float left, float right, string formatString, float power, GUIStyle textfieldStyle, GUIStyle sliderStyle, GUIStyle thumbStyle, Texture2D sliderBackground, GUIStyle thumbStyleExtent)
internal static float DoSlider(Rect position, Rect dragZonePosition, int id, float value, float left, float right, string formatString, GUIStyle textfieldStyle, float power = 1f, float logbase = 1f)
{
return DoSlider(position, dragZonePosition, id, value, left, right, formatString, left, right, power, textfieldStyle, sliderStyle, thumbStyle, sliderBackground, thumbStyleExtent);
return DoSlider(position, dragZonePosition, id, value, left, right, formatString, power, logbase, textfieldStyle, GUI.skin.horizontalSlider, GUI.skin.horizontalSliderThumb, null, GUI.skin.horizontalSliderThumbExtent);
}

private static float DoSlider(Rect position, Rect dragZonePosition, int id, float value, float left, float right, string formatString, float power, float logbase, GUIStyle textfieldStyle, GUIStyle sliderStyle, GUIStyle thumbStyle, Texture2D sliderBackground, GUIStyle thumbStyleExtent)
{
return DoSlider(position, dragZonePosition, id, value, left, right, formatString, left, right, power, logbase, textfieldStyle, sliderStyle, thumbStyle, sliderBackground, thumbStyleExtent);
}

private static float DoSlider(
Rect position, Rect dragZonePosition, int id, float value, float sliderMin, float sliderMax, string formatString, float textFieldMin
, float textFieldMax, float power, GUIStyle textfieldStyle, GUIStyle sliderStyle, GUIStyle thumbStyle, Texture2D sliderBackground, GUIStyle thumbStyleExtent
, float textFieldMax, float power, float logbase, GUIStyle textfieldStyle, GUIStyle sliderStyle, GUIStyle thumbStyle, Texture2D sliderBackground, GUIStyle thumbStyleExtent
)
{
int sliderId = GUIUtility.GetControlID(s_SliderKnobHash, FocusType.Passive, position);
Expand Down Expand Up @@ -3440,6 +3463,12 @@ private static float DoSlider(Rect position, Rect dragZonePosition, int id, floa
remapRight = PowPreserveSign(sliderMax, 1f / power);
newSliderValue = PowPreserveSign(value, 1f / power);
}
else if (logbase != 1f)
{
remapLeft = Mathf.Log(sliderMin, logbase);
remapRight = Mathf.Log(sliderMax, logbase);
newSliderValue = Mathf.Log(value, logbase);
}

Rect sliderRect = new Rect(position.x, position.y, sWidth, position.height);

Expand All @@ -3455,6 +3484,11 @@ private static float DoSlider(Rect position, Rect dragZonePosition, int id, floa
newSliderValue = PowPreserveSign(newSliderValue, power);
newSliderValue = Mathf.Clamp(newSliderValue, Mathf.Min(sliderMin, sliderMax), Mathf.Max(sliderMin, sliderMax));
}
else if (logbase != 1f)
{
newSliderValue = Mathf.Pow(logbase, newSliderValue);
}


// Do slider labels if present
if (EditorGUIUtility.sliderLabels.HasLabels())
Expand Down Expand Up @@ -9823,6 +9857,17 @@ internal static float PowerSlider(GUIContent label, float value, float leftValue
return EditorGUI.PowerSlider(r, label, value, leftValue, rightValue, power);
}

internal static int LogarithmicIntSlider(string label, int value, int leftValue, int rightValue, int logbase, int textFieldMin, int textFieldMax, params GUILayoutOption[] options)
{
return LogarithmicIntSlider(EditorGUIUtility.TempContent(label), value, leftValue, rightValue, logbase, textFieldMin, textFieldMax, options);
}

internal static int LogarithmicIntSlider(GUIContent label, int value, int leftValue, int rightValue, int logbase, int textFieldMin, int textFieldMax, params GUILayoutOption[] options)
{
Rect r = s_LastRect = GetSliderRect(true, options);
return EditorGUI.LogarithmicIntSlider(r, label, value, leftValue, rightValue, logbase, textFieldMin, textFieldMax);
}

public static int IntSlider(int value, int leftValue, int rightValue, params GUILayoutOption[] options)
{
Rect r = s_LastRect = GetSliderRect(false, options);
Expand All @@ -9842,7 +9887,7 @@ internal static int IntSlider(int value, int leftValue, int rightValue, float po
GUIStyle textfieldStyle, GUIStyle sliderStyle, GUIStyle thumbStyle, Texture2D sliderBackground, GUIStyle thumbStyleExtent, params GUILayoutOption[] options)
{
Rect r = s_LastRect = GetSliderRect(false, sliderStyle, options);
return EditorGUI.IntSlider(r, value, leftValue, rightValue, power, textfieldStyle, sliderStyle, thumbStyle, sliderBackground, thumbStyleExtent);
return EditorGUI.IntSlider(r, value, leftValue, rightValue, power, logbase: 1, textfieldStyle, sliderStyle, thumbStyle, sliderBackground, thumbStyleExtent);
}

public static int IntSlider(string label, int value, int leftValue, int rightValue, params GUILayoutOption[] options)
Expand Down
9 changes: 8 additions & 1 deletion Editor/Mono/EditorUtility.cs
Expand Up @@ -506,10 +506,17 @@ internal static void DisplayObjectContextMenu(Rect position, Object[] context, i
info.instanceObject = targetComponent;
info.assetPath = AssetDatabase.GetAssetPath(sourceGo);
GameObject rootObject = PrefabUtility.GetRootGameObject(sourceGo);
if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(instanceGo))
if (targetComponent.hideFlags.HasFlag(HideFlags.DontSaveInEditor)
|| !PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject)
|| EditorUtility.IsPersistent(instanceGo))
{
pm.AddDisabledItem(menuItemContent);
}
else
{
pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabAddedComponent, info);
}
},
(menuItemContent) =>
{
Expand Down
11 changes: 2 additions & 9 deletions Editor/Mono/GI/LightBaker.bindings.cs
Expand Up @@ -544,19 +544,12 @@ public Resolution lightmapResolution(UInt32 index)
public extern LightmapRequest[] GetLightmapRequests();
public extern void SetLightmapRequests(LightmapRequest[] requests);

private extern unsafe void SetProbePositions([Span("positionsLength", isReadOnly: true)] Vector3* positions, int positionsLength);

public void SetProbePositions(Vector3[] positions)
{
SetProbePositions(positions.AsSpan());
}
public unsafe void SetProbePositions(ReadOnlySpan<Vector3> positions)
{
fixed (Vector3* positionsPtr = positions)
{
SetProbePositions(positionsPtr, positions.Length);
}
}
public extern void SetProbePositions(ReadOnlySpan<Vector3> positions);

public extern Vector3[] GetProbePositions();
}
extern static public Result Bake(BakeInput input);
Expand Down
33 changes: 7 additions & 26 deletions Editor/Mono/GI/Lightmapping.bindings.cs
Expand Up @@ -672,29 +672,18 @@ public sealed partial class Lightmapping
[StaticAccessor("BakedGISceneManager::Get()", StaticAccessorType.Arrow)]
public static extern bool probesIgnoreDirectEnvironment { get; set; }

[StaticAccessor("BakedGISceneManager::Get()", StaticAccessorType.Arrow)]
private static extern unsafe void SetCustomBakeInputs([Span("inputDataLength", isReadOnly:true)]Vector4* inputData, int inputDataLength, int sampleCount);

public static void SetCustomBakeInputs(Vector4[] inputData, int sampleCount)
{
SetCustomBakeInputs(inputData.AsSpan(), sampleCount);
}
public static unsafe void SetCustomBakeInputs(ReadOnlySpan<Vector4> inputData, int sampleCount)
{
fixed(Vector4* inputDataPtr = inputData)
{
SetCustomBakeInputs(inputDataPtr, inputData.Length, sampleCount);
}
}

[StaticAccessor("BakedGISceneManager::Get()", StaticAccessorType.Arrow)]
public static extern void SetCustomBakeInputs(ReadOnlySpan<Vector4> inputData, int sampleCount);

[StaticAccessor("BakedGISceneManager::Get()", StaticAccessorType.Arrow)]
private static extern unsafe bool GetCustomBakeResultsCopy([Span("resultsLength")]Vector4* results, int resultsLength);
public static unsafe bool GetCustomBakeResults(Span<Vector4> results)
private static extern unsafe bool GetCustomBakeResultsCopy(Span<Vector4> results);
public static bool GetCustomBakeResults(Span<Vector4> results)
{
fixed (Vector4* resultsPtr = results) {
return GetCustomBakeResultsCopy(resultsPtr, results.Length);
}
return GetCustomBakeResultsCopy(results);
}
public static bool GetCustomBakeResults([Out] Vector4[] results)
{
Expand Down Expand Up @@ -796,9 +785,6 @@ public unsafe static bool GetAdditionalBakedProbes(int id, NativeArray<Spherical
return GetAdditionalBakedProbes(id, shPtr, validityPtr, octahedralDepthPtr, outBakedProbeSH.Length);
}

[FreeFunction]
private static extern unsafe void SetAdditionalBakedProbes(int id, [Span("positionsLength", isReadOnly:true)]Vector3 * positions, int positionsLength, bool dering);

public static void SetAdditionalBakedProbes(int id, Vector3[] positions)
{
SetAdditionalBakedProbes(id, positions.AsSpan(), true);
Expand All @@ -807,13 +793,8 @@ public static void SetAdditionalBakedProbes(int id, ReadOnlySpan<Vector3> positi
{
SetAdditionalBakedProbes(id, positions, true);
}
public static unsafe void SetAdditionalBakedProbes(int id, ReadOnlySpan<Vector3> positions, bool dering)
{
fixed(Vector3* positionsPtr = positions)
{
SetAdditionalBakedProbes(id, positionsPtr, positions.Length, dering);
}
}
[FreeFunction]
public static extern void SetAdditionalBakedProbes(int id, ReadOnlySpan<Vector3> positions, bool dering);

[FreeFunction]
public static extern void SetLightDirty(Light light);
Expand Down
70 changes: 65 additions & 5 deletions Editor/Mono/GUI/CacheServerWindow.cs
Expand Up @@ -15,9 +15,16 @@ internal class CacheServerWindow : PopupWindowContent
private readonly GUIContent m_StatusMessageConnected;
private readonly GUIContent m_StatusMessageError;
private readonly GUIContent m_OpenProjectSettings;

private readonly GUIContent m_UploadArtifacts;
private readonly GUIContent m_UploadShaderCache;
private readonly GUIContent m_UploadAllRevisions;
private readonly GUIContent m_RefreshIcon;

readonly string m_UploadArtifactsDefaultToolip = "Queues the upload of the current revision of all Artifacts present in the project. Only revisions not found on the Accelerator are uploaded.";
readonly string m_UploadShaderCacheDefaultToolip = "Queues the upload of all Shaders, and their variants, from the Unity Shader Cache. Only shaders and/or variants not found on the Accelerator are uploaded.";
readonly string m_UploadAllRevisionsDefaultToolip = "Queues upload of all revisions of every Artifact in the project. Only revisions not found on the Accelerator are uploaded.";
readonly string m_DisabledSettingPrefix = "Uploading is currently disabled in Project Settings.";

private readonly GUIStyle m_WindowStyle;

public CacheServerWindow()
Expand All @@ -26,7 +33,9 @@ public CacheServerWindow()
m_StatusMessageConnected = EditorGUIUtility.TrTextContent("Connected");
m_StatusMessageError = EditorGUIUtility.TrTextContent("Attempting to reconnect");
m_OpenProjectSettings = EditorGUIUtility.TrTextContent("Open Project Settings...");

m_UploadArtifacts = EditorGUIUtility.TrTextContent("Upload Artifacts", m_UploadArtifactsDefaultToolip);
m_UploadShaderCache = EditorGUIUtility.TrTextContent("Upload Shader Cache", m_UploadShaderCacheDefaultToolip);
m_UploadAllRevisions = EditorGUIUtility.TrTextContent("Upload All Revisions", m_UploadAllRevisionsDefaultToolip);
m_RefreshIcon = EditorGUIUtility.TrIconContent("Refresh", "Refresh connection");

m_WindowStyle = new GUIStyle { padding = new RectOffset(6, 6, 6, 6) };
Expand All @@ -36,9 +45,14 @@ public override void OnGUI(Rect rect)
{
var exit = false;

bool isCacheConnected = AssetDatabase.IsConnectedToCacheServer();

bool isCacheEnabled = AssetDatabase.IsCacheServerEnabled();
bool isUploadEnabled = AssetDatabase.GetCacheServerEnableUpload();

GUILayout.BeginArea(rect, m_WindowStyle);
// Cache server connection url
if (AssetDatabase.IsCacheServerEnabled())
if (isCacheEnabled)
{
var iconPosition = new Rect();
iconPosition.x = rect.width - (m_RefreshIcon.image.width / (Screen.dpi > 160 ? 2 : 1)) - m_WindowStyle.padding.right;
Expand All @@ -55,7 +69,7 @@ public override void OnGUI(Rect rect)
var style = new GUIStyle();
style.fontStyle = FontStyle.Bold;
style.normal.textColor = EditorStyles.boldLabel.normal.textColor;
if (!AssetDatabase.IsConnectedToCacheServer())
if (!isCacheConnected)
{
style.normal.textColor = new Color(0.97f, 0.32f, 0.31f);
}
Expand All @@ -78,6 +92,40 @@ public override void OnGUI(Rect rect)
EditorGUILayout.LabelField(ConnectionStatusText(), statusTextStyle);
GUILayout.EndHorizontal();

if(isCacheConnected && isCacheEnabled)
{
// Divider line
var actionButtonLine = EditorGUILayout.GetControlRect(GUILayout.Height(1));
actionButtonLine.x -= 6;
actionButtonLine.width += 12;
EditorGUI.DrawRect(actionButtonLine, new Color(0.387f, 0.387f, 0.387f));

GUILayout.BeginHorizontal();
using (new EditorGUI.DisabledScope(!isUploadEnabled || !isCacheEnabled))
{
// change tooltip based on Project Settings
m_UploadArtifacts.tooltip = isUploadEnabled ? m_UploadArtifactsDefaultToolip : $"{m_DisabledSettingPrefix} {m_UploadArtifactsDefaultToolip}";
m_UploadShaderCache.tooltip = isUploadEnabled ? m_UploadShaderCacheDefaultToolip : $"{m_DisabledSettingPrefix} {m_UploadShaderCacheDefaultToolip}";
m_UploadAllRevisions.tooltip = isUploadEnabled ? m_UploadAllRevisionsDefaultToolip : $"{m_DisabledSettingPrefix} {m_UploadAllRevisionsDefaultToolip}";

if (GUILayout.Button(m_UploadArtifacts, GUILayout.Width(110)))
{
CacheServer.UploadArtifacts();
}

if (GUILayout.Button(m_UploadShaderCache, GUILayout.Width(140)))
{
CacheServer.UploadShaderCache();
}

if (GUILayout.Button(m_UploadAllRevisions, GUILayout.Width(130)))
{
CacheServer.UploadArtifacts(uploadAllRevisions:true);
}
}
GUILayout.EndHorizontal();
}

// Divider line
var lineRect = EditorGUILayout.GetControlRect(GUILayout.Height(1));
lineRect.x -= 6;
Expand Down Expand Up @@ -136,10 +184,22 @@ private void OpenPreferences()
public override Vector2 GetWindowSize()
{
int lines = AssetDatabase.IsCacheServerEnabled() ? 3 : 2;
bool isConnected = AssetDatabase.IsConnectedToCacheServer();
if (isConnected)
lines++;

int heightOfLines = (int)Math.Ceiling(EditorGUI.kSingleLineHeight * lines);
int heightOfWindowPadding = m_WindowStyle.padding.top + m_WindowStyle.padding.bottom;
int dividerLine = 2;
return new Vector2(250, heightOfLines + heightOfWindowPadding + dividerLine);

if (isConnected)
dividerLine += 2;

int width = 250;
if (isConnected)
width = 390;

return new Vector2(width, heightOfLines + heightOfWindowPadding + dividerLine);
}
}
}
131 changes: 34 additions & 97 deletions Editor/Mono/GUI/EditorApplicationLayout.cs
Expand Up @@ -23,12 +23,13 @@ namespace UnityEditor
{
internal class EditorApplicationLayout
{
static private PlayModeView m_PlayModeView = null;
static private bool m_MaximizePending = false;
static List<PlayModeView> m_PlayModeViewList = null;


static internal bool IsInitializingPlaymodeLayout()
{
return m_PlayModeViewList != null && m_PlayModeViewList.Count > 0;
return m_PlayModeView != null;
}

static internal void SetPlaymodeLayout()
Expand All @@ -39,22 +40,6 @@ static internal void SetPlaymodeLayout()

static internal void SetStopmodeLayout()
{
if (m_PlayModeViewList != null && m_PlayModeViewList.Count > 0)
{
var monitorNames = EditorFullscreenController.GetConnectedDisplayNames();
foreach (var playModeView in m_PlayModeViewList)
{
if (playModeView.fullscreenMonitorIdx >= monitorNames.Length)
continue;

EditorFullscreenController.SetSettingsForCurrentDisplay(playModeView.fullscreenMonitorIdx);
EditorFullscreenController.OnExitPlaymode();
}

m_PlayModeViewList.Clear();
m_PlayModeViewList = null;
}

WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(false);
Toolbar.RepaintToolbar();
}
Expand All @@ -65,101 +50,53 @@ static internal void SetPausemodeLayout()
SetStopmodeLayout();
}

static internal void InitializePlaymodeViewList()
{
if (m_PlayModeViewList == null)
{
m_PlayModeViewList = new List<PlayModeView>();
}
else
{
m_PlayModeViewList.Clear();
}
}

static internal void InitPlaymodeLayout()
{
InitializePlaymodeViewList();
WindowLayout.ShowAppropriateViewOnEnterExitPlaymodeList(true, out m_PlayModeViewList);
m_PlayModeView = WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(true) as PlayModeView;
if (m_PlayModeView == null)
return;

var fullscreenDetected = false;
var monitorNames = EditorFullscreenController.GetConnectedDisplayNames();

foreach (var playModeView in m_PlayModeViewList)
if (m_PlayModeView.enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayMaximized)
{
if (playModeView == null)
continue;

if (playModeView.fullscreenMonitorIdx >= monitorNames.Length)
continue;

if (playModeView.enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayFullscreen)
{
EditorFullscreenController.SetSettingsForCurrentDisplay(playModeView.fullscreenMonitorIdx);
EditorFullscreenController.isFullscreenOnPlay = true;
EditorFullscreenController.fullscreenDisplayId = playModeView.fullscreenMonitorIdx;
EditorFullscreenController.isToolbarEnabledOnFullscreen = false;
EditorFullscreenController.targetDisplayID = playModeView.targetDisplay;

if (playModeView.m_Parent is DockArea dockArea && dockArea.actualView is GameView gv)
{
playModeView.m_Parent.EnableVSync(gv.vSyncEnabled);
EditorFullscreenController.enableVSync = gv.vSyncEnabled;
EditorFullscreenController.selectedSizeIndex = gv.selectedSizeIndex;
}
fullscreenDetected = true;
}
else if (!fullscreenDetected)
if (m_PlayModeView.m_Parent is DockArea dockArea)
{
EditorFullscreenController.isFullscreenOnPlay = false;
}
m_MaximizePending = WindowLayout.MaximizePrepare(dockArea.actualView);

if (playModeView.enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayMaximized)
{
if (playModeView.m_Parent is DockArea dockArea)
{
m_MaximizePending = WindowLayout.MaximizePrepare(dockArea.actualView);
var gv = dockArea.actualView as GameView;
if (gv != null)
{
playModeView.m_Parent.EnableVSync(gv.vSyncEnabled);
}
}
var gameView = dockArea.actualView as GameView;
if (gameView != null)
m_PlayModeView.m_Parent.EnableVSync(gameView.vSyncEnabled);
}
}

EditorFullscreenController.OnEnterPlaymode();
// Mark this PlayModeView window as the start view so the backend
// can set size and mouseoffset properly for this view
m_PlayModeView.m_Parent.SetAsStartView();
m_PlayModeView.m_Parent.SetAsLastPlayModeView();

if (!EditorFullscreenController.isFullscreenOnPlay)
{
playModeView.m_Parent.SetAsStartView();
playModeView.m_Parent.SetAsLastPlayModeView();

if (playModeView is IGameViewOnPlayMenuUser)
{
if (((IGameViewOnPlayMenuUser)playModeView).playFocused)
{
playModeView.Focus();
}
}
}
Toolbar.RepaintToolbar();
}
//GameView should be actively focussed If Playmode is entered in maximized state - case 1252097
if (m_PlayModeView.maximized)
m_PlayModeView.m_Parent.Focus();

Toolbar.RepaintToolbar();
}

static internal void FinalizePlaymodeLayout()
{
foreach (var playModeView in m_PlayModeViewList)
if (m_PlayModeView != null)
{
if (playModeView != null)
{
if (m_MaximizePending)
WindowLayout.MaximizePresent(playModeView);
if (m_MaximizePending)
WindowLayout.MaximizePresent(m_PlayModeView);

// All StartView references on all play mode views must be cleared before play mode starts. Otherwise it may cause issues
// with input being routed to the correct game window. See case 1381985
playModeView.m_Parent.ClearStartView();
}
m_PlayModeView.m_Parent.ClearStartView();
}

Clear();
}

static private void Clear()
{
m_MaximizePending = false;
m_PlayModeView = null;
}
}
} // namespace
12 changes: 0 additions & 12 deletions Editor/Mono/GUI/InternalEditorGUI.cs
Expand Up @@ -243,18 +243,6 @@ internal static void GameViewSizePopup(Rect buttonRect, GameViewSizeGroupType gr
}
}

internal static void GameViewOnPlayPopup(Rect buttonRect, int selectedIndex, IGameViewOnPlayMenuUser gameView, GUIStyle guiStyle)
{
var text = GameViewOnPlayMenu.GetOnPlayBehaviorName(selectedIndex);

if (EditorGUI.DropdownButton(buttonRect, GUIContent.Temp(text), FocusType.Passive, guiStyle))
{
var menuData = new GameViewOnPlayMenuItemProvider();
var flexibleMenu = new GameViewOnPlayMenu(menuData, selectedIndex, null, gameView);
PopupWindow.Show(buttonRect, flexibleMenu);
}
}

public static void DrawRect(Rect rect, Color color)
{
if (Event.current.type != EventType.Repaint)
Expand Down
6 changes: 0 additions & 6 deletions Editor/Mono/GUI/InternalEditorGUILayout.cs
Expand Up @@ -25,12 +25,6 @@ internal static void GameViewSizePopup(GameViewSizeGroupType groupType, int sele
EditorGUI.GameViewSizePopup(s_LastRect, groupType, selectedIndex, gameView, style);
}

internal static void GameViewOnPlayPopup(int selectedIndex, IGameViewOnPlayMenuUser gameView, GUIStyle style, params GUILayoutOption[] options)
{
s_LastRect = GetControlRect(false, EditorGUI.kSingleLineHeight, style, options);
EditorGUI.GameViewOnPlayPopup(s_LastRect, selectedIndex, gameView, style);
}

internal static void SortingLayerField(GUIContent label, SerializedProperty layerID, GUIStyle style, GUIStyle labelStyle)
{
s_LastRect = EditorGUILayout.GetControlRect(false, EditorGUI.kSingleLineHeight, style);
Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/GUI/SliderWithTexture.cs
Expand Up @@ -106,7 +106,7 @@ Texture2D sliderBackground
? EditorGUIUtility.DragZoneRect(position)
: default(Rect); // Ensure dragzone is empty when we have no label
return DoSlider(
controlRect, dragZone, id, sliderValue, sliderMin, sliderMax, formatString, textFieldMin, textFieldMax, power,
controlRect, dragZone, id, sliderValue, sliderMin, sliderMax, formatString, textFieldMin, textFieldMax, power, 1f,
EditorStyles.numberField, "ColorPickerSliderBackground", "ColorPickerHorizThumb", sliderBackground, null
);
}
Expand Down
91 changes: 0 additions & 91 deletions Editor/Mono/GUI/WindowLayout.cs
Expand Up @@ -823,97 +823,6 @@ internal static EditorWindow GetMaximizedWindow()
return null;
}

internal static EditorWindow ShowAppropriateViewOnEnterExitPlaymodeList(bool entering, out List<PlayModeView> allWindows)
{
allWindows = new List<PlayModeView>();

int[] map = new[] { 4, 3, 1, 2 };
var allWindowsBase = PlayModeView.GetAllPlayModeViewWindows()
.OrderBy(c => map[(int)(c.enterPlayModeBehavior)]).ToList();

foreach (var w in allWindowsBase)
{
allWindows.Add(w);
}

// Prevent trying to go into the same state as we're already in, as it will break things
if (WindowFocusState.instance.m_CurrentlyInPlayMode == entering)
return null;

WindowFocusState.instance.m_CurrentlyInPlayMode = entering;

EditorWindow window = null;
EditorWindow maximized = GetMaximizedWindow();

if (entering)
{
if (!GameView.openWindowOnEnteringPlayMode && !(PlayModeView.GetCorrectPlayModeViewToFocus() is PlayModeView))
return null;

WindowFocusState.instance.m_WasMaximizedBeforePlay = (maximized != null);

// If a view is already maximized before entering play mode,
// just keep that maximized view, no matter if it's the game view or some other.
// Trust that user has a good reason (desire by Ethan etc.)
if (maximized != null)
{
return maximized;
}
}
else
{
// If a view was already maximized before entering play mode,
// then it was kept when switching to play mode, and can simply still be kept when exiting
if (WindowFocusState.instance.m_WasMaximizedBeforePlay)
{
return maximized;
}
}

// Unmaximize if maximized
if (maximized)
Unmaximize(maximized);

// Try finding and focusing appropriate window/tab
window = TryFocusAppropriateWindow(entering);
if (window)
{
return window;
}

// If we are entering Play more and no Game View was found, create one
if (entering && PlayModeView.openWindowOnEnteringPlayMode)
{

// Try to create and focus a Game View tab docked together with the Scene View tab
EditorWindow sceneView = FindEditorWindowOfType(typeof(SceneView));
GameView gameView;
if (sceneView && sceneView.m_Parent is DockArea)
{
DockArea dock = sceneView.m_Parent as DockArea;
if (dock)
{
WindowFocusState.instance.m_LastWindowTypeInSameDock = sceneView.GetType().ToString();
gameView = ScriptableObject.CreateInstance<GameView>();
dock.AddTab(gameView);

allWindows.Add(gameView);
return gameView;
}
}

// If no Scene View was found at all, just create a floating Game View
gameView = ScriptableObject.CreateInstance<GameView>();
gameView.Show(true);
gameView.Focus();

allWindows.Add(gameView);
return gameView;
}

return window;
}

internal static EditorWindow ShowAppropriateViewOnEnterExitPlaymode(bool entering)
{
// Prevent trying to go into the same state as we're already in, as it will break things
Expand Down
277 changes: 26 additions & 251 deletions Editor/Mono/GameView/GameView.cs

Large diffs are not rendered by default.

164 changes: 0 additions & 164 deletions Editor/Mono/GameView/GameViewOnPlayMenu.cs

This file was deleted.

122 changes: 0 additions & 122 deletions Editor/Mono/GameView/GameViewOnPlayMenuItemProvider.cs

This file was deleted.

28 changes: 26 additions & 2 deletions Editor/Mono/GameView/GameViewSizeMenu.cs
Expand Up @@ -10,11 +10,15 @@ namespace UnityEditor
// Resolution/Aspect ratio menu for the GameView, with an optional toggle for low-resolution aspect ratios
internal class GameViewSizeMenu : FlexibleMenu
{
static class Styles
{
public static GUIContent vSyncToggleContent = EditorGUIUtility.TrTextContent("VSync (Game view only)", "Enable VSync only for the game view while in playmode.");
}
const float kTopMargin = 7f;
const float kMargin = 9f;
IGameViewSizeMenuUser m_GameView;

float frameHeight { get { return kTopMargin * 2 + EditorGUI.kSingleLineHeight; } }
float frameHeight { get { return kTopMargin * 2 + EditorGUI.kSingleLineHeight * (IsVSyncToggleVisible() ? 2 : 1);}}
float contentOffset { get { return frameHeight + EditorGUI.kControlVerticalSpacing; } }

public GameViewSizeMenu(IFlexibleMenuItemProvider itemProvider, int selectionIndex, FlexibleMenuModifyItemUI modifyItemUi, IGameViewSizeMenuUser gameView)
Expand All @@ -32,6 +36,26 @@ public override Vector2 GetWindowSize()
return size;
}

private bool IsVSyncToggleVisible()
{
// Only show the vsync toggle for editor supported gfx device backend.
var gfxDeviceType = SystemInfo.graphicsDeviceType;
return gfxDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal ||
gfxDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Vulkan ||
gfxDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Direct3D11 ||
gfxDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Direct3D12 ||
gfxDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore;
}


private void DoVSyncToggle(Rect rect)
{
if (!IsVSyncToggleVisible())
return;
var toggleRect = new Rect(rect.xMin, rect.yMax + 2, rect.width, EditorGUI.kSingleLineHeight);
m_GameView.vSyncEnabled = GUI.Toggle(toggleRect, m_GameView.vSyncEnabled, Styles.vSyncToggleContent);
}

public override void OnGUI(Rect rect)
{
var frameRect = new Rect(rect.x, rect.y, rect.width, frameHeight);
Expand All @@ -43,7 +67,7 @@ public override void OnGUI(Rect rect)
m_GameView.lowResolutionForAspectRatios = GUI.Toggle(toggleRect, m_GameView.forceLowResolutionAspectRatios || m_GameView.lowResolutionForAspectRatios, GameView.Styles.lowResAspectRatiosContextMenuContent);

GUI.enabled = true;

DoVSyncToggle(toggleRect);

rect.height = rect.height - contentOffset;
rect.y = rect.y + contentOffset;
Expand Down
1 change: 1 addition & 0 deletions Editor/Mono/GameView/IGameViewSizeMenuUser.cs
Expand Up @@ -9,5 +9,6 @@ internal interface IGameViewSizeMenuUser
void SizeSelectionCallback(int indexClicked, object objectSelected);
bool lowResolutionForAspectRatios { get; set; }
bool forceLowResolutionAspectRatios { get; }
bool vSyncEnabled { get; set; }
}
}
1 change: 1 addition & 0 deletions Editor/Mono/Graphics/ShaderCompilerData.cs
Expand Up @@ -69,6 +69,7 @@ public enum ShaderCompilerPlatform
{
None = 0, // For non initialized variable.
D3D = 4, // Direct3D 11 (FL10.0 and up) and Direct3D 12, compiled with MS D3DCompiler
[System.Obsolete(@"OpenGL ES 2.0 is no longer supported since Unity 2023.1")]
GLES20 = 5, // OpenGL ES 2.0 / WebGL 1.0, compiled with MS D3DCompiler + HLSLcc
GLES3x = 9, // OpenGL ES 3.0+ / WebGL 2.0, compiled with MS D3DCompiler + HLSLcc
PS4 = 11, // Sony PS4
Expand Down
13 changes: 10 additions & 3 deletions Editor/Mono/ImportSettings/DesktopPluginImporterExtension.cs
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO;
using System.Linq;
using UnityEditor.Modules;
Expand Down Expand Up @@ -175,16 +176,15 @@ private bool IsUsableOnOSX(PluginImporter imp)
return true;

string ext = FileUtil.GetPathExtension(imp.assetPath).ToLower();
return ext == "so" || ext == "bundle" || ext == "dylib" || IsCppPluginFile(imp.assetPath);
return ext == "bundle" || ext == "dylib" || IsLinuxLibrary(imp.assetPath) || IsCppPluginFile(imp.assetPath);
}

private bool IsUsableOnLinux(PluginImporter imp)
{
if (!imp.isNativePlugin)
return true;

string ext = FileUtil.GetPathExtension(imp.assetPath).ToLower();
return ext == "so" || IsCppPluginFile(imp.assetPath);
return IsLinuxLibrary(imp.assetPath) || IsCppPluginFile(imp.assetPath);
}

public override void OnPlatformSettingsGUI(PluginImporterInspector inspector)
Expand Down Expand Up @@ -275,6 +275,13 @@ public override string CalculateFinalPluginPath(string platformName, PluginImpor
return Path.GetFileName(imp.assetPath);
}

// Regex that matchers strings ending in ".so" or ".so.12" or ".so.4.7" and so on.
private static Regex LinuxLibraryRegex = new Regex(@"\.so(\.[0-9]+)*$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
internal static bool IsLinuxLibrary(string assetPath)
{
return LinuxLibraryRegex.IsMatch(assetPath);
}

internal static bool IsCppPluginFile(string assetPath)
{
var extension = Path.GetExtension(assetPath).ToLower();
Expand Down
25 changes: 0 additions & 25 deletions Editor/Mono/ImportSettings/TextureImporterInspector.cs
Expand Up @@ -1546,31 +1546,6 @@ public override void OnInspectorGUI()
if (!string.IsNullOrEmpty(m_ImportWarning))
EditorGUILayout.HelpBox(m_ImportWarning, MessageType.Warning);

if (!m_TextureShape.hasMultipleDifferentValues && !m_EnableMipMap.hasMultipleDifferentValues && !m_NPOTScale.hasMultipleDifferentValues)
{
// To avoid complexity of combinations of settings (e.g., tex1 is rescaled to POT with mipmap enabled, tex2 is NPOT with mipmap disabled, then all is fine but we would still get warnings)
// we only show the warnings for a single texture (or a group with the same values)

if (m_TextureShape.intValue == (int)TextureImporterShape.Texture2D && m_EnableMipMap.boolValue && m_NPOTScale.intValue == (int)TextureImporterNPOTScale.None && TargetsHaveNPOTTextures())
{
BuildTarget buildTarget = EditorUserBuildSettings.activeBuildTarget;
UnityEngine.Rendering.GraphicsDeviceType[] activeTargetGraphicsAPIs = PlayerSettings.GetGraphicsAPIs(buildTarget);
if (Array.Exists(activeTargetGraphicsAPIs, api => api == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2))
{
GUIContent c;
if (buildTarget == BuildTarget.WebGL)
c = EditorGUIUtility.TrTextContent("NPOT textures are not fully supported on WebGL1. On these devices, mipmapping will be disabled.");
else if (buildTarget == BuildTarget.Android)
c = EditorGUIUtility.TrTextContent("Some Android devices running on OpenGLES2 may not support NPOT textures. If this is the case, mipmapping will be disabled.");
else
c = EditorGUIUtility.TrTextContent("Some devices running on OpenGLES2 may not support NPOT textures. If this is the case, mipmapping will be disabled.");

EditorGUILayout.HelpBox(c.text, MessageType.Warning, true);
}
}
}


GUI.enabled = wasEnabled;
}

Expand Down
2 changes: 1 addition & 1 deletion Editor/Mono/Inspector/CameraOverlay.cs
Expand Up @@ -104,7 +104,7 @@ public override void OnGUI()
var cameraRect = imguiContainer.rect;
cameraRect.width = Mathf.Floor(cameraRect.width);

if (cameraRect.width < 1 || cameraRect.height < 1)
if (cameraRect.width < 1 || cameraRect.height < 1 || float.IsNaN(cameraRect.width) || float.IsNaN(cameraRect.height))
return;

if (Event.current.type == EventType.Repaint)
Expand Down
15 changes: 13 additions & 2 deletions Editor/Mono/Inspector/EditorSettingsInspector.cs
Expand Up @@ -461,7 +461,7 @@ public override void OnInspectorGUI()
GUI.enabled = editorEnabled;
if (GUILayout.Button(Content.ucbpLearnMore, EditorStyles.linkLabel))
{
var help = Help.FindHelpNamed("AssetBundles-Building");
var help = Help.FindHelpNamed("Build-MultiProcess");
Application.OpenURL(help);
}
GUILayout.EndHorizontal();
Expand Down Expand Up @@ -821,10 +821,21 @@ private void DoCacheServerSettings()
if (address.Length == 2)
port = Convert.ToUInt16(address[1]);

if (AssetDatabase.CanConnectToCacheServer(ip, port))
bool canConnect = AssetDatabase.CanConnectToCacheServer(ip, port);
bool isConnected = AssetDatabase.IsConnectedToCacheServer();
if (canConnect)
m_CacheServerConnectionState = CacheServerConnectionState.Success;
else
m_CacheServerConnectionState = CacheServerConnectionState.Failure;

//We have to check if we're out of sync. here.
//If we can connect, but we're not connected, we need to update some UI
//If we CANNOT connect, but we are connected, we are out of sync. too and
//need to update some UI.
//Calling RefreshSettings here fixes that, and this check encapsulates the
//above 2 conditions.
if (canConnect != isConnected)
AssetDatabase.RefreshSettings();
}

GUILayout.Space(25);
Expand Down
14 changes: 13 additions & 1 deletion Editor/Mono/Inspector/Enlighten/LightmapParameters.cs
Expand Up @@ -76,7 +76,19 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(m_Resolution, Styles.resolutionContent);
EditorGUILayout.Slider(m_ClusterResolution, 0.1F, 1.0F, Styles.clusterResolutionContent);
EditorGUILayout.IntSlider(m_IrradianceBudget, 32, 2048, Styles.irradianceBudgetContent);
EditorGUILayout.IntSlider(m_IrradianceQuality, 512, 131072, Styles.irradianceQualityContent);
if (m_IrradianceQuality.hasMultipleDifferentValues)
{
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = true;

int newValue = (int) EditorGUILayout.LogarithmicIntSlider(Styles.irradianceQualityContent, value: m_IrradianceQuality.intValue, leftValue: 512, rightValue: 131072, logbase: 2, 512, 131072);
if (EditorGUI.EndChangeCheck())
m_IrradianceQuality.intValue = newValue;

EditorGUI.showMixedValue = false;
}
else
m_IrradianceQuality.intValue = EditorGUILayout.LogarithmicIntSlider(Styles.irradianceQualityContent, value: m_IrradianceQuality.intValue, leftValue: 512, rightValue: 131072, logbase: 2, 512, 131072);
EditorGUILayout.Slider(m_ModellingTolerance, 0.0f, 1.0f, Styles.modellingToleranceContent);
EditorGUILayout.PropertyField(m_EdgeStitching, Styles.edgeStitchingContent);
EditorGUILayout.PropertyField(m_IsTransparent, Styles.isTransparent);
Expand Down
68 changes: 42 additions & 26 deletions Editor/Mono/Inspector/LightingSettingsEditor.cs
Expand Up @@ -22,6 +22,7 @@ public void OnEnable()
m_Editor = new SharedLightingSettingsEditor();
m_Editor.OnEnable();
m_Editor.UpdateSettings(serializedObject);
m_Editor.ClampMaxRanges();
}

internal override void OnHeaderControlsGUI()
Expand All @@ -38,6 +39,11 @@ public override void OnInspectorGUI()

serializedObject.ApplyModifiedProperties();
}

private void OnFocus()
{
m_Editor.ClampMaxRanges();
}
}

internal class SharedLightingSettingsEditor
Expand Down Expand Up @@ -69,6 +75,7 @@ internal class SharedLightingSettingsEditor
SerializedProperty m_CompAOExponentDirect;
SerializedProperty m_LightmapCompression;
SerializedProperty m_LightmapMaxSize;
SerializedProperty m_LightmapSizeFixed;
SerializedProperty m_BakeBackend;
// pvr
SerializedProperty m_PVRSampleCount;
Expand Down Expand Up @@ -193,7 +200,6 @@ static class Styles
public static readonly GUIContent mixedLightsLabel = EditorGUIUtility.TrTextContent("Mixed Lighting", "Bake Global Illumination for mixed lights and static objects. May bake both direct and/or indirect lighting based on settings. Only static objects are blocking and bouncing light, dynamic objects receive baked lighting via light probes.");
public static readonly GUIContent generalLightmapLabel = EditorGUIUtility.TrTextContent("Lightmapping Settings", "Settings that apply to both Global Illumination modes (Precomputed Realtime and Baked).");
public static readonly GUIContent internalLabel = EditorGUIUtility.TrTextContent("Internal Settings", "Internal only settings. ");
public static readonly GUIContent noRealtimeGIInSM2AndGLES2 = EditorGUIUtility.TrTextContent("Realtime Global Illumination is not supported on SM2.0 hardware nor when using GLES2.0.");
public static readonly GUIContent forceWhiteAlbedo = EditorGUIUtility.TrTextContent("Force White Albedo", "Force white albedo during lighting calculations.");
public static readonly GUIContent forceUpdates = EditorGUIUtility.TrTextContent("Force Updates", "Force continuous updates of runtime indirect lighting calculations.");
public static readonly GUIContent filterMode = EditorGUIUtility.TrTextContent("Filter Mode");
Expand All @@ -203,6 +209,7 @@ static class Styles
public static readonly GUIContent lightmapResolution = EditorGUIUtility.TrTextContent("Lightmap Resolution", "Sets the resolution in texels used per unit for objects lit by baked global illumination. The higher this value is, the more time the Editor needs to bake lighting.");
public static readonly GUIContent padding = EditorGUIUtility.TrTextContent("Lightmap Padding", "Sets the separation in texels between shapes in the baked lightmap.");
public static readonly GUIContent lightmapMaxSize = EditorGUIUtility.TrTextContent("Max Lightmap Size", "Sets the max size of the full lightmap Texture in pixels. Values are squared, so a setting of 1024 can produce a 1024x1024 pixel sized lightmap.");
public static readonly GUIContent lightmapSizeFixed = EditorGUIUtility.TrTextContent("Fixed Lightmap Size", "Forces all lightmap textures to use the same size. These can be no larger than Max Lightmap Size.");
public static readonly GUIContent lightmapCompression = EditorGUIUtility.TrTextContent("Lightmap Compression", "Compresses baked lightmaps created using this Lighting Settings Asset. Lower quality compression reduces memory and storage requirements, at the cost of more visual artifacts. Higher quality compression requires more memory and storage, but provides better visual results.");
public static readonly GUIContent tiledBaking = EditorGUIUtility.TrTextContent("Tiled baking", "Determines the tiled baking mode. Auto: Memory status triggers tiling. If Auto is not enabled, bakes may fail. Disabled: Never use tiling.");
public static readonly GUIContent ambientOcclusion = EditorGUIUtility.TrTextContent("Ambient Occlusion", "Specifies whether to include ambient occlusion or not in the baked lightmap result. Enabling this results in simulating the soft shadows that occur in cracks and crevices of objects when light is reflected onto them.");
Expand Down Expand Up @@ -243,6 +250,11 @@ static class Styles
public static readonly GUIStyle labelStyle = EditorStyles.wordWrappedMiniLabel;
}

private int maxDirectSamples = 1024;
private int maxIndirectSamples = 8192;
private int maxEnvironmentSamples = 2048;
private SerializedObject currentLSO;

public void OnEnable()
{
m_ShowRealtimeLightsSettings = new SavedBool("LightingSettings.ShowRealtimeLightsSettings", false);
Expand Down Expand Up @@ -272,6 +284,12 @@ public void OnGUI(bool compact, bool drawAutoGenerate)
EditorGUILayout.Space();
}

if (currentLSO == null || currentLSO != m_GIWorkflowMode.serializedObject)
{
currentLSO = m_GIWorkflowMode.serializedObject;
ClampMaxRanges();
}

RealtimeLightingGUI(compact);
MixedLightingGUI(compact);
GeneralLightmapSettingsGUI(compact);
Expand All @@ -297,6 +315,7 @@ public void UpdateSettings(SerializedObject lightingSettingsObject)
m_AlbedoBoost = lightingSettingsObject.FindProperty("m_AlbedoBoost");
m_IndirectOutputScale = lightingSettingsObject.FindProperty("m_IndirectOutputScale");
m_LightmapMaxSize = lightingSettingsObject.FindProperty("m_LightmapMaxSize");
m_LightmapSizeFixed = lightingSettingsObject.FindProperty("m_LightmapSizeFixed");
m_LightmapParameters = lightingSettingsObject.FindProperty("m_LightmapParameters");
m_LightmapDirectionalMode = lightingSettingsObject.FindProperty("m_LightmapsBakeMode");
m_BakeResolution = lightingSettingsObject.FindProperty("m_BakeResolution");
Expand Down Expand Up @@ -360,11 +379,6 @@ void RealtimeLightingGUI(bool compact)

EditorGUILayout.PropertyField(m_EnableRealtimeGI, Styles.useRealtimeGI);

if (m_EnableRealtimeGI.boolValue && PlayerHasSM20Support())
{
EditorGUILayout.HelpBox(Styles.noRealtimeGIInSM2AndGLES2.text, MessageType.Warning);
}

EditorGUI.indentLevel++;

bool bakedGISupported = SupportedRenderingFeatures.IsLightmapBakeTypeSupported(LightmapBakeType.Baked);
Expand Down Expand Up @@ -514,9 +528,12 @@ void GeneralLightmapSettingsGUI(bool compact)
}
EditorGUILayout.PropertyField(m_PVREnvironmentIS, Styles.environmentImportanceSampling);

MultiEditableDelayedIntField(m_PVRDirectSampleCount, Styles.directSampleCount);
MultiEditableDelayedIntField(m_PVRSampleCount, Styles.indirectSampleCount);
MultiEditableDelayedIntField(m_PVREnvironmentSampleCount, Styles.environmentSampleCount);
MultiEditableLogarithmicIntSlider(m_PVRDirectSampleCount, Styles.directSampleCount, 1, maxDirectSamples, 1, 1 << 30);
MultiEditableLogarithmicIntSlider(m_PVRSampleCount, Styles.indirectSampleCount, 1, maxIndirectSamples, 1, 1 << 30);
MultiEditableLogarithmicIntSlider(m_PVREnvironmentSampleCount, Styles.environmentSampleCount, 1, maxEnvironmentSamples, 1, 1 << 30);

maxDirectSamples = (int)Mathf.ClosestPowerOfTwo(Math.Max(maxDirectSamples, m_PVRDirectSampleCount.intValue));
maxIndirectSamples = (int)Mathf.ClosestPowerOfTwo(Math.Max(maxIndirectSamples, m_PVRSampleCount.intValue));

using (new EditorGUI.DisabledScope(EditorSettings.useLegacyProbeSampleCount))
{
Expand Down Expand Up @@ -625,6 +642,8 @@ void GeneralLightmapSettingsGUI(bool compact)

EditorGUILayout.IntPopup(m_LightmapMaxSize, Styles.lightmapMaxSizeStrings, Styles.lightmapMaxSizeValues, Styles.lightmapMaxSize);

EditorGUILayout.PropertyField(m_LightmapSizeFixed, Styles.lightmapSizeFixed);

EditorGUILayout.IntPopup(m_LightmapCompression, Styles.lightmapCompressionStrings, Styles.lightmapCompressionValues, Styles.lightmapCompression);

EditorGUILayout.PropertyField(m_AmbientOcclusion, Styles.ambientOcclusion);
Expand Down Expand Up @@ -718,13 +737,6 @@ void InternalSettingsGUI(bool compact)

// Helper methods

static bool PlayerHasSM20Support()
{
var apis = PlayerSettings.GetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget);
bool hasSM20Api = apis.Contains(UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2);
return hasSM20Api;
}

static void DrawPropertyFieldWithPostfixLabel(SerializedProperty property, GUIContent label, GUIContent postfixLabel)
{
const float minimumWidth = 170.0f;
Expand Down Expand Up @@ -952,26 +964,30 @@ void DrawDenoiserTypeDropdown(SerializedProperty prop, GUIContent label, Denoise
EditorGUI.EndProperty();
}

void MultiEditableDelayedIntField(SerializedProperty property, GUIContent style)
int MultiEditableLogarithmicIntSlider(SerializedProperty property, GUIContent style, int min, int max, int textFieldMin, int textFieldMax)
{
if (property.hasMultipleDifferentValues)
{
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = true;

int fieldValue = EditorGUILayout.DelayedIntField(style, property.intValue);

int newValue = EditorGUILayout.LogarithmicIntSlider(style, property.intValue, min, max, 2, textFieldMin, textFieldMax);
if (EditorGUI.EndChangeCheck())
property.intValue = fieldValue;
property.intValue = newValue;

EditorGUI.showMixedValue = false;
}

}
else
{
int fieldValue = EditorGUILayout.DelayedIntField(style, property.intValue);
property.intValue = fieldValue;
}
property.intValue = EditorGUILayout.LogarithmicIntSlider(style, property.intValue, min, max, 2, textFieldMin, textFieldMax);

return property.intValue;
}

internal void ClampMaxRanges()
{
maxDirectSamples = Mathf.Max(m_PVRDirectSampleCount.intValue, 1024);
maxIndirectSamples = Mathf.Max(m_PVRSampleCount.intValue, 8192);
maxEnvironmentSamples = Mathf.Max(m_PVREnvironmentSampleCount.intValue, 2048);
}
}
}
27 changes: 21 additions & 6 deletions Editor/Mono/Inspector/MaterialEditor.cs
Expand Up @@ -2555,12 +2555,12 @@ private bool DoReflectionProbePicker(out Rect buttonRect)

public void DefaultPreviewSettingsGUI()
{
if (!ShaderUtil.hardwareSupportsRectRenderTexture)
var mat = target as Material;
if (!SupportsRenderingPreview(mat))
return;

Init();

var mat = target as Material;
var viewType = GetPreviewType(mat);
if (targets.Length > 1 || viewType == PreviewType.Mesh)
{
Expand All @@ -2581,12 +2581,12 @@ public void DefaultPreviewSettingsGUI()

public sealed override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
{
if (!ShaderUtil.hardwareSupportsRectRenderTexture)
var mat = target as Material;
if (!SupportsRenderingPreview(mat))
return null;

Init();


var previewRenderUtility = GetPreviewRendererUtility();
EditorUtility.SetCameraAnimateMaterials(previewRenderUtility.camera, true);

Expand Down Expand Up @@ -2763,9 +2763,25 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)
DefaultPreviewGUI(r, background);
}

public void DefaultPreviewGUI(Rect r, GUIStyle background)
private static bool SupportsRenderingPreview(Material material)
{
if (!ShaderUtil.hardwareSupportsRectRenderTexture)
return false;

if (material == null)
return false;

var assetPath = AssetDatabase.GetAssetPath(material);
if (assetPath.EndsWith(".vfx", StringComparison.InvariantCultureIgnoreCase))
return false;

return true;
}

public void DefaultPreviewGUI(Rect r, GUIStyle background)
{
var mat = target as Material;
if (!SupportsRenderingPreview(mat))
{
if (Event.current.type == EventType.Repaint)
EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40), "Material preview \nnot available");
Expand All @@ -2774,7 +2790,6 @@ public void DefaultPreviewGUI(Rect r, GUIStyle background)

Init();

var mat = target as Material;
var viewType = GetPreviewType(mat);

if (DoesPreviewAllowRotation(viewType))
Expand Down