Hi,
According to the UE documentation, it is possible to use FAutoConsoleCommand to register and unregister the console command automatically.
So far I have tested that If I declare the FAutoConsoleCommand as a static member in a class, and initiate it a FConsoleCommandDelegate binded to a static member function, it works.
But If I declare the FAutoConsoleCommand as a non-static member in a class, the compiler will throw out an error of “error C2512: ‘FAutoConsoleCommand’: no appropriate default constructor available”.
If I declare it as a static member and initiate it a FConsoleCommandDelegate binded to a object instance member function, the compiling will fail too.
So, what is the correct way of using FAutoConsoleCommand? Is it possible to register a console command by FAutonConsoleCommand to trigger a object instance memeber function?
BTW, If I use the FConsoleManager::Get().RegisterConsoleCommand to register the console command with a FConsoleCommandDelegate binded to a member function of a object instance, it also works.
But I want to know how to manage it with the FAutoConsoleCommand.
Thanks.
1>[3/8] Compile [x64] MyObject.gen.cpp
1>D:\UnrealProjects\MPShooterEOS\Intermediate\Build\Win64\UnrealEditor\Inc\MPShooterEOS\UHT\MyObject.gen.cpp(75): error C2512: ‘FAutoConsoleCommand’: no appropriate default constructor available
1>E:\UE521\Engine\Source\Runtime\Core\Public\HAL\IConsoleManager.h(1716): note: see declaration of ‘FAutoConsoleCommand’
1>[4/8] Compile [x64] MyObject.cpp
1>D:\Unreal Projects\MPShooterEOS\Source\MPShooterEOS\Private\MyObject.cpp(10): error C2512: ‘FAutoConsoleCommand’: no appropriate default constructor available
1>E:\UE521\Engine\Source\Runtime\Core\Public\HAL\IConsoleManager.h(1716): note: see declaration of ‘FAutoConsoleCommand’