8
8
import sys
9
9
import os
10
10
11
- unreal .log ("Loading Shotgun Engine for Unreal from {}" .format (__file__ ))
11
+ unreal .log ("Loading SG Engine for Unreal from {}" .format (__file__ ))
12
+
13
+ # Shotgun integration components were renamed to Shotgrid from UE5
14
+ if hasattr (unreal , "ShotgridEngine" ):
15
+ UESGEngine = unreal .ShotgridEngine
16
+
17
+ else :
18
+ UESGEngine = unreal .ShotgunEngine
12
19
13
20
14
21
@unreal .uclass ()
15
- class ShotgunEngineWrapper (unreal . ShotgunEngine ):
22
+ class ShotgunEngineWrapper (UESGEngine ):
16
23
17
24
def _post_init (self ):
18
25
"""
19
26
Equivalent to __init__ but will also be called from C++
20
27
"""
21
28
config .wrapper_instance = self
22
29
23
- @unreal .ufunction (override = True )
24
- def get_shotgun_menu_items (self ):
25
- """
26
- Returns the list of available menu items to populate the Shotgun menu in Unreal
27
- """
28
- menu_items = []
29
-
30
- engine = sgtk .platform .current_engine ()
31
- menu_items = self .create_menu (engine )
32
-
33
- unreal .log ("get_shotgun_menu_items returned: {0}" .format (menu_items .__str__ ()))
34
-
35
- return menu_items
30
+ # Shotgun integration components were renamed to Shotgrid from UE5
31
+ if hasattr (UESGEngine , "get_shotgrid_menu_items" ):
32
+ @unreal .ufunction (override = True )
33
+ def get_shotgrid_menu_items (self ):
34
+ """
35
+ Returns the list of available menu items to populate the SG menu in Unreal.
36
+ """
37
+ menu_items = []
38
+
39
+ engine = sgtk .platform .current_engine ()
40
+ menu_items = self .create_menu (engine )
41
+
42
+ unreal .log ("get_shotgrid_menu_items returned: {0}" .format (menu_items .__str__ ()))
43
+
44
+ return menu_items
45
+
46
+ def get_shotgun_menu_items (self ):
47
+ """
48
+ Provide backward compatibility.
49
+ """
50
+ return self .get_shotgrid_menu_items ()
51
+ else :
52
+ @unreal .ufunction (override = True )
53
+ def get_shotgun_menu_items (self ):
54
+ """
55
+ Returns the list of available menu items to populate the SG menu in Unreal.
56
+ """
57
+ menu_items = []
58
+
59
+ engine = sgtk .platform .current_engine ()
60
+ menu_items = self .create_menu (engine )
61
+
62
+ unreal .log ("get_shotgun_menu_items returned: {0}" .format (menu_items .__str__ ()))
63
+
64
+ return menu_items
65
+
66
+ def get_shotgrid_menu_items (self ):
67
+ """
68
+ Provide forward compatibility.
69
+ """
70
+ return self .get_shotgun_menu_items ()
71
+
72
+ if hasattr (UESGEngine , "get_shotgrid_work_dir" ):
73
+ def get_shotgun_work_dir (self , * args , ** kwargs ):
74
+ """
75
+ Provide backward compatibility.
76
+ """
77
+ return self .get_shotgrid_work_dir (* args , ** kwargs )
78
+ else :
79
+ def get_shotgrid_work_dir (self , * args , ** kwargs ):
80
+ """
81
+ Provide forward compatibility.
82
+ """
83
+ return self .get_shotgun_work_dir (* args , ** kwargs )
36
84
37
85
@unreal .ufunction (override = True )
38
86
def execute_command (self , command_name ):
39
87
"""
40
- Callback to execute the menu item selected in the Shotgun menu in Unreal
88
+ Callback to execute the menu item selected in the SG menu in Unreal.
41
89
"""
42
90
engine = sgtk .platform .current_engine ()
43
91
@@ -58,9 +106,9 @@ def _get_command_override(self, engine, command_name, default_callback):
58
106
:param command_name: The command name to override
59
107
:param default_callback: The callback to use when there's no override
60
108
"""
61
- # Override the Shotgun Panel command to use the Shotgun Entity context
109
+ # Override the SG Panel command to use the SG Entity context
62
110
# and also reuse the dialog if one already exists
63
- if command_name == "Shotgun Panel..." :
111
+ if command_name in [ "Shotgun Panel..." , "ShotGrid Panel..." ] :
64
112
def show_shotgunpanel_with_context ():
65
113
app = engine .apps ["tk-multi-shotgunpanel" ]
66
114
entity_type , entity_id = self ._get_context (engine )
@@ -75,7 +123,7 @@ def show_shotgunpanel_with_context():
75
123
76
124
def _get_context_url (self , engine ):
77
125
"""
78
- Get the Shotgun entity URL from the metadata of the selected asset, if present
126
+ Get the SG entity URL from the metadata of the selected asset, if present.
79
127
"""
80
128
# By default, use the URL of the project
81
129
url = engine .context .shotgun_url
@@ -110,12 +158,12 @@ def _get_context_url(self, engine):
110
158
111
159
def _get_context (self , engine ):
112
160
"""
113
- Get the Shotgun context (entity type and id) that is associated with the selected menu command
161
+ Get the SG context (entity type and id) that is associated with the selected menu command.
114
162
"""
115
163
entity_type = None
116
164
entity_id = None
117
165
118
- # The context is derived from the Shotgun entity URL
166
+ # The context is derived from the SG entity URL
119
167
url = self ._get_context_url (engine )
120
168
if url :
121
169
# Extract entity type and id from URL, which should follow this pattern:
@@ -173,7 +221,7 @@ def shutdown(self):
173
221
174
222
engine = sgtk .platform .current_engine ()
175
223
if engine is not None :
176
- unreal .log ("Shutting down ShotgunEngineWrapper" )
224
+ unreal .log ("Shutting down %s" % self . __class__ . __name__ )
177
225
178
226
# destroy_engine of tk-unreal will take care of closing all dialogs that are still opened
179
227
engine .destroy ()
@@ -184,12 +232,12 @@ def shutdown(self):
184
232
Menu generation functionality for Unreal (based on the 3ds max Menu Generation implementation)
185
233
186
234
Actual menu creation is done in Unreal
187
- The following functions simply generate a list of available commands that will populate the Shotgun menu in Unreal
235
+ The following functions simply generate a list of available commands that will populate the SG menu in Unreal
188
236
"""
189
237
190
238
def create_menu (self , engine ):
191
239
"""
192
- Populate the Shotgun Menu with the available commands
240
+ Populate the SG Menu with the available commands.
193
241
"""
194
242
menu_items = []
195
243
@@ -257,9 +305,13 @@ def _add_menu_item_from_command(self, menu_items, command):
257
305
258
306
def _add_menu_item (self , menu_items , type , name = "" , title = "" , description = "" ):
259
307
"""
260
- Adds a new Unreal ShotgunMenuItem to the menu items
308
+ Adds a new Unreal SG MenuItem to the menu items.
261
309
"""
262
- menu_item = unreal .ShotgunMenuItem ()
310
+ # Shotgun integration components were renamed to Shotgrid from UE5
311
+ if hasattr (unreal , "ShotgridMenuItem" ):
312
+ menu_item = unreal .ShotgridMenuItem ()
313
+ else :
314
+ menu_item = unreal .ShotgunMenuItem ()
263
315
menu_item .title = title
264
316
menu_item .name = name
265
317
menu_item .type = type
@@ -275,15 +327,23 @@ def _start_contextual_menu(self, engine, menu_items):
275
327
276
328
self ._add_menu_item (menu_items , "context_begin" , ctx_name , ctx_name )
277
329
278
- engine .register_command ("Jump to Shotgun" , self ._jump_to_sg , {"type" : "context_menu" , "short_name" : "jump_to_sg" })
330
+ engine .register_command (
331
+ "Jump to ShotGrid" ,
332
+ self ._jump_to_sg ,
333
+ {"type" : "context_menu" , "short_name" : "jump_to_sg" }
334
+ )
279
335
280
336
# Add the menu item only when there are some file system locations.
281
337
if ctx .filesystem_locations :
282
- engine .register_command ("Jump to File System" , self ._jump_to_fs , {"type" : "context_menu" , "short_name" : "jump_to_fs" })
338
+ engine .register_command (
339
+ "Jump to File System" ,
340
+ self ._jump_to_fs ,
341
+ {"type" : "context_menu" , "short_name" : "jump_to_fs" }
342
+ )
283
343
284
344
def _jump_to_sg (self ):
285
345
"""
286
- Callback to Jump to Shotgun from context
346
+ Callback to Jump to SG from context.
287
347
"""
288
348
from sgtk .platform .qt5 import QtGui , QtCore
289
349
url = self ._get_context_url (sgtk .platform .current_engine ())
0 commit comments