Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

断点调试无法查看变量值. #743

Open
lenovo734646 opened this issue Dec 21, 2022 · 0 comments
Open

断点调试无法查看变量值. #743

lenovo734646 opened this issue Dec 21, 2022 · 0 comments

Comments

@lenovo734646
Copy link

lenovo734646 commented Dec 21, 2022

查看某个类的对像的值时,所有成员GameObject类型的成员会报错(不确定其它unity类会不会,没注意),但c#库里的类型不会. 这样对调试造成很大的不便, 这里不能发截图.群我进不去.报错是这样的:

UnityEngine.UnityException: ToString can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
at (wrapper managed-to-native) UnityEngine.Object.ToString(UnityEngine.Object)
at UnityEngine.Object.ToString () [0x00001] in <4a31731933e0419ca5a995305014ad37>:0
at ILRuntime.Runtime.Debugger.VariableInfo.FromObject (System.Object obj, System.Boolean retriveType) [0x0001f] in E:\UnityProject\Plaza\Library\PackageCache\[email protected]\Runtime\Debugger\VariableInfo.cs:156
at ILRuntime.Runtime.Debugger.DebugService.ResolveMember (System.Object obj, System.Type objType, System.String name, System.Type[] parameterTypes, System.Object[] parameters, System.Object& res) [0x000b1] in E:\UnityProject\Plaza\Library\PackageCache\[email protected]\Runtime\Debugger\DebugService.cs:1435
at ILRuntime.Runtime.Debugger.DebugService.ResolveVariable (System.Int32 threadHashCode, System.Int32 frameIndex, ILRuntime.Runtime.Debugger.VariableReference variable, System.Object& res) [0x00322] in E:\UnityProject\Plaza\Library\PackageCache\[email protected]\Runtime\Debugger\DebugService.cs:1270
at ILRuntime.Runtime.Debugger.DebuggerServer.OnReceive (ILRuntime.Runtime.Debugger.DebugMessageType type, System.Byte[] buffer) [0x0033e] in E:\UnityProject\Plaza\Library\PackageCache\[email protected]\Runtime\Debugger\DebuggerServer\DebuggerServer.cs:270

我在报错的位置打印该对象的ToString()是没有问题的:
mainObject_.ToString():Canvas (UnityEngine.GameObject)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant