What determines the availability of unload / reload buttons for editor modules?

I have been working on an editor module for a while now. I made some large changes to how the EditorMode and Toolkit sets up the UI Commands and the Slate UI today. At some point the Unload / Reload buttons disappeared from the Module window in the editor. I have noticed that additionally when I press Recompile it no longer disables the additional Mode tab as it used to do.

Is there a specific reason for this? Did something that I changed influece the type of module that I have? I have an additional module that only contains runtime classes. This has never had those buttons, but I can understand why.

Thanks.

1 Like

I ran into this in UE 4.15 too. Turns out having a class that inherits from UFactory in your module/plugin will remove the option to reload that plugin via the module window.

I was able to work around this by creating a separate module (ie, MyGameFactories) and putting my UFactory classes there. You still can’t reload the factory plugin, but your editor module will regain the ability to reload.

Hope that helps!

I’m analyzing the same issue.

In UnrealEngine\Engine\Source\Developer\ModuleUI\Private\SModuleUI.cpp I found the code below. This code is for the module window.

else if ( ColumnName == "ModuleActions" )
			{
				...
				// Reload button
				+ SHorizontalBox::Slot()
					.AutoWidth()
					.Padding( 2.0f, 0.0f )
					[
						SNew( SButton )
						.Visibility( Item.ToSharedRef(), &FModuleListItem::GetVisibilityBasedOnReloadableState )
						.Text( LOCTEXT("Reload", "Reload") )
						.OnClicked( Item.ToSharedRef(), &FModuleListItem::OnReloadClicked )
					]

And If follow the code in the same file, finally I can meet the function GetVisibilityBasedOnLoadedAndShutdownableState() through GetVisibilityBasedOnReloadableState()

EVisibility SModuleUI::FModuleListItem::GetVisibilityBasedOnLoadedAndShutdownableState() const
{
	if ( GIsSavingPackage || IsGarbageCollecting() )
	{
		return EVisibility::Hidden;
	}

	const bool bIsHotReloadable = FModuleManager::Get().DoesLoadedModuleHaveUObjects(ModuleName);
	const bool bCanShutDown = ( FModuleManager::Get().IsModuleLoaded(ModuleName)
								&& !bIsHotReloadable 
								&& FModuleManager::Get().GetModule(ModuleName)->SupportsDynamicReloading() );

	return bCanShutDown ? EVisibility::Visible : EVisibility::Hidden;
}


EVisibility SModuleUI::FModuleListItem::GetVisibilityBasedOnReloadableState() const
{
	return GetVisibilityBasedOnLoadedAndShutdownableState();
};

This function checks DoesLoadedModuleHaveUObjects() . I think that Having UObject or Not can affect the visibility of reload button.

Unload / Reload buttons will disappear for example if you use UPROPERTY, UENUM, and other things associated with the garbage collector