Problem:
When an artist hits Publish in Shotgun on an Asset mesh, we want it to automatically be imported into Unreal Engine 4, and submitted to the UE4 aware Source Control.
Solution:
Convoluted. Suggestions welcome. Please see below.
I don’t \think\ the Shotgun Toolkit provides event driven support from Shotgun. Thankfully there’s the ShotgunEventDaemon.
ShotgunEventDaemon:
Utilizing ShotgunEventDaemon we can make a plugin, modeled after logArgs.py or any other example, that attempts to communicate on a local port when an Asset Publish event happens with the asset id or another unique identifying piece of information.
I have to figure out from the myriad of Shotgun_PublishedFile_Change events, which I want to handle. I can probably handle ones with an attachment_id. I have to figure out from that information how to associate it with a specific Asset that I can import. That asset ID will be sent to a socket.
SG Toolkit Side:
Okay, on the SG toolkit side of things, I was thinking I need an app engine that can tap into tk-unreal to run an import.
If ShotgunEventDaemon service isn’t running, my plugin isn’t active on the port, I can have a thread/process spin it up from my tk app engine.
I can setup a thread to listen on the mentioned port, and when an asset comes in I can look up that asset to fetch it’s sg_publish_data.
After I get the asset data I need to figure out how to trigger an import. _import_to_content_browser
in tk-unreal_actions
is what’s called from execute_action
. I need to figure out from a tk-unreal engine reference how to make that execute happen. I think I can access tk-unreal from another tk app using:
app.engine.apps["tk-unreal"]
Or just:
engine.apps["tk-unreal"].
From there I’m not sure how to get access to the
I don’t /think/ I can access tk-unreal unless Unreal is open, but wanted to be sure. When running Unreal’s Shotgun Python Console, tk-unreal is available from engine.tk_unreal
; but if I’m running a toolkit app engine, I’m not sure if it would have access to the same information or not without doing a lookup mentioned above.
Questions:
- What’s the tk difference between Engine and other types, and engine.py and startup.py?
- I have to find and read through documentation, I’ll probably scratch this out and answer myself.
- Is tk-unreal available before Unreal Engine itself is opened?
- Can you trigger an import from the Shotgun App without needing Unreal open from the start?
- If I have a tk app that depends on tk-unreal, how can I know when tk-unreal is started/shutdown and available for use?
- Is there an easy way to trigger _import_to_content_browser from execute_action in tk-unreal_actions when you have access to the tk-unreal engine?
- How do I get access to an Engine’s Hook Classes?
Finally:
Has anyone done this before, and can you share details of what you went through?
Asked on UDN: https://udn.unrealengine.com/s/question/0D54z00007Al1XBCAZ/shotguneventdaemon-and-tkunreal