We have just finalized a plugin for UE4 that enables real-time texturing within the Unreal Engine. The plugin relies on the Auto Reimport Textures feature to reload textures in a specific directory as specified by the Auto Reimport Directories. It all works great on 50% of our test machines, but does not work at all on the rest of our machines. Even with a blank project setup and no custom plugins loaded, and Auto Reimport Textures checked, it simply does not react to changes in the Auto Reimport Directory.
Thus we have also tried to write a custom listener, but on 50% of our machines the issue remains – nothing happens. Here is our custom listener code for reference:
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "ListenerTestPluginPrivatePCH.h"
#include "Developer/DirectoryWatcher/Public/DirectoryWatcherModule.h"
#include "Developer/DirectoryWatcher/Public/IDirectoryWatcher.h"
class FListenerTestPlugin : public IListenerTestPlugin
{
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
/** Callback when folder changes */
IDirectoryWatcher::FDirectoryChanged FolderChangedDelegate;
/**
* Adds a callback to directory watcher.
*/
void InitHotReloadWatcher();
/**
* Removes a directory watcher callback
*/
void ShutdownHotReloadWatcher();
/**
* Directory watcher callback
*/
void OnDirectoryContentsChanged(const TArray<struct FFileChangeData>& FileChanges);
};
IMPLEMENT_MODULE( FListenerTestPlugin, ListenerTestPlugin )
void FListenerTestPlugin::StartupModule()
{
// This code will execute after your module is loaded into memory (but after global variables are initialized, of course.)
InitHotReloadWatcher();
}
void FListenerTestPlugin::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
ShutdownHotReloadWatcher();
}
void FListenerTestPlugin::InitHotReloadWatcher()
{
FDirectoryWatcherModule& DirectoryWatcherModule = FModuleManager::Get().LoadModuleChecked<FDirectoryWatcherModule>(TEXT("DirectoryWatcher"));
IDirectoryWatcher* DirectoryWatcher = DirectoryWatcherModule.Get();
if (DirectoryWatcher)
{
// Watch the folder for new files
FString path = FString(TEXT("C:/QuixelTemp/"));
FolderChangedDelegate = IDirectoryWatcher::FDirectoryChanged::CreateRaw(this, &FListenerTestPlugin::OnDirectoryContentsChanged);
DirectoryWatcher->RegisterDirectoryChangedCallback(path, FolderChangedDelegate);
}
}
void FListenerTestPlugin::ShutdownHotReloadWatcher()
{
FDirectoryWatcherModule* DirectoryWatcherModule = FModuleManager::GetModulePtr<FDirectoryWatcherModule>(TEXT("DirectoryWatcher"));
if (DirectoryWatcherModule != nullptr)
{
IDirectoryWatcher* DirectoryWatcher = DirectoryWatcherModule->Get();
if (DirectoryWatcher)
{
FString path = FString(TEXT("C:/QuixelTemp/"));
DirectoryWatcher->UnregisterDirectoryChangedCallback(path, FolderChangedDelegate);
}
}
}
void FListenerTestPlugin::OnDirectoryContentsChanged(const TArray<struct FFileChangeData>& FileChanges)
{
UE_LOG(LogTemp, Warning, TEXT("DirectoryChanged Callback called!!!"));
for (int i = 0; i < FileChanges.Num(); i++)
{
UE_LOG(LogTemp, Warning, TEXT("%s"), *FileChanges[i].Filename);
}
}
We would like to know if this is a known issue, and would be happy to provide any additional information you may require in order to help reproduce it.
We are having a hard time reproducing this internally. So let me get a little bit more information, are you uploading a texture that is also in the auto reimport directory or just uploading a texture from anywhere on the machine? Also what version of the engine specifically are your testing on?
Thank you for your reply! The process is as follows:
Save texture to disk (D:/Textures/albedo.tga)
Open UE4 project
Import albedo.tga into project
Set Auto Reimport Directories to D:/Textures/
Set Auto Reimport Textures to true
Edit and overwrite albedo.tga using Adobe Photoshop
At this point the texture is not automatically reimported. If I manually reimport the texture through the context menu it updates.
This has been tried on 4.3, 4.4, and 4.5. Important to note is that this exact process works on 2 machines, and fails on 2 other machines. On a fluke I had it work on the failing machines once, by creating a new empty project in 4.5 and then proceeding with the process listed above. The success could however not be reproduced in earlier versions of UE4, and regardless of version it would not work if I opened an existing project (Marketplace content for instance) and imported the textures the exact same way.
Let me know should you need anything else. Your support is much appreciated!
I did not set the settings as default after Step 5. I’ve tried this now too, however it makes no difference. Here is a GIF demonstrating the exact process (now also setting the settings as default). Note how the texture does not reimport after having been inverted and resaved. Only if I right click and reimport manually the change will take effect:
Can you give me the system specifications for the machines where the reimport is not occuring? IN particular I am looking for any differences between the working specifications and the non-working specifications and anything that the test machines that do not work have in common like OS, maybe even a particular program installed.
After a great deal of testing I have now been able to isolate the issue. Auto Reimport Textures only works if the texture files are located in the C:/ drive. The file watcher does not work with any other directory (D:/, for instance).
I hope this will be helpful to you in reproducing as well as solving the issue.
I haven’t had any luck so far on breaking the Auto Reimport. I am able to reimport from any drive on my computer. Can you let me know if your d drive is an external or networked drive? Also if you can let me know exact what the computers that are having this issue’s specifications are?
We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information requested above and we will offer further assistance.
My apologies for the delayed response, I had missed your last reply. Unfortunately this is still unresolved. The D:/ drive is neither an external nor network drive. Here are the specifications of four of the machines, two that are working and two that are not.
The only guesses I can make are that 1) the reimport functionality does not work on any of our Windows machines but on all OSX machines, or 2) that it only works on the drive that the operating system is installed on, or 3) that it only works on SSD drives.
I think I might have an idea and I am seeing if I can test it one a specific setup here, but if you look at the windows machines which are not working (or partly working) are the secondary drives slaved to the primary hard drives? I am not exactly sure why that would cause an issue but based on your data above and my own tests here that is the only variable that I have left to test.
My tests here have been based on this specification with it working on both C and D drives:
OS: Windows 7 Professional 64-bit
PROCESSOR: Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz (12 CPUs), ~2.1GHz
RAM: 32 GB RAM
VIDEO CARD: NVIDIA GeForce GTX 770
C: 256GB D: 2TB
I will let you know as soon as I have a results from the latest test but if you gather any more information please upload and let me know.
Unfortunately I have not been successful in reproducing this issue. In all setups including the Primary and Slave setup I mentioned above, all textures are importing and re-importing as expected.
I did think you could try to eliminate the Photoshop component of the test. On a Windows machine, import a PNG texture and setup your re-import texture directory. Instead of opening Photoshop to edit open Paint and edit then save and see if the editor on your machines pick up the texture change.
Hello,
same problem here.
The PC is a Asus ROG G20, with 2 drives : 1 SSD (one partition, C:) and 1 SATA (one partition D:).
If I set the textures in D: , for example D:\textures , the editor doesn’t update them when they change on disk, while on C: they are correctly updated.
I am looking into this issue again. Currently I am attempting to get my hands on a CPU setup similar to your description. As soon as I know more information I will post here.
I was finally able to get my hands on a PC with the SSD anf HDD setup and can say that I was still unable to get an error on reimporting the textures. I will say that you do have to do the initial import and then save the textures into the engine before the auto reimport texture function will kick in. So if you could test that and make sure that it is working for you, I will also say that I was testing on 4.7.3
Not sure if this is the same issue I was seeing, but I also had Auto-Reimport seem to fail randomly, but it turned out to only be when the Data Source Folder Editor Preference was set (this problem occurs as early as UE 4.21.2 and as late as UE 4.24 preview 1). I submitted a fix for it here: https://github.com/EpicGames/UnrealEngine/pull/6359