Removed sg_client instances, direct import of UnityEngine (#54)

Co-authored-by: mojibola obadimeji <mojibola.obadimeji@imaginary-spaces.com>
This commit is contained in:
jibola1997 2021-05-19 13:44:27 -04:00 коммит произвёл GitHub
Родитель 368ded6e86
Коммит e7c5ccbb15
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 10 добавлений и 16 удалений

Просмотреть файл

@ -1,5 +1,4 @@
from sg_client import GetUnityEngine
import UnityEngine
import json
import os
import sgtk
@ -44,7 +43,6 @@ class UnitySessionAddMetadataPlugin(HookBaseClass):
logger.critical("There is no text field 'sg_unity_metadata' on Version entity type. Create one to store Unity metadata when publishing a Version")
return
else:
UnityEngine = GetUnityEngine()
data_path = UnityEngine.Application.dataPath
project_path = os.path.dirname(data_path)
@ -61,7 +59,6 @@ class UnitySessionAddMetadataPlugin(HookBaseClass):
{ 'project_path' : project_path,
'scene_path' : scene_path,
'metadata_version': _metadata_version } )
# Update the version entity with new metadata
engine.shotgun.update('Version', version['id'], { 'sg_unity_metadata' : metadata_json } )

Просмотреть файл

@ -1,5 +1,6 @@
import sgtk
from sg_client import GetUnityEngine, GetUnityEditor
import UnityEngine
import UnityEditor
import json
import os
@ -101,8 +102,8 @@ class UnityActions(HookBaseClass):
"Parameters: %s. Shotgun Data: %s" % (name, params, sg_data))
if name == "jump_to_frame":
UnityEditor = GetUnityEditor()
UnityEngine = GetUnityEngine()
UnityEditor = UnityEditor
UnityEngine = UnityEngine
# Open the scene
metadata = params

Просмотреть файл

@ -1,6 +1,6 @@
# Shotgun
import sgtk
from sg_client import GetUnityEditor
import UnityEditor
# misc
import json
@ -47,8 +47,6 @@ class UnityApplyMetadata(HookBaseClass):
if not unity_metadata.relates_to_current_project(metadata):
self.logger.warning('Not applying Shotgun metadata as it does not relate to the currently loaded project. Metadata = "{}")'.format(pprint.pformat(metadata)))
# TODO: could we call GetUnityEditor().EditorApplication.OpenProject?
# What would be the effect on the bootstrap, domain reload, etc.?
return
# Find the scene to open
@ -56,5 +54,5 @@ class UnityApplyMetadata(HookBaseClass):
return
# open the correct scene in Unity
GetUnityEditor().SceneManagement.EditorSceneManager.OpenScene(metadata.get('scene_path'))
UnityEditor.SceneManagement.EditorSceneManager.OpenScene(metadata.get('scene_path'))

Просмотреть файл

@ -71,10 +71,10 @@ def get_metadata_from_entity(entity, sg):
return metadata
def relates_to_current_project(metadata):
from sg_client import GetUnityEngine
import UnityEngine
# Make sure the right project is currently loaded
loaded_project = GetUnityEngine().Application.dataPath
loaded_project = UnityEngine.Application.dataPath
# Remove /Assets
loaded_project = os.path.split(loaded_project)[0]
@ -86,14 +86,12 @@ def relates_to_current_project(metadata):
return metadata_project == loaded_project
def relates_to_existing_scene(metadata):
from sg_client import GetUnityEditor
import UnityEditor
metadata_scene_path = metadata.get('scene_path')
if not metadata_scene_path:
return False
UnityEditor = GetUnityEditor()
scene_guids = UnityEditor.AssetDatabase.FindAssets('t:scene')
for guid in scene_guids:
scene_path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid)