从 MonoDevelop 调试器中选择 Unity 编辑器中的游戏对象

Selecting a GameObject in Unity Editor from MonoDevelop Debugger

我正在 MonoDevelop 中调试 MonoBehaviour 脚本。

有办法select(在Unity编辑器中)gameobject当前暂停的脚本附加到?

(我有多个附有该脚本的预制件实例,因此在层次结构中找到它并不容易)

您可以利用 Unity 的 Selection class 相当轻松地做到这一点。请务必在脚本顶部添加 using UnityEditor;

要在层次结构中调试 select gameObject,只需在脚本中将 Selection.activeGameObject 属性 设置在放置断点的行之后在。例如:

void Update()
{
    int breakPoint = 5; //your breakpoint is placed here

    //select this gameObject in the hierarchy 
    Selection.activeGameObject = this.gameObject; 
}