I thought this would be a really cool and efficient workflow IF I could get everything to work properly. The goal is to have Unreal monitor a local folder and update itself from what it sees in the local folder.
Before running Python in Unreal, you'll need to install Watchdog - a cross-platform API that allows you to run commands in response to any changes in the file system being monitored. I'm specifically using it to monitor directories on my SSD. You'll need to install it for Unreal to see your local folders.
Here are a few main pieces of the code that do a lot of the work. To start, we need to import code from other libraries including Unreal Engine, the operating system and watchdog. Line 53 is where the function uses the file path to import a new asset and line 74 shows how it scans to actively monitor for new changes with the folder.
A tick function continuously checks the queue to process any changed events.
I wanted to know what was going on at all-times with this process so A tick function continuously checks the queue to process so I included in-editor notifications keep the user informed.
Another main functionality I wanted to include was the ability to copy and paste within a folder and have Unreal recognize that. After some tweaks to the code, I was able to get it to work. Below you can see that a mesh with the same name was copied into the asset folder. Intially this feature would crash Unreal and I had to restart multiple times.
This could turn into something cool but there are a lot of bugs to be sorted out. Specifically how Unreal handles deleted assets and continues to reference that asset after its deletion. This has caused a lot of errors in the code, so I will keep working on that.
Python to Unreal Documentation: https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/?application_version=5.4
WatchDog install: https://pypi.org/project/watchdog/
Copilot: Code Debugging