Edit Plugin - no effect produced - How I achieve the results? Impossible to edit a string.

Hello everyone,

I’m new to Unreal and have experience with Unity and C++ (for different cases). However, I’m having trouble understanding how compiling (building) works in Unreal. To make even a small change to a C++ class and see the results in the game, I have to save everything, close Unreal and Visual Studio, open Visual Studio, run the Windows debugger, and then reopen Unreal. Only then can I play the game and see the changes I made, which seems too complicated.

Another issue I’m having is that when I close everything and reopen Unreal, it resets the scene to the default one for the project I created. I then have to go to the content folder and open the last map I saved after inserting the edited element in C++.

I realize that what I’ve written above is complicated, but I’m really struggling with even the simplest things in Unreal. Even when I follow online tutorials step by step, I can’t seem to achieve the same results easily. I always have to follow the same long process.

I said everything because I wanted to introduce you to my situation, Now I am going to describe what I need and I wrote in the title of this topic:

I was asked to develop a game with specific gameplay requirements and rules, and I was provided with a framework to use for building the game. Unfortunately I’ve never oversteppen this last request: import framework files into the project and use its method.

After searching online, I found that I need to create a plugin and add the DLL and LIB files of the framework. However, I’m not sure if I’ve successfully completed this task. To test some of my actions, I created a new plugin using the third-party template provided by Unreal. It created an example library that, when loaded into the project, displays a popup window saying that the library was loaded. I tried to edit this string, but every time I open the project, the string is the same. Even if I save the CPP file, clean the solution, and rebuild it, the string remains the same.

I’m not asking for help to resolve the task of adding a DLL and LIB framework to the project, but I would like to understand how to make changes to the string and see the updated message in the popup window.

Please help me.

If someone has other suggestion about all the other problem I have described is always really appreciated. Thanks in advace.

You can set the default editor map in editor preferences > maps and modes for starters.

I use jetbrains rider instead of visual studio, (which I highly recommend if you can get the free student version with a .edu email address) but generally closing the editor, rebuilding my solution and relaunching unreal seems to do the trick.

Maybe it’s different if you’re building a plug-in though, so that may not be too useful.

Hi there!
Welcome the Unreal :eyes:

Firstly, when you make changes to your C++ code, you do need to compile it before you can see the changes in the game. However, you don’t necessarily need to close both Unreal and Visual Studio every time you make a change. Instead, you can simply build the solution in Visual Studio and then switch back to Unreal and hit the “Compile” button in the editor, If you are using UE4 (Near the Play Button) , If you are using UE5 (Bottom Right Corner).

This will only recompile the modified files and should be faster than restarting both programs.

In addition, Unreal provides a “Hot Reload” feature that allows you to see the changes without even having to recompile. To use this feature, make sure that “Enable Hot Reload” is checked in the Unreal Editor preferences under “Play”. Then, when you make changes to your code and save them, switch back to Unreal and wait a few seconds for the changes to be applied.

Regarding the issue with the scene resetting to the default one, you can set a specific level to load on startup by going to the “Project Settings” → “Maps & Modes” and selecting your desired level from the “Game Default Map” dropdown.

Now, onto your question about creating a plugin and updating the popup message. It’s possible that the string you are trying to edit is defined in a header file, which needs to be included in the plugin’s source file. If that’s the case, modifying the string in the source file won’t have any effect.

To update the popup message, you need to modify the string in the correct header file, rebuild the plugin in Visual Studio, and then reload the plugin in the Unreal Editor. You can do this by going to the “Plugins” section of the Unreal Editor, finding your plugin, and clicking the “Reload” button. Once the plugin is reloaded, the updated message should be displayed.

I hope this helps you with your questions and issues. Unreal Engine can be a complex and challenging tool, but with practice and patience, you will become more comfortable with it.

Good luck with your game development! :+1:

Thank you very much @mykaa all your suggestion were very useful, you opened to me a new world xD Anyway, the main task that I wanted to achieve is unreachable yet. If you try to create the template plugin from unreal “Edit → Plugins → Add Plugin → Third Party Library” it will create a complete folder into the Plugin folder. Complete meaning with all the files required and more. What I am trying to do is to change the text of a MessageBox method that is used as following:

ExampleLibrary.h

#if defined _WIN32 || defined _WIN64
#define EXAMPLELIBRARY_IMPORT __declspec(dllimport)
#elif defined __linux__
#define EXAMPLELIBRARY_IMPORT __attribute__((visibility("default")))
#else
#define EXAMPLELIBRARY_IMPORT
#endif

EXAMPLELIBRARY_IMPORT void ExampleLibraryFunction();

ExampleLibrary.cpp

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#if defined _WIN32 || defined _WIN64
    #include <Windows.h>

    #define EXAMPLELIBRARY_EXPORT __declspec(dllexport)
#else
    #include <stdio.h>
#endif

#ifndef EXAMPLELIBRARY_EXPORT
    #define EXAMPLELIBRARY_EXPORT
#endif

EXAMPLELIBRARY_EXPORT void ExampleLibraryFunction()
{
#if defined _WIN32 || defined _WIN64
	MessageBox(NULL, TEXT("Loaded xxxx ExampleLibrary.dll xxxx from Third Party Plugin sample."), TEXT("Third Party Plugin"), MB_OK);
    UE_LOG(LogTemp, Warning, TEXT("I just started running"));
#else
    printf("yyyy Loaded ExampleLibrary yyyyyy from Third Party Plugin sample");
#endif
}

and into another folder I have ExampleLibrary.dll and ExampleLibrary.lib

everything is attached to the plugin as follows:

PD3rdLibrary.Build.cs

PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "x64", "Release", "ExampleLibrary.lib"));

			// Delay-load the DLL, so we can load it from the right place first
			PublicDelayLoadDLLs.Add("ExampleLibrary.dll");

			// Ensure that the DLL is staged along with the executable
			RuntimeDependencies.Add("$(PluginDir)/Binaries/ThirdParty/PD3rdLibrary/Win64/ExampleLibrary.dll");

PluginName.cpp

#include "PluginName.h"
#include "Core.h"
#include "Modules/ModuleManager.h"
#include "Interfaces/IPluginManager.h"
#include "PluginNameLibrary/ExampleLibrary.h"

#define LOCTEXT_NAMESPACE "FPluginNameModule"

void FPluginNameModule::StartupModule()
{
	// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module

	// Get the base directory of this plugin
	FString BaseDir = IPluginManager::Get().FindPlugin("PluginName")->GetBaseDir();

	// Add on the relative location of the third party dll and load it
	FString LibraryPath;
LibraryPath = FPaths::Combine(*BaseDir, TEXT("Binaries/ThirdParty/PluginNameLibrary/Win64/ExampleLibrary.dll"));

ExampleLibraryHandle = !LibraryPath.IsEmpty() ? FPlatformProcess::GetDllHandle(*LibraryPath) : nullptr;

	if (ExampleLibraryHandle)
	{
		// Call the test function in the third party library that opens a message box
		ExampleLibraryFunction();
	}
	else
	{
		FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("ThirdPartyLibraryError", "Failed to load example third party library"));
	}

I hope those other information can help to find a solution.
thanks in advance

I always recommend this video to anyone who wants to learn more about how an Unreal project is structured. Maybe this will help a bit.