From b7fec88ca64557690681d7630a411ecf104e6d87 Mon Sep 17 00:00:00 2001 From: Jan Discart Date: Tue, 11 May 2021 22:35:03 +0200 Subject: [PATCH] Global Dependency Scene Injection - Fixed issue where only root objects of the scene where injected. - Removed the option to export examples separately because they were moved in the Toolkit folder itself. --- Assets/Editor/Export/ExportPackage.cs | 40 +++++++++---------- .../SceneInjection/GlobalDependencyContext.cs | 2 +- .../Toolkit/Scripts/Extensions.meta | 8 ++++ 3 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 Assets/Impossible Odds/Toolkit/Scripts/Extensions.meta diff --git a/Assets/Editor/Export/ExportPackage.cs b/Assets/Editor/Export/ExportPackage.cs index 34332a6..6d3a02c 100644 --- a/Assets/Editor/Export/ExportPackage.cs +++ b/Assets/Editor/Export/ExportPackage.cs @@ -31,24 +31,24 @@ private static void ExportToolkit() AssetDatabase.ExportPackage("Assets/Impossible Odds", fullPath, ExportPackageOptions.Recurse); } - [MenuItem("Assets/Impossible Odds/Export Toolkit Examples")] - private static void ExportExamples() - { - string path = EditorPrefs.GetString(ExportPackageDirectoryKey, Application.dataPath); - string name = EditorPrefs.GetString(ExportPackageExamplesNameKey, "Impossible Odds Toolkit Examples"); - string fullPath = EditorUtility.SaveFilePanel("Export Impossible Odds Examples", path, name, PackageExtension); - - if (string.IsNullOrEmpty(fullPath)) - { - return; - } - - FileInfo fileInfo = new FileInfo(fullPath); - path = fileInfo.DirectoryName; - name = Path.GetFileNameWithoutExtension(fileInfo.Name); - EditorPrefs.SetString(ExportPackageDirectoryKey, path); - EditorPrefs.SetString(ExportPackageExamplesNameKey, name); - - AssetDatabase.ExportPackage("Assets/Examples/Impossible Odds", fullPath, ExportPackageOptions.Recurse); - } + // [MenuItem("Assets/Impossible Odds/Export Toolkit Examples")] + // private static void ExportExamples() + // { + // string path = EditorPrefs.GetString(ExportPackageDirectoryKey, Application.dataPath); + // string name = EditorPrefs.GetString(ExportPackageExamplesNameKey, "Impossible Odds Toolkit Examples"); + // string fullPath = EditorUtility.SaveFilePanel("Export Impossible Odds Examples", path, name, PackageExtension); + + // if (string.IsNullOrEmpty(fullPath)) + // { + // return; + // } + + // FileInfo fileInfo = new FileInfo(fullPath); + // path = fileInfo.DirectoryName; + // name = Path.GetFileNameWithoutExtension(fileInfo.Name); + // EditorPrefs.SetString(ExportPackageDirectoryKey, path); + // EditorPrefs.SetString(ExportPackageExamplesNameKey, name); + + // AssetDatabase.ExportPackage("Assets/Examples/Impossible Odds", fullPath, ExportPackageOptions.Recurse); + // } } diff --git a/Assets/Impossible Odds/Toolkit/Scripts/DependencyInjection/SceneInjection/GlobalDependencyContext.cs b/Assets/Impossible Odds/Toolkit/Scripts/DependencyInjection/SceneInjection/GlobalDependencyContext.cs index 9274b4c..9695a8a 100644 --- a/Assets/Impossible Odds/Toolkit/Scripts/DependencyInjection/SceneInjection/GlobalDependencyContext.cs +++ b/Assets/Impossible Odds/Toolkit/Scripts/DependencyInjection/SceneInjection/GlobalDependencyContext.cs @@ -107,7 +107,7 @@ private IEnumerable FindStaticMethods(Type attributeType) private void OnSceneLoaded(Scene scene, LoadSceneMode sceneLoadMode) { Log.Info("Injecting scene '{0}' with the global dependency context.", scene.name); - scene.GetRootGameObjects().Inject(DependencyContainer); + scene.GetRootGameObjects().Inject(DependencyContainer, true); } } } diff --git a/Assets/Impossible Odds/Toolkit/Scripts/Extensions.meta b/Assets/Impossible Odds/Toolkit/Scripts/Extensions.meta new file mode 100644 index 0000000..f534967 --- /dev/null +++ b/Assets/Impossible Odds/Toolkit/Scripts/Extensions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 86c645df89d6440ccad298d58035c610 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: