はじめに
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <eae584ce26bc40229c1b1aa476bfa589>:0) UnityEditor.GameView.DoToolbarGUI () (at <4a1b55d6b009421a9ad1d16b54b782d5>:0) UnityEditor.GameView.OnGUI () (at <4a1b55d6b009421a9ad1d16b54b782d5>:0) System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <eae584ce26bc40229c1b1aa476bfa589>:0) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <eae584ce26bc40229c1b1aa476bfa589>:0) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <4a1b55d6b009421a9ad1d16b54b782d5>:0) UnityEditor.HostView.Invoke (System.String methodName) (at <4a1b55d6b009421a9ad1d16b54b782d5>:0) UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <4a1b55d6b009421a9ad1d16b54b782d5>:0) UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <4a1b55d6b009421a9ad1d16b54b782d5>:0) UnityEditor.DockArea.OldOnGUI () (at <4a1b55d6b009421a9ad1d16b54b782d5>: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 <a30d64cf198846a786f143decb66f563>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Unity エディタを日本語設定で使っている状態で
Package Manager から Device Simulator をインストールすると
上記のエラーが発生して Game ウィンドウが表示されない状態になる
対策
【Unity インストール先のフォルダ】\Editor\Data\Localization
上記フォルダ内に含まれている「ja.po」をテキストエディタで開いて
#: Editor/Mono/GameView/GameView.cs:1 msgid "Game" msgstr "ゲーム"
19716 行目付近の上記の記述の「msgstr」の部分を
msgstr "Game"
このように ゲーム
から Game
に変更して保存し、
Unity エディタを再起動するとエラーが発生しなくなる
「ja.po」が保存できない場合は管理者権限で編集・保存する必要がある