GUIで使用している Arial.ttf フォントが使えない件

721 views
Skip to first unread message

necotarou

unread,
Jun 24, 2023, 9:20:34 PM6/24/23
to 宴ユーザーグループ
宴のバージョン: 宴3.12.3
UnityのバージョンとOS: 2022.3.1f1 Windows 11
Unityの習熟度:プログラマーとして実務経験あり。

上記環境で NewProject を行おうとすると以下エラーでプロジェクトの生成ができませんでした。

```
ArgumentException: Arial.ttf is no longer a valid built in font. Please use LegacyRuntime.ttf
Utage.CreateNewProjectWindow.get_UiFont () (at Assets/Utage/Editor/Scripts/Menu/CreateNewProjectWindow.cs:52)
Utage.CreateNewProjectWindow.OnGUI () (at Assets/Utage/Editor/Scripts/Menu/CreateNewProjectWindow.cs:112)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at <582c35e8f45345d395e99f8e72e3c16d>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at <582c35e8f45345d395e99f8e72e3c16d>:0)
UnityEditor.DockArea.OldOnGUI () (at <582c35e8f45345d395e99f8e72e3c16d>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.IMGUIContainer.DoIMGUIRepaint () (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.UIR.RenderChainCommand.ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams drawParams, System.Single pixelsPerPoint, System.Exception& immediateException) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
Rethrow as ImmediateModeException
UnityEngine.UIElements.UIR.RenderChain.Render () (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.UIRRepaintUpdater.Update () (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.Panel.UpdateForRepaint () (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <d293f45b4ec64e6c9e762fe89794e7a5>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <e35f2ca690d241b7981de4b44e6c2240>:0)
```
どうやらこのバージョンのUnityにはもう Arial.ttf フォントが含まれていないようです。
試しに
CreateNewProjectWindow.cs 
```
Font UiFont
{
get
{
if (uiFont == null)
{
uiFont = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
}
return uiFont;
}
}
Font uiFont = null;
```
および
```
//フォントを変更
void FontChange( bool autoSave )
{
Font arialFont = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;

if (this.UiFont == arialFont) return;
if (this.UiFont == null) return;

//シーンをセーブ
if (autoSave)
{
WrapperUnityVersion.SaveScene();
}
else
{
if (!WrapperUnityVersion.SaveCurrentSceneIfUserWantsTo())
{
return;
}
}

Debug.Log("Font Change Arial to " + this.UiFont.name);
AssetDatabase.Refresh();
ReferenceAssetChanger.FindAndChangeAll(arialFont, UiFont, this.newProjectDir);
}
```

のフォント指定を
```
LegacyRuntime.ttf
```
に指定したところ NewProject 実行できました。
取り急ぎご報告です。

マッドネスラボ

unread,
Jun 24, 2023, 11:03:25 PM6/24/23
to 宴ユーザーグループ
すみません。チェックが漏れていたようです。
ご連絡いただき助かりました。ありがとうございます。

修正しましたので、添付のパッケージファイルを適用してください。(または後ほどの宴のバージョンアップを適用してください)
(添付ファイルのダウンロード後に、拡張子が *. gzになっている場合は、*.unitypackageに変えてからプロジェクトに適用してください)



2023年6月25日日曜日 10:20:34 UTC+9 necotarou:
FixNewProject.unitypackage
Reply all
Reply to author
Forward
0 new messages