This page lists changes in Unity 2023.2 which might affect existing projects when you upgrade them from a 2023.1 version to 2023.2.
Unity’s Progressive LightmapperA tool in Unity that bakes lightmaps according to the arrangement of lights and geometry in your scene. More info
See in Glossary no longer bakes the ambient probe and the skyboxA special type of Material used to represent skies. Usually six-sided. More info
See in Glossary Reflection ProbeA rendering component that captures a spherical view of its surroundings in all directions, rather like a camera. The captured image is then stored as a Cubemap that can be used by objects with reflective materials. More info
See in Glossary by default, and the Recalculate Environment Lighting setting in the Lighting window has been removed.
To avoid a newly created sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary having no environment lighting, Unity assigns a default Lighting Data Asset containing environment lighting that matches the default skybox material.
You must select Generate Lighting in the Lighting window in the following cases:
If you rely on the previous automatic baking behavior but you use the default environment lighting settings, Unity upgrades the scene to use the default Lighting Data Asset.
The Auto Generate setting in the Lighting window has been removed, and related APIs are now obsolete.
To generate baked lighting for a scene, you can do any of the following:
Lightmapping.Bake
API.Lightmapping.BakeAsync
API.To check lightmapsA pre-rendered texture that contains the effects of light sources on static objects in the scene. Lightmaps are overlaid on top of scene geometry to create the effect of lighting. More info
See in Glossary while you’re editing, you can now select a Scene View Draw Mode and set Lighting Data to Preview. This displays a preview of the baked lighting. The preview lightmaps are non-destructive, and you can use them after you’ve baked the scene.
If a scene relies on auto-generated lighting, it will now be missing baked lighting. Select Generate Lighting in the Lighting window to bake the lighting manually.
If you use a script to open a scene, you must now use Lightmapping.Bake
or Lightmapping.BakeAsync
instead of waiting for auto-generated lighting to complete.
The following graphics formats, which were previously deprecated in 2022.1, are now obsolete and produce compile errors if you use them:
GraphicsFormat.DepthAuto
GraphicsFormat.ShadowAuto
GraphicsFormat.VideoAuto
The GraphicsFormatUtility.GetGraphicsFormat API no longer returns the obsolete formats. Instead it does the following:
RenderTextureFormat.Depth
to GraphicsFormat.None
instead of GraphicsFormat.DepthAuto
. GraphicsFormat.None
indicates depth-only rendering.RenderTextureFormat.Shadowmap
to GraphicsFormat.None
instead of GraphicsFormat.ShadowAuto
. If you create a render textureA special type of Texture that is created and updated at runtime. To use them, first create a new Render Texture and designate one of your Cameras to render into it. Then you can use the Render Texture in a Material just like a regular Texture. More infoGraphicsFormat.None
format, you must set RenderTextureDescriptor.shadowSamplingMode to ShadowSamplingMode.CompareDepths to enable depth-compare sampling.Because GraphicsFormat.DepthAuto
and GraphicsFormat.ShadowAuto
were both considered depth stencil formats but used as colors formats, you may need to adjust your code.
For example, in the following snippet, GraphicsFormatUtility.IsDepthFormat
returns false
instead of true
:
RenderTextureDescriptor desc = new RenderTextureDescriptor(256, 256, RenderTextureFormat.Depth, 32);
bool isDepthOnly = GraphicsFormatUtility.IsDepthFormat(desc.graphicsFormat);
To check if a RenderTexture
or RenderTextureDescriptor
is depth-only, use one of the following:
if (renderTexture.graphicsFormat == GraphicsFormat.None && renderTexture.depthStencilFormat != GraphicsFormat.None)
if (renderTexture.format == RenderTextureFormat.Depth || renderTexture.format == RenderTextureFormat.Shadowmap)
Runtime-created 2D textures will no longer have their mipmap upload limited by default. Before, mipmap limits had to be disabled explicitly via the Texture2D constructor (by providing an ignoreMipmapLimit
boolean parameter when the constructor is called with a TextureFormat, or the IgnoreMipmapLimit
TextureCreationFlag when it’s called with a GraphicsFormat), or by toggling tex.ignoreMipmapLimit
of a constructed texture. This behavior has changed: mipmap limits are now opt-in for runtime-created 2D textures.
Without making project changes, in the following cases users miss out on GPU bandwidth and memory optimizations, and potentially see a better quality than intended because textures are now getting uploaded at full resolution:
In following cases, users are not affected by this change:
false
for ignoreMipmapLimit
,tex.ignoreMipmapLimit
to false
after construction.These users may want to upgrade their scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary if they use deprecated constructors.
To upgrade your scripts, use a Texture2D constructor with a MipmapLimitDescriptor
to indicate that a runtime Texture should be affected by the quality settings.
This change was made for consistency with the new mipmap limit support for Texture2DArrays. Rather than having each texture shape define its own default mipmap limit behavior, we opt for consistency and have decided that runtime textures should explicitly enable mipmap limits. This opt-in behavior is preferred over opt-out because runtime textures are often used in more versatile ways where unexpectedly uploading fewer mips than expected could be more harmful than unexpectedly uploading more mips.
Simplified the creation of custom controls with UXML in UI(User Interface) Allows a user to interact with your application. Unity currently supports three UI systems. More info
See in Glossary Toolkit to speed up the workflow and make it more intuitive.
A key improvement is the introduction of UxmlElement and UxmlAttribute attributes. These attributes simplify attribute authoring and automatically derive the attribute names from property names, eliminating the need for UxmlTraits and UxmlFactory classes.
You can now create custom attribute converters for specific data types, ensuring seamless conversion of values to and from UXML attribute strings. We’ve also enhanced UxmlObjects, allowing custom, non-visual elements to be defined within visual elementsA node of a visual tree that instantiates or derives from the C# VisualElement
class. You can style the look, define the behaviour, and display it on screen as part of the UI. More info
See in Glossary. The new system leverages the Unity serialization and uses a source generator to create UxmlSerializedData classes for elements from all UxmlAttribute definitions for each custom element class, enabling support for custom property drawersA Unity feature that allows you to customize the look of certain controls in the Inspector window by using attributes on your scripts, or by controlling how a specific Serializable class should look More info
See in Glossary, decorators, and various attributes.
The introduction of “attribute overrides” allows you to customize the behavior of UXML attributes, and provides flexibility when you work with inherited attributes. These improvements provide a more efficient and user-friendly experience for creating complex UI elements in Unity 2023.2 and beyond.
A legacy custom control created with UxmlFactory and UxmlTraits:
public class HealthBar : VisualElement
{
private const float k_LowValue = 0;
private const float k_HighValue = 100;
// Declare as usable with Uxml
public new class UxmlFactory : UxmlFactory<HealthBar, UxmlTraits> { }
// Define attributes (and connect with class properties) for Uxml
public new class UxmlTraits : BindableElement.UxmlTraits
{
UxmlColorAttributeDescription m_Color = new UxmlColorAttributeDescription { name = "color", defaultValue = Color.white };
UxmlFloatAttributeDescription m_Value = new UxmlFloatAttributeDescription { name = "value", defaultValue = k_HighValue };
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
{
base.Init(ve, bag, cc);
var bar = ve as HealthBar;
bar.color = m_Color.GetValueFromBag(bag, cc);
bar.value = m_Value.GetValueFromBag(bag, cc);
}
}
public Color color { get; set; }
[Range(k_LowValue, k_HighValue)]
public float value { get; set; }
}
Can be converted to the new UxmlElement and UxmlAttributes system like this:
[UxmlElement]
public class HealthBar2 : VisualElement
{
private const float k_LowValue = 0;
private const float k_HighValue = 100;
[UxmlAttribute]
public Color color { get; set; } = Color.white;
[UxmlAttribute]
[Range(k_LowValue, k_HighValue)]
public float value { get; set; } = k_HighValue;
}
For more examples and information, refer to Unity UI Toolkit documentation, and stay tuned for an in-depth blog post this fall.
The Assets/Create menu has been reorganized and categorized. As part of this overhaul, the Unity Built-In ScriptTemplate files have been renamed.
Users who have added elements to the Assets/Create menu with either CreateAssetMenuAttribute``, MenuItemAt
tribute or a Custom ScriptTemplate might want to change their menu item’s priority as it’s placement relative to other elements is now different.
Users who were creating assets by executing these menu items with the EditorApplication.ExecuteMenuItem
API, must verify the new path to the menu item.
Users who have previously overridden the Unity Built-In ScriptTemplates must update the names of their override files to ensure they match the new names of the Built-In Templates.
The ExecuteDefaultAction
and ExecuteDefaultActionAtTarget
methods have been deprecated. The following methods are added to replace them:
HandleEventTrickleDown
HandleEventBubbleUp
Unity executes these new methods on each element in the event dispatching path immediately after TrickleDown
and before BubbleUp
callbacks of that element. During those methods, the dispatching phase is set to TrickleDown
or BubbleUp
accordingly and the event’s `currentTarget`` coincides with the element executing the method.
The AtTarget
dispatching phase and the PreventDefault
method have been deprecated. Calling StopPropagation
or StopPropagationImmediately
will stop further executing HandleEventTrickleDown
and HandleEventBubbleUp
at the same time as it stops further invocation of the TrickleDown
and `BubbleUp`` callbacks.
In most cases, if you don’t upgrade to the new methods, your code will not alter its behavior significantly. The obsolete methods will still be called in the same order as before or with minimal adjustments. However, all the standard controls within UI Toolkit have been migrated to using the new methods, aligning their logic execution order accordingly. Mixing calls to obsolete methods with the use of upgraded controls could lead to certain logic being out of sync compared to previous Unity versions.
To upgrade existing code to the new methods, proceed as follows:
ExecuteDefaultAction
and ExecuteDefaultActionAtTarget
by HandleEventBubbleUp
and PreventDefault
by StopPropagation
(or remove calls to PreventDefault
if StopPropagation
has already been called in the same code block. This covers the majority of cases).PreventDefault
during a BubbleUp
callback, which is no longer possible and can’t be replaced by StopPropagation because the event has already reached its target, consider adding a callback during the TrickleDown
phase to call StopPropagation
. This step is generally sufficient to address such scenarios.