The UE4 plug-in hides the source code and successfully compiles and packages the project

UE4 plug-in hides source code compilation and packaging project

        The customer suddenly asked us to provide self-developed plug-ins, but the company did not want customers to see our source code. After several days of research, we referred to many articles by the big guys, but the articles of the big guys did not explain in detail. The specific operation of hiding the source code compilation and packaging project function, here I share the specific operation of implementing this function.

Reference article UE4 plug-in development So Easy

1. Create a plugin

              Create a plugin with a blank template and compile it.

             Create a C++ class in the plugin to inherit BlueprintFunctionLibrary for functional testing. Note that you need to select the newly created plugin MyFirstPlugin (Runtime), declare a static function in .h of MyBlueprintFunctionLibrary, and implement the function in .Cpp.

public:
	UFUNCTION(BlueprintCallable, Category = "PluginTest")
	static float PluginFunctionAAndB(float A, float B);
float UMyBlueprintFunctionLibrary::PluginFunctionAAndB(float A, float B)
{
	return A + B;
}

              Right-click Generate, compile the C++ code, open the project to test the function, and find that the plug-in function is OK.

2. Package plugin

             You need to do some configuration in the .uplugin of the plug-in before packaging the plug-in. Make sure that the WhitelistPlatforms is "Win64" and the Type is "Runtime".

"Modules": [
    {
      "Name": "MyFirstPlugin",
      "Type": "Runtime",
      "LoadingPhase": "Default",
      "WhitelistPlatforms": [
        "Win32",
        "Win64"
      ]
    }
	]

             Go back to the project, click package, wait for a few minutes, and the package is successful.

 

3. Hide plugin source code

             Replace the packaged plug-in folder with the original plug-in folder;

            And delete the Private folder;

           Add the code bUsePrecompiled = true in the plugin.build.cs file; set whether to use precompilation to true, and the plugin will not be compiled again during compilation;

           If the packaging fails later, you can add another sentence PrecompileForTargets = PrecompileTargetsType.None;

	public MyFirstPlugin(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

        bUsePrecompiled = true;
        PrecompileForTargets = PrecompileTargetsType.None;
    }

           Right-click Generate, compile the C++ code, open the project and package it successfully, and run it. The function is found to be OK, and the function of hiding the plug-in source code is completed.

 

Guess you like

Origin blog.csdn.net/xialuhui/article/details/113569437