Skip to content

Commit

Permalink
Unity 6000.0.22f1 C# reference source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Unity Technologies committed Oct 2, 2024
1 parent a9c1652 commit 5e328f0
Show file tree
Hide file tree
Showing 70 changed files with 2,446 additions and 192 deletions.
21 changes: 19 additions & 2 deletions Editor/Mono/BuildProfile/BuildProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ namespace UnityEditor.Build.Profile
[HelpURL("build-profiles-reference")]
public sealed partial class BuildProfile : ScriptableObject
{
/// <summary>
/// Asset Schema Version
/// </summary>
[SerializeField]
uint m_AssetVersion = 1;

/// <summary>
/// Build Target used to fetch module and build profile extension.
/// </summary>
Expand Down Expand Up @@ -78,6 +84,17 @@ internal BuildProfilePlatformSettingsBase platformBuildProfile
set => m_PlatformBuildProfile = value;
}

/// <summary>
/// When set, this build profiles <see cref="scenes"/> used when building.
/// </summary>
/// <seealso cref="EditorBuildSettings"/>
[SerializeField] private bool m_OverrideGlobalSceneList = false;
internal bool overrideGlobalSceneList
{
get => m_OverrideGlobalSceneList;
set => m_OverrideGlobalSceneList = value;
}

/// <summary>
/// List of scenes specified in the build profile.
/// </summary>
Expand All @@ -97,7 +114,7 @@ public EditorBuildSettingsScene[] scenes
m_Scenes = value;
CheckSceneListConsistency();

if (this == BuildProfileContext.activeProfile)
if (this == BuildProfileContext.activeProfile && m_OverrideGlobalSceneList)
EditorBuildSettings.SceneListChanged();
}
}
Expand Down Expand Up @@ -202,7 +219,7 @@ void OnEnable()

