コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】TargetException: Non-static field requires a target

概要

f:id:baba_s:20220121165638g:plain

TargetException: Non-static field requires a target
System.Reflection.RuntimeFieldInfo.SetValue (System.Object obj, System.Object val, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) (at <31c0f51ac5a24a22ba784db24f4ba023>:0)
System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) (at <31c0f51ac5a24a22ba784db24f4ba023>:0)
Unity.Burst.Editor.BurstAotSettingsIMGUIRegister+BurstAotSettingsProvider.OnGUI (System.String searchContext) (at Library/PackageCache/com.unity.burst@1.6.0/Editor/BurstAotSettings.cs:700)
UnityEditor.SettingsWindow.DrawControls () (at <0cde216a590a4d6fbc3d7db7ac203c5d>:0)
UnityEditor.SettingsWindow.DrawSettingsPanel () (at <0cde216a590a4d6fbc3d7db7ac203c5d>: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 <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <66054a7773f64b399021c1a3f19995a3>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <4c1b5f56ab12481abc458fdd69da0f26>:0)

Project Settings の「Burst AOT Settings」で
「Enable Burst Compilation」のオンオフを切り替えたら
上記のエラーが発生して設定が反映されない状況に遭遇した

f:id:baba_s:20220121165756g:plain

一度 Unity を再生したらエラーが出なくなった