VS快速全局查找Unity死循环代码

1、编写一个死循环方法,然后运行调试vs

using UnityEngine;

public class DeadLoop : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        DeadLoopMethod();
    }

    
    void DeadLoopMethod()
    {
        while (true)
        {
            Debug.Log($"log");
        } 
    }
}


2、运行Unity执行到死循环的时候,Unity编辑器会卡死

3、切换到vs界面,点击调试-窗口-线程
如图:

 

4、出现线程窗口,并暂停调试


5、双击调试窗口中的方法,这时就会自动定位到死循环位置

 



posted @ 2024-07-18 14:39  Flamesky  阅读(403)  评论(0)    收藏  举报