1. Download the demo project for testing
The steps of configuring PuerTs are not repeated here.
2. Preparation
2.1 Opening a project
Normally, you can see the following screen when you open the project directly
If you click Run directly, you can find that the Output Log window below has started to print many cases.
It is because the project executes QuickStart.ts by default.
2.2 Open TsGameInstance.cpp
3. Add VsCode breakpoint
3.1 Find QuickStart.ts in VsCode, just break a point
(Here we take L17 as an example)
4. Modify the virtual machine port (8889)
and return to TsGameInstance.cpp . Uncomment
the commented code . The picture is too long. The current code is as follows:
![insert image description here](https://img-blog.csdnimg.cn/f2a4c44666fc42c29ca620b42a94da02.png)
<span style="color:#333333"><span style="background-color:#ffffff"><code class="language-typescript"><span style="color:#0000ff">void</span> <span style="color:#a31515">UTsGameInstance</span>::<span style="color:#a31515">OnStart</span>()
{
<span style="color:#008000">//GameScript = MakeShared<puerts::FJsEnv>();</span>
<span style="color:#a31515">GameScript</span> = <span style="color:#a31515">MakeShared</span><<span style="color:#ff0000">puerts</span>::<span style="color:#a31515">FJsEnv</span>>(<span style="color:#ff0000">std</span>::make_unique<<span style="color:#ff0000">puerts</span>::<span style="color:#a31515">DefaultJSModuleLoader</span>>(<span style="color:#a31515">TEXT</span>(<span style="color:#a31515">"JavaScript"</span>)), <span style="color:#ff0000">std</span>::make_shared<<span style="color:#ff0000">puerts</span>::<span style="color:#a31515">FDefaultLogger</span>>(), <span style="color:#880000">8889</span>);
<span style="color:#a31515">GameScript</span>-><span style="color:#a31515">WaitDebugger</span>();
<span style="color:#a31515">TArray</span><<span style="color:#a31515">TPair</span><<span style="color:#a31515">FString</span>, <span style="color:#a31515">UObject</span>*>> <span style="color:#a31515">Arguments</span>;
<span style="color:#a31515">Arguments</span>.<span style="color:#a31515">Add</span>(<span style="color:#a31515">TPair</span><<span style="color:#a31515">FString</span>, <span style="color:#a31515">UObject</span>*>(<span style="color:#a31515">TEXT</span>(<span style="color:#a31515">"GameInstance"</span>), <span style="color:#008000">this</span>));
<span style="color:#a31515">GameScript</span>-><span style="color:#a31515">Start</span>(<span style="color:#a31515">"QuickStart"</span>, <span style="color:#a31515">Arguments</span>);
}
</code></span></span>
Pay attention to the modified code. I have changed the port to "8889" and
opened WaitDebugger() at the same time, the purpose is that the Client waits for the V8 virtual machine
5. Add VsCode configuration
5.1 Open the Debug configuration of VsCode
5.2 Select Node.js: Attach
5.3 Change the port to (8889)
6. Start Debugging
6.1 Start VsCode standby
①First select the Debug configuration added in 5.2
②Click the green triangle on the left
to see the following schematic box
6.2 Start the project of 2.1
Not surprisingly, it has been successfully interrupted.
7. Enjoy Debug~
Let's start to test by yourself, leave a small tail " Hospital Certificate Picture " You are happy, I am happy, everyone is happy together.