I recently redid some UI in my game and it’s now giving me an error everytime I try to turn on/off a toggle through code or input. It only happens in one scene of my game and I tried reopening, reimporting, and remaking the toggles but nothing has fixed. Any help is much appreciated!
Here is the error I’m getting when turning on/off a toggle.
ArgumentException: Object of type 'UnityEngine.Object' cannot be converted to type 'UnityEngine.GameObject'.
System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <8ce0bd04a7a04b4b9395538239d3fdd8>:0)
System.Reflection.RuntimeMethodInfo.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <8ce0bd04a7a04b4b9395538239d3fdd8>:0)
System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <8ce0bd04a7a04b4b9395538239d3fdd8>:0)
System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <8ce0bd04a7a04b4b9395538239d3fdd8>:0)
System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) (at <8ce0bd04a7a04b4b9395538239d3fdd8>:0)
UnityEngine.Events.PersistentCall.GetObjectCall (UnityEngine.Object target, System.Reflection.MethodInfo method, UnityEngine.Events.ArgumentCache arguments) (at <9ae153a4144543aca4f16814b7ce3264>:0)
UnityEngine.Events.PersistentCall.GetRuntimeCall (UnityEngine.Events.UnityEventBase theEvent) (at <9ae153a4144543aca4f16814b7ce3264>:0)
UnityEngine.Events.PersistentCallGroup.Initialize (UnityEngine.Events.InvokableCallList invokableList, UnityEngine.Events.UnityEventBase unityEventBase) (at <9ae153a4144543aca4f16814b7ce3264>:0)
UnityEngine.Events.UnityEventBase.RebuildPersistentCallsIfNeeded () (at <9ae153a4144543aca4f16814b7ce3264>:0)
UnityEngine.Events.UnityEventBase.PrepareInvoke () (at <9ae153a4144543aca4f16814b7ce3264>:0)
UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at <9ae153a4144543aca4f16814b7ce3264>:0)
UnityEngine.UI.Toggle.Set (System.Boolean value, System.Boolean sendCallback) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Toggle.cs:284)
UnityEngine.UI.Toggle.set_isOn (System.Boolean value) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Toggle.cs:247)
UnityEngine.UI.ToggleGroup.NotifyToggleOn (UnityEngine.UI.Toggle toggle, System.Boolean sendCallback) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/ToggleGroup.cs:71)
UnityEngine.UI.Toggle.Set (System.Boolean value, System.Boolean sendCallback) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Toggle.cs:272)
UnityEngine.UI.Toggle.set_isOn (System.Boolean value) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Toggle.cs:247)
UnityEngine.UI.Toggle.InternalToggle () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Toggle.cs:317)
UnityEngine.UI.Toggle.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Toggle.cs:328)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:530)