Could you guys teach me how to create my own console commands? I just want to create a console command like
Stat startfile
but I could not found the source code about that command. I read a lot of tutorial and know that I can use the UFUNCTION Exec, but it is said that can only get works on the some specific class. Therefore, Could you guys please teach me how to create a console command like Stat startfile or point out where the source code of that console command?
You can create your own console command and make it recognized everywhere. If your custom class wasn’t pawn/controller/gamemode, you need to put your custom class inside of of these class, and override the function to forward the function call as stated in the article.
As for Stat StartFile
Source\Developer\FunctionalTesting\Private\FunctionalTest.cpp (1285)
Thank you! very helpful! May I ask an another silly question? If I constructed a new class inheriting the cheat manager, and that new class only has the UFUNCTIOIN Exec, will the UE4 recognize my custom console command after I compile or need I do anything else? I just started to learn the Unreal Engine weeks ago, and confused about how it works. I mean when the engine start to run, which file is first to run. What is the Unreal Engine work process?
If you inherit the cheat manager and built any functions in it, they will be recognized.
But you need to swap out the default cheat manager within APlayerController with the code below, in constructor, or its blueprint equivalent. (Go to details panel and type cheat manager)
As for compilation, anythings tight to UFUNCTION() or UPROPERTY() will need to regenerate its generated.h, recompile it instead of hot reload for a better “life experience”.
The engine has too much code, I had no idea which one going to run first. I only sure about the inherited one because it is easier to place breakpoints. Engine breakpoints might not hit due to optimization.
Thank you so much! May I continue to ask a question? Could I create a console command like Stat StartFile that need not be called in the specific class? Really want to get all thing clear about the console command part…sorry to bother you a lot,