Unity Monetization初始化报错Arial.ttf无效,需改用LegacyRuntime.ttf怎么修复?
解决Unity Ads初始化时Arial.ttf无效的错误
当调用Monetization.Initialize(gameId, testMode)(底层实际调用Advertisement.Initialize)时,触发字体引用错误,提示信息如下:
ArgumentException: Arial.ttf is no longer a valid built in font. Please use LegacyRuntime.ttf
完整错误栈:
ArgumentException: Arial.ttf is no longer a valid built in font. Please use LegacyRuntime.ttf UnityEngine.Advertisements.Placeholder.CreateButton (UnityEngine.GameObject canvasGameObject, System.Int32 x, System.Int32 y, System.Int32 width, System.Int32 height, UnityEngine.Vector2 anchorMin, UnityEngine.Vector2 anchorMax, System.String buttonText, UnityEngine.Events.UnityAction onButtonClick) (at <91220002a2fd403abd0d44e0c6cd5f2c>:0) UnityEngine.Advertisements.Placeholder.CreatePlaceholder (UnityEngine.GameObject canvasGameObject, UnityEngine.Texture2D texture, System.Int32 textureWidth, System.Int32 textureHeight) (at <91220002a2fd403abd0d44e0c6cd5f2c>:0) UnityEngine.Advertisements.Placeholder.Awake () (at <91220002a2fd403abd0d44e0c6cd5f2c>:0) UnityEngine.Advertisements.Advertisement:Initialize(String, Boolean) Starter:StartMonetization() (at Assets/Scripts/POBSystem/Starter.cs:402) <Start>d__140:MoveNext() (at Assets/Scripts/POBSystem/Starter.cs:385) System.Runtime.CompilerServices.MoveNextRunner:Run() UniRx.Async.Internal.ReusablePromise:TryInvokeContinuation() (at Assets/UniRx.Async/Internal/ReusablePromise.cs:102) UniRx.Async.Internal.ReusablePromise:TrySetResult() (at Assets/UniRx.Async/Internal/ReusablePromise.cs:89) UniRx.Async.DelayPromise:MoveNext() (at Assets/UniRx.Async/UniTask.Delay.cs:155) UniRx.Async.Internal.PlayerLoopRunner:Run() (at Assets/UniRx.Async/Internal/PlayerLoopRunner.cs:67) UniRx.Async.<>c__DisplayClass8_0:<InsertRunner>b__1() (at Assets/UniRx.Async/PlayerLoopHelper.cs:91)
修复步骤
更新Unity Ads插件到最新版
这个错误源于旧版Unity Ads插件仍在引用Unity已废弃的内置Arial字体。打开Package Manager,找到Unity Ads(或命名为Advertisements),点击更新到官方最新稳定版本,新版本已替换为LegacyRuntime.ttf或适配了Unity新字体系统。手动修改插件代码(无法更新包时)
如果项目兼容性限制不能升级插件,可手动修改:- 在Project窗口搜索
Placeholder.cs(属于Unity Ads插件的核心脚本) - 打开脚本后,找到创建Text组件时指定
"Arial.ttf"的代码行 - 将其替换为
"LegacyRuntime.ttf",保存后重新编译项目
- 在Project窗口搜索
检查版本兼容性
确保Unity Editor版本与Unity Ads包版本匹配,部分旧版Editor搭配新版Ads包也可能出现资源引用冲突,尽量使用官方推荐的版本组合。
内容的提问来源于stack exchange,提问作者Gabriel Alabi
相关产品推荐
相关产品推荐

