Unity3d 类型为'的对象;UnityEngine.Object';无法转换为类型';UnityEngine.Transform';

Unity3d 类型为'的对象;UnityEngine.Object';无法转换为类型';UnityEngine.Transform';,unity3d,Unity3d,我试图制作一个选项菜单,但是我遇到了标题上的错误,我没有使用任何代码 编辑:编辑器的完整图像和错误代码 错误代码: ArgumentException:无法创建类型为“UnityEngine.Object”的对象 已转换为类型“UnityEngine.Transform”。 System.RuntimeType.CheckValue(System.Object值, System.Reflection.Binder、System.Globalization.CultureInfo 区域性,S

我试图制作一个选项菜单,但是我遇到了标题上的错误,我没有使用任何代码

编辑:编辑器的完整图像和错误代码

错误代码:

ArgumentException:无法创建类型为“UnityEngine.Object”的对象 已转换为类型“UnityEngine.Transform”。 System.RuntimeType.CheckValue(System.Object值, System.Reflection.Binder、System.Globalization.CultureInfo 区域性,System.Reflection.BindingFlags invokeAttr)(位于 :0) System.Reflection.Monmethod.ConvertValues(System.Reflection.Binder 活页夹,System.Object[]参数,System.Reflection.ParameterInfo[]pinfo, 系统、全球化、文化信息文化, System.Reflection.BindingFlags invokeAttr)(位于 :0) System.Reflection.Method.DoInvoke(System.Object obj, System.Reflection.BindingFlags调用ATTR,System.Reflection.Binder binder,System.Object[]参数,System.Globalization.CultureInfo 文化(网址:0) System.Reflection.Method.Invoke(System.Reflection.BindingFlags invokeAttr,System.Reflection.Binder活页夹,System.Object[] 参数,System.Globalization.CultureInfo文化)(位于 :0) System.Reflection.ConstructorInfo.Invoke(System.Object[]参数) (at:0) UnityEngine.Events.PersistentCall.GetObjectCall(UnityEngine.Object 目标,System.Reflection.MethodInfo方法, UnityEngine.Events.ArgumentCache参数)(位于 :0) UnityEngine.Events.PersistentCall.GetRuntimeCall (UnityEngine.Events.UnityEventBase事件)(位于 :0) UnityEngine.Events.PersistentCallGroup.Initialize (UnityEngine.Events.InvokableCallList invokableList, UnityEngine.Events.UnityEventBase UnityEventBase)(位于 :0) UnityEngine.Events.UnityEventBase.RebuildPersistentCallsIfRequired() (at:0) UnityEngine.Events.UnityEventBase.PrepareInvoke()(位于 :0) UnityEngine.Events.UnityEvent.Invoke()(位于 :0)UnityEngine.UI.Button.Press() (在C:/程序中) 文件/Unity/Hub/Editor/2020.3.3f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.Unity.ugui/Runtime/UI/Core/Button.cs:68) UnityEngine.UI.Button.OnPointer单击 (UnityEngine.EventSystems.PointerEventData事件数据)(位于C:/Program 文件/Unity/Hub/Editor/2020.3.3f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.Unity.ugui/Runtime/UI/Core/Button.cs:110) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPoClickHandler, UnityEngine.EventSystems.BaseEventData(事件数据)(位于C:/Program 文件/Unity/Hub/Editor/2020.3.3f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.Unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject目标,UnityEngine.EventSystems.BaseEventData eventData,UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] 函子)(在C:/Program 文件/Unity/Hub/Editor/2020.3.3f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.Unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:262) UnityEngine.EventSystems.EventSystem:Update()(位于C:/Program 文件/Unity/Hub/Editor/2020.3.3f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.Unity.ugui/Runtime/EventSystem/EventSystem.cs:385)


错误很可能是引用了另一段代码。无法将错误
转换为类型
意味着不能将一种类型隐式转换为另一种类型,在您的情况下,
UnityEngine.Object
转换为
Transform


很难从您发布的两张图片中确切地说出为什么会出现这个问题,因为它们是层次结构,并且完全相同。如果您添加一些代码或添加错误的来源,这将有所帮助。同样地,发布任何相关代码,其中您试图将您认为是
转换的内容
分配给
对象

我添加了编辑器的完整图片,并且没有任何代码连接到该按钮。我相信这是因为您之前曾让按钮onclick序列化不同的对象,因此它会在改变只需为onclick中的转换指定一个引用就可以了。我不确定,但猜测根本的问题是根本没有引用
转换。Unity的序列化程序无论如何都会生成类型为
UnityEngine.Object
的无效“实例”,该“实例”将包含一些额外的错误信息(通常不是正常的
NullReferenceException
,您将得到
MissingReferenceException
)。。也许这是一个边缘场景,由于使用了反射,该场景中的角色向南移动