void OnDisable()
{
if (IsActiveBuildProfileOrPlatform())
if (BuildProfileContext.activeProfile == this)
EditorUserBuildSettings.SetActiveProfileScriptingDefines(m_ScriptingDefines);

var playerSettingsDirty = EditorUtility.IsDirty(m_PlayerSettings);
Expand Down
1 change: 0 additions & 1 deletion Editor/Mono/BuildTargetDiscovery.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ internal static bool DoesBuildTargetSupportSinglePassStereoRendering(BuildTarget
s_platform_43,
s_platform_45,
s_platform_46,
s_platform_47,
s_platform_48,
};

Expand Down
10 changes: 7 additions & 3 deletions Editor/Mono/EditorBuildSettings.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public static EditorBuildSettingsScene[] scenes
{
get
{
if (BuildProfileContext.activeProfile is not null)
if (BuildProfileContext.activeProfile is not null
&& BuildProfileContext.activeProfile.overrideGlobalSceneList)
{
return BuildProfileContext.activeProfile.scenes;
}
Expand All @@ -95,7 +96,8 @@ public static EditorBuildSettingsScene[] scenes
}
set
{
if (BuildProfileContext.activeProfile is not null)
if (BuildProfileContext.activeProfile is not null
&& BuildProfileContext.activeProfile.overrideGlobalSceneList)
{
BuildProfileContext.activeProfile.scenes = value;
}
Expand All @@ -109,7 +111,9 @@ public static EditorBuildSettingsScene[] scenes
[RequiredByNativeCode]
static EditorBuildSettingsScene[] GetActiveBuildProfileSceneList()
{
if (!EditorUserBuildSettings.isBuildProfileAvailable || BuildProfileContext.activeProfile is null)
if (!EditorUserBuildSettings.isBuildProfileAvailable
|| BuildProfileContext.activeProfile is null
|| !BuildProfileContext.activeProfile.overrideGlobalSceneList)
return null;

return BuildProfileContext.activeProfile.scenes;
Expand Down
6 changes: 6 additions & 0 deletions Editor/Mono/EditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,12 @@ public void Close()
if (WindowLayout.IsMaximized(this))
WindowLayout.Unmaximize(this);

// [UUM-58449] If the focused window got closed, reset the IME composition mode to the default value. The normal codepaths may not run since this object is immediately destroyed.
if (focusedWindow == this)
{
GUIUtility.imeCompositionMode = IMECompositionMode.Auto;
}

DockArea da = m_Parent as DockArea;
if (da)
{
Expand Down
10 changes: 10 additions & 0 deletions Editor/Mono/GI/Lightmapping.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ public enum GIWorkflowMode
Legacy = 2
}

[NativeHeader("Runtime/Graphics/LightmapSettings.h")]
public enum BakeOnSceneLoadMode
{
Never = 0,
IfMissingLightingData = 1,
};

// Obsolete, please use Actions instead
public delegate void OnStartedFunction();
public delegate void OnCompletedFunction();
Expand Down Expand Up @@ -447,6 +454,9 @@ public static void Tetrahedralize(Vector3[] positions, out int[] outIndices, out
[FreeFunction]
public static extern void GetTerrainGIChunks([NotNull] Terrain terrain, ref int numChunksX, ref int numChunksY);

[StaticAccessor("GetLightmapSettings()")]
public static extern BakeOnSceneLoadMode bakeOnSceneLoad { get; set; }

[StaticAccessor("GetLightmapSettings()")]
public static extern LightingDataAsset lightingDataAsset { get; set; }

Expand Down
8 changes: 8 additions & 0 deletions Editor/Mono/GUI/EditorStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ public sealed class EditorStyles
public static GUIStyle inspectorDefaultMargins { get { return s_Current.m_InspectorDefaultMargins; } }
private GUIStyle m_InspectorDefaultMargins;

internal static GUIStyle inspectorHorizontalDefaultMargins => s_Current.m_InspectorHorizontalDefaultMargins;
private GUIStyle m_InspectorHorizontalDefaultMargins;

public static GUIStyle inspectorFullWidthMargins { get { return s_Current.m_InspectorFullWidthMargins; } }
private GUIStyle m_InspectorFullWidthMargins;

Expand Down Expand Up @@ -564,6 +567,11 @@ private void InitSharedStyles()
padding = new RectOffset(kInspectorPaddingLeft, kInspectorPaddingRight, kInspectorPaddingTop, 0)
};

m_InspectorHorizontalDefaultMargins = new GUIStyle
{
padding = new RectOffset(kInspectorPaddingLeft, kInspectorPaddingRight, 0, 0)
};

// For the full width margins, use padding from right side in both sides,
// though adjust for overdraw by adding one in left side to get even margins.
m_InspectorFullWidthMargins = new GUIStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,7 @@ internal bool OnGUI(Rect position, SerializedProperty property, GUIContent label
if (childrenAreExpanded)
{
SerializedProperty endProperty = prop.GetEndProperty();
// Children need to be indented
int prevIndent = EditorGUI.indentLevel;
EditorGUI.indentLevel++;
position = EditorGUI.IndentedRect(position);
EditorGUI.indentLevel = prevIndent;

while (prop.NextVisible(childrenAreExpanded) && !SerializedProperty.EqualContents(prop, endProperty))
{
if (GUI.isInsideList && prop.depth <= EditorGUI.GetInsideListDepth())
Expand Down
5 changes: 5 additions & 0 deletions Editor/Mono/Overlays/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@ internal void ToggleCollapsedPopup()
m_ModalPopup.Focus();
}

public void RefreshPopup()
{
m_ModalPopup?.Refresh();
}

void ClosePopup()
{
m_ModalPopup?.RemoveFromHierarchy();
Expand Down
17 changes: 15 additions & 2 deletions Editor/Mono/Overlays/OverlayPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,26 @@ class OverlayPopup : VisualElement
AddToClassList(Overlay.ussClassName);
style.position = Position.Absolute;

Refresh();

RegisterCallback<MouseEnterEvent>(evt => m_CursorIsOverPopup = true);
RegisterCallback<MouseLeaveEvent>(evt => m_CursorIsOverPopup = false);
}

public void Refresh()
{
var root = this.Q("overlay-content");

root.Clear();

root.renderHints = RenderHints.ClipWithScissors;
style.maxHeight = StyleKeyword.Initial;
style.maxWidth = StyleKeyword.Initial;

root.Add(overlay.GetSimpleHeader());
root.Add(overlay.CreatePanelContent());

RegisterCallback<MouseEnterEvent>(evt => m_CursorIsOverPopup = true);
RegisterCallback<MouseLeaveEvent>(evt => m_CursorIsOverPopup = false);
root.Focus();
}

public static OverlayPopup CreateUnderOverlay(Overlay overlay)
Expand Down
22 changes: 21 additions & 1 deletion Editor/Mono/PlayerSettingsVulkan.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,27 @@ namespace UnityEditor
public partial class PlayerSettings : UnityEngine.Object
{
public static extern bool vulkanEnableSetSRGBWrite { get; set; }
public static extern UInt32 vulkanNumSwapchainBuffers { get; set; }

private static extern UInt32 GetVulkanNumSwapchainBuffersImpl();
private static extern void SetVulkanNumSwapchainBuffersImpl(UInt32 value);

// NOTE: While in the editor, changing this value can be destructive so we force 3 swapchain buffers while running in the editor.
public static UInt32 vulkanNumSwapchainBuffers
{
get
{
// Must match the value PlayerSettings::kFixedEditorVulkanSwapchainBufferCount in native code,
// explicitly report the current value being used.
const UInt32 kFixedEditorVulkanSwapchainBufferCount = 3;
if (EditorApplication.isPlaying)
return kFixedEditorVulkanSwapchainBufferCount;
else
return GetVulkanNumSwapchainBuffersImpl();
}

set => SetVulkanNumSwapchainBuffersImpl(value);
}

public static extern bool vulkanEnableLateAcquireNextImage { get; set; }

[Obsolete("Vulkan SW command buffers are deprecated, vulkanUseSWCommandBuffers will be ignored.")]
Expand Down
13 changes: 13 additions & 0 deletions Editor/Mono/SceneModeWindows/LightingWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ static class Styles
public static readonly GUIContent progressiveGPUChangeWarning = EditorGUIUtility.TrTextContent("Changing the compute device used by the Progressive GPU Lightmapper requires the editor to be relaunched. Do you want to change device and restart?");
public static readonly GUIContent gpuBakingProfile = EditorGUIUtility.TrTextContent("GPU Baking Profile", "The profile chosen for trading off between performance and memory usage when baking using the GPU.");

public static readonly GUIContent bakeOnSceneLoad = EditorGUIUtility.TrTextContent("Bake On Scene Load", "Whether to automatically generate lighting for Scenes that do not have valid lighting data when first opened.");

public static readonly GUIContent invalidEnvironmentLabel = EditorGUIUtility.TrTextContentWithIcon("Baked environment lighting does not match the current Scene state. Generate Lighting to update this.", MessageType.Warning);
public static readonly GUIContent unsupportedDenoisersLabel = EditorGUIUtility.TrTextContentWithIcon("Unsupported denoiser selected", MessageType.Error);

Expand Down Expand Up @@ -539,6 +541,16 @@ void DrawBakingProfileSelector()
}
}

void DrawBakeOnLoadSelector()
{
var selected = (Lightmapping.BakeOnSceneLoadMode)EditorGUILayout.EnumPopup(Styles.bakeOnSceneLoad, Lightmapping.bakeOnSceneLoad);
if (selected != Lightmapping.bakeOnSceneLoad)
{
Undo.RecordObject(LightmapEditorSettings.GetLightmapSettings(), "Change Bake On Load Setting");
Lightmapping.bakeOnSceneLoad = selected;
}
}

void DrawBottomBarGUI(Mode selectedMode)
{
using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
Expand All @@ -552,6 +564,7 @@ void DrawBottomBarGUI(Mode selectedMode)
// Bake settings.
DrawGPUDeviceSelector();
DrawBakingProfileSelector();
DrawBakeOnLoadSelector();

{
// Bake button if we are not currently baking
Expand Down
11 changes: 4 additions & 7 deletions Editor/Mono/SceneView/SceneView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,10 @@ void HandleViewToolCursor(Rect cameraRect)
{
if (!Tools.viewToolActive || Event.current.type != EventType.Repaint)
return;
// In case multiple scene views are opened, we only want to set the cursor for the one being hovered
// Skip if the mouse is over an overlay or an area that should not use a custom cursor
if (mouseOverWindow is SceneView view && (mouseOverWindow != this || !view.sceneViewMotion.viewportsUnderMouse))
return;

var cursor = MouseCursor.Arrow;
switch (Tools.viewTool)
Expand Down Expand Up @@ -3012,13 +3016,6 @@ void HandleMouseCursor()
bool repaintView = false;
MouseCursor cursor = MouseCursor.Arrow;

//Reset the cursor if the mouse is over an overlay or an area that should not use a custom cursor
if (mouseOverWindow is SceneView view && !view.sceneViewMotion.viewportsUnderMouse)
{
InternalEditorUtility.ResetCursor();
return;
}

foreach (CursorRect r in s_MouseRects)
{
if (r.rect.Contains(evt.mousePosition))
Expand Down
Loading

0 comments on commit 5e328f0

Please sign in to comment.