😊

モバイルプロジェクト Unity 2022 LTS バージョンアップの当たりをつける

に公開

https://docs.unity3d.com/2022.3/Documentation/Manual/WhatsNew2022LTS.html

Unity 2022 LTS の公式マニュアルを確認して、モバイル向けプロジェクトにおいてアップデート作業が必要そうなものを確認していく。
本記事では Unity 2021 で動作していたプロジェクトをアップデートした時、ビルド失敗に繋がりそうな事項を単に列挙する。対応の必要性や詳細についてはここでは触れない。

Upgrading Guide

https://docs.unity3d.com/2022.3/Documentation/Manual/UpgradeGuide2022LTS.html

基本はここに記載されていることに対応すれば良さそうだがここに書いていない breaking changes もあったりするので注意する。

Unity’s default Gradle templates have changed

Gradleバージョン7.2へのアップデートにより、いくつかのbuild.gradleファイルの設定オプションが変更されました。これにより、Unityのデフォルトのgradleテンプレートに大きな変更が必要になりました。UnityはカスタムGradleテンプレートを新しいフォーマットに合わせてアップグレードしようとしないので、カスタムテンプレートファイルを含むプロジェクトはビルドに失敗するかもしれません。これを解決するには、新しいデフォルトテンプレートファイルに基づいてカスタムテンプレートファイルを再作成します。

カスタムテンプレートに変更が入ったため修正が必要と思われる。

Release Note

Upgrading Guide の他にも breaking changes があったりするので一つ一つ確認していく。
Added やグラフィック関連などは無視しているので注意。
なお、ほとんど関係なさそうだが見落とすとめんどうなので多めに検討付る。

Unity 2022.1.0

Features

  • Android: Builds will fail early and with a human readable error message, when Unity project is located in path with Non ASCII characters. Android Tools like clang don't work correctly when operating in paths with non ascii characters and the error is not very clear, thus Unity will provide a better error message. (1340631)
  • Android: Bump Android Logcat package to 1.2.3.
  • Android: Editor log will contain more information about the location from where OnPostGenerateGradleAndroidProject are called.
  • Android: Input System will now send text events for combinations Ctrl + [A..Z].
  • Android: Native Input Backend will send less Move Events to the input system package. It will ignore Move Events which position didn't change from previous event. This should improve performance when touching screen with multiple fingers.
  • Android: OBB loading performance improved and removed excessive asks for external storage read permission.
    Build Pipeline: Made copying of assemblies part of the incremental player to save time on subsequent builds.
  • Build Pipeline: Make error messages about microphone or camera usage more visible.
  • Build Pipeline: On platforms using incremental player builds, data builds will now be skipped if data has not changed, even for non-development builds.
    Build Pipeline: Reference documentation improvements in area of Build Pipeline.
  • Build System: Bee_backend/win32: buffer child ouput without temp files.
  • Build System: Use a linux clang compiler optimized for speed instead of size.
  • Build System: Use a linux clang toolchain built with a newer bootstrap compiler.
  • IL2CPP: Fire the AppDomain.ProcessExit event when the runtime shuts down.
  • IL2CPP: Use intrinsics for System.Runtime.CompilerServices.Unsafe methods.
  • Scripting: Include Roslyn Analyzer diagnostics for "EnableDomainReloadTimings" diagnostic switch.
  • Scripting: Rename ".NET Standard" to ".NET Standard 2.1" in the Api Compatibility Level options to be more precise.
  • Scripting: The Managed Stripping Level for new projects when targeting the IL2CPP backend will be Minimal.
  • Scripting: Unity engine and editor managed code is now compiled with .net standard 2.1.

API Changes

  • Android: Changed: UnityPlayer Java class now explicitly requires Activity instead of Context in constructors.
  • Editor: Removed: Made Il2CppEagerStaticClassConstructionAttribute internal to avoid conflicts with other definitions outside of the package.
  • iOS: Obsoleted: PlayerSettings.iOS.allowHTTPDownload replaced by cross platform setting PlayerSettings.insecureHttpOption.
  • iOS: Removed: Removed the obsolete iOS Notification Services API. Please consider using the the "Mobile Notifications" package (available in the Unity package manager) which implements the iOS UserNotifications framework.
  • Package: Changed: Mobile Notifications 2.0.0: Fix NotificationSettings.iOSSettings.DefaultAuthorizationOptions having incorrect return type (was PresentationOption, now AuthorizationOption).
  • Package: Changed: Mobile Notifications 2.0.0: iOSNotificationTrigger.Type is no longer static and returns iOSNotificationTriggerType instead of int.

Changes

  • Android: Allow Android Player to use Vulkan on GPUs that are currently unknown to Unity on Android 11 or newer.
  • Android: Android Gradle Plugin version upgraded from 3.6.0 to 4.0.1.
  • Android: Gradle version upgraded from 5.6.4 to 6.1.1.
  • Android: Pdb files in development builds will now be stored along with the main apk file or main asset pack.
  • Build Pipeline: Enabling or disabling modules will now cause a data rebuild in the incremental build pipeline.
  • Build Pipeline: It is no longer possible to build a player when a script reload is pending. (1325753)
  • Editor: When performing incremental build (Android, Windows, OSX, WebGL, iOS), player assemblies will be placed now in Library/Bee folder rather than Library folder, and will persist until the next build.
  • IL2CPP: Code generation option moved from build settings (EditorUserBuildSettings.il2CppCodeGeneration
    ) to player settings (PlayerSettings.SetIl2CppCodeGeneration/PlayerSettings.GetIl2CppCodeGeneration). This option is now per platform and persisted with the project.
  • IL2CPP: Removed un-needed generic method context initialization calls.
  • iOS: IOS 12 is now minimum supported iOS version.
  • Networking: UnityWebRequest by default is HTTPS only now. Plain text HTTP can be enabled in Player Settings.
  • Package Manager: We now cache whether each asset version is a full project or not after clicking Import on it for the first time.
  • Profiler: The command-line argument "-profiler-log-file" now not only sets profiler target file but also activates profiler. (1339129)
  • uGUI: Removed the HideFlags.HideAndDontSave on the mesh inside Graphics for it to get properly cleaned up on both managed and native side. (1319556)
  • uGUI: Updated the context menu order and grouped all non-TMP game objects and components under legacy.

Fixed

  • Android: Changed boost documentation and timing values in the simulator to reflect the boost mode timing of 10s instead of the previous 15 seconds as it changes on the driver side.
  • Android: Changed bottleneck profiler colors to reflect warning states correctly.
  • Android: Il2cpp resources will be extracted during player launch only when needed, for ex., changes in scripts. Previously they would be extracted each time you make a new build from Unity.
  • Android: In the new input system, the search, call, endcall, camera, focus, and headsethook keys were all mapped to various function keys. These mappings are not helpful on any current platforms, and in the case of the search key, this mapping is wrong on Chrome OS keyboards which have separate search and F2 keys. (1343608)
  • Android: Toggling Build App Bundle in the Build Player Window will now prompt for a save location rather than attempting to use the last build location which would have been the incorrect type of package. (1329922)
  • Build Pipeline: iOS and tvOS now use the new incremental build pipeline.
  • Build Pipeline: The build subtarget is now adjusted to kStandaloneBuildSubtargetServer when BuildPipeline.BuildPlayer is called with the deprecated option BuildOptions.EnableHeadlessMode set to true so the scripted build pipeline remains backward compatible until the option is effectively removed. (1354146)
  • Build System: Fixed error "Cannot find mono image in MonoManager for assembly x" during assembly reload when calling ContentBuildInterface:GetPlayerObjectIdentifiersInAsset.
  • Core: Corrected disposed NativeArray and NativeSlice instance behaviour when accessing the Length property. An exception is now thrown instead of returning 0. An exception is also thrown when accessing the NativeArray indexer or attempting to iterate over disposed instances.
  • Core: Updated NativeArray and NativeSlice Enumerator MoveNext functions with a define conditional
    atomic safety handle boolean check to ensure that existing enumerators return false
    when MoveNext() is called instead of throwing an exception.
  • Editor: Updating EditorScript behavior in SceneView based on Inspector visibility. (1340534)
  • IL2CPP: Added missing facade dlls (System.Memory System.Buffers...) to the Unity 4.8 reference profile.
  • IL2CPP: Android will now properly build when Windows Language is set to Turkish.
  • IL2CPP: Fixed exported Android project failure. (1373278)
  • iOS: Fixed a crash when the iPhone 12 family were forced to portrait upside down. (1357577)
  • iOS: Fixed an issue that the iOS Simulator crashing an app when the Strip Engine Code is turned on. (1190185)
  • iOS: Fixed graphics memory not being freed on unity unload. (1348481)
  • iOS: Metal: fixed disabling stencil completely in case of Comparison Function being Disabled, as the "write only" is perfectly valid stencil state (case 1345523). (1345523)
  • Scripting: When switching to UWP it doesn't add NET_STANDARD_2_0 define, it adds NET_4_6 instead. (1334636)
  • Scripting: [InitializeOnLoad] classes are now initialized in a defined order based on assembly references, such that if Assembly B depends on Assembly A, all [InitializeOnLoad] classes in Assembly A are guaranteed to be initialized prior to any [InitializeOnLoad] classes in Assembly B. (1344815)

Known issues

  • IL2CPP: [Mobile] [IL2CPP] Build fails when using custom script and target architecture ARM64 is selected (1420369)
  • Mono: [Android] "Found plugins with same names" error is thrown when building on Android with duplicate .dll files (1373388)

Unity 2022.2.0

Features

API Changed

  • Android: Changed: The Android Java interop APIs now do nothing when used from unattached thread. Previously they would temporary attach a thread and return invalid local references. No change for properly written code that attaches a thread prior to calling JNI.
  • Android: Changed: Updated SupportsAccelerometer() API to return whether a device has an accelerometer sensor or not.
  • Android: Obsoleted: PlayerSettings.Android.minifyWithR8 is now obsolete: setting it now has no effect will always return true.
  • Editor: Changed: Lightmapping.SetAdditionalBakedProbes now accepts a boolean value to indicate if probes should be deringed.
  • Editor: Obsoleted: IDataModeHandler and IDataModeHandlerAndDispatcher are obsoleted.
  • Editor: Removed: Made Il2CppEagerStaticClassConstructionAttribute internal to avoid conflicts with other definitions outside of the package.
  • Networking: Deprecated: UnityWebRequest.Post() taking string payload has been deprecated. A direct replacement is UnityWebRequest.PostWwwForm(), also introduced UnityWebRequest.Post() taking string payload and Content-Type, the later being intended for sending string data other than HTML form.
  • Scripting: Changed: Renamed CancellationToken properties on Application and MonoBehaviour classes to OnDestroyCancellationToken and OnExitCancellationToken.

Changes

  • Android: Android SDK must have cmdline-tools component installed now. Unity will ignore tools component.
  • Android: Android SDK must have cmdline-tools component installed now. Unity will ignore tools component.
  • Android: Default gradle templates have changed significantly with new Gradle and AGP versions. Gradle templates in existing projects will have to be recreated based on new default templates when upgrading projects created with previous Unity versions.
  • Android: Implemented a new system to generate Android manifests internally.
  • Android: JDK 11 is now required to build Android apps.
  • Android: Removed Editor UI option that previously allowed you to choose between R8 and Proguard tools to minify code. The new AGP version doesn't have an option to minify using proguard, so R8 is always used instead.
  • Android: Unity uses Android Gradle Plugin 7.1.2 by default.
  • Android: Unity uses Gradle 7.2 by default.
  • Android: Upgraded to using Android NDK r23b. Default linker is now lld which fixes issues with large projects and IL2CPP.
  • Build Pipeline: Changed so log messages from the player build system are printed to Editor.log immediately instead of at the end of the build.
  • Build Pipeline: Changed so Unity doesn't recompile editor scripts during a player build.
  • Core: Stopped the reset of NativeArray and NativeSlice length when an instance is disposed, to ensure entry into iterators that would likely yield a disposed object exception.
  • Editor: Disabled the CS0282 compiler warning when PlayerSettings.SuppressCommonWarnings is enabled.
  • Editor: Updated the MacOS x64 Editor to require macOS 10.14.
  • IL2CPP: Corrected performance regression from Unity 2021.2 when script debugging is enabled.
    IL2CPP: Removed unneeded generic method context initialization calls.
  • iOS: Changed how selection is handled if it's set before the on screen keyboard has showed up.
  • iOS: Changed IOS Xcode projects to use the il2cpp executable to compile il2cpp sources, so the Xcode doesn't compile the sources directly. This makes iOS consistent with other platforms.
  • iOS: IOS player build requires Xcode13.

Fixes

  • Android: Changed boost documentation and timing values in the simulator to reflect the boost mode timing of 10s instead of the previous 15 seconds as it changes on the driver side.
  • Android: Changed bottleneck profiler colors to reflect warning states correctly.
  • Android: Removed styles*.xml files from launcher module, since styles.xml are only used by unityLibrary AndroidManifest.xml.
  • Core: Removed disposed NativeArray and NativeSlice check when you iterate or access properties like Length due to a performance regression when collections checks are enabled.
  • IL2CPP: Avoid a possible race condition when the garbage collector is enabled or disabled that could cause it to become permanently disabled. (UUM-16300)
  • IL2CPP: Avoid an exception from Buffer.BlockCopy when the destination array is of type sbyte. (UUM-12875)
  • IL2CPP: Avoid an intermittent crash in the .NET thread pool implementation when a thread is incorrectly removed from the pool twice. (UUM-11191)
  • IL2CPP: Changed Socket Handle implementation to use file descriptor. (1389108)
  • IL2CPP: Throw an exception from Buffer.BlockCopy when the destination array has a non-primitive element type. (UUM-3302)
  • iOS: Disabled capitalization, autocorrection and others when soft keyboard is secure and input is hidden. (UUM-5974)
  • iOS: Disabled depth16 support on pre-iOS14 or pre-A9, since depth-bias does not work correctly. (UUM-9562)
  • iOS: When using "Replace" we will now overwrite any custom changes to project files again. (1374317)
  • Mono: Updated the machine config file for Android Player builds. (1405235)
  • Scripting: ApiUpdater could corrupt sources when updating attributes with parameters.
  • Scripting: Application.logMessageReceived callbacks are restored on re-entering play mode when domain reload is disabled. (1378388)
  • Scripting: Changed Compilation+Domain reload to happen before Import so we can use the domain to extract the information. This means that that we are not depending on import order anymore. (1223295)
  • Scripting: Don't cast Mathf.Abs to float when passing a float value (increases performance). (1372997)
  • Scripting: When using ObjectFactory.CreateInstance with a custom type deriving directly from UnityEngine.Object, a clearer exception message is thrown. (UUM-7896)

Discussion