Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks for catching errors while importing project settings. #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Editor/Core/Config/Common/ImportProjectSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class ImportProjectSettings : OptionalExecutor
public override int Priority => Constants.Priority.ProjectSettingsImport;
public override string Description => "Import ProjectSettings from games with globalgamemanagers";
public long IncludedSettings;
public bool LogImportErrors;
private AssetsManager assetsManager;
private YAMLExportManager exportManager;
private PPtrExporterInfo pptrExporterInfo;
Expand Down Expand Up @@ -125,9 +126,18 @@ private void ExportGlobalGameManagers(AssetsFileInstance globalGameManagersFile,
fileName = Enum.GetName(typeof(AssetClassID), info.TypeId);
}

AssetExternal assetExternal = assetsManager.GetExtAsset(globalGameManagersFile, 0, info.PathId);
var collection = new ProjectSettingCollection { Assets = { assetExternal } };
SaveCollection(collection, null, Path.Combine(outputProjectSettingsDirectory, $"{fileName}.{collection.ExportExtension}"), unityVersion);
try
{
AssetExternal assetExternal = assetsManager.GetExtAsset(globalGameManagersFile, 0, info.PathId);
var collection = new ProjectSettingCollection { Assets = { assetExternal } };
SaveCollection(collection, null, Path.Combine(outputProjectSettingsDirectory, $"{fileName}.{collection.ExportExtension}"), unityVersion);
}
catch (Exception exception)
{
if (LogImportErrors)
Debug.LogError($"Caught an error when trying to import external asset from path ID {info.PathId} of the game managers file: {exception}");
}

}
}

Expand Down
21 changes: 9 additions & 12 deletions UXML/Settings/ImportProjectSettings.UXML
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<ui:UXML xmlns:ui="UnityEngine.Experimental.UIElements" xmlns:uie="UnityEditor.Experimental.UIElements" editor-extension-mode="True">

<ui:VisualElement class="thunderkit-field">
<ui:Label text="Included Settings" class="thunderkit-field-label"
tooltip="Project Settings to import if available in the game files"
/>
<uie:MaskField name="included-settings-field" binding-path="IncludedSettings" choices="AudioManager, ClusterInputManager, DynamicsManager, EditorBuildSettings, EditorSettings, GraphicsSettings, InputManager, NavMeshAreas, NetworkManager, Physics2DSettings, PresetManager, ProjectSettings, QualitySettings, TagManager, TimeManager, UnityConnectSettings, VFXManager, XRSettings " class="thunderkit-field-input"
tooltip="Project Settings to import if available in the game files"
/>
</ui:VisualElement>

<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
<ui:VisualElement class="thunderkit-field">
<ui:Label text="Included Settings" tooltip="Project Settings to import if available in the game files" class="thunderkit-field-label" />
<uie:MaskField name="included-settings-field" binding-path="IncludedSettings" choices="AudioManager, ClusterInputManager, DynamicsManager, EditorBuildSettings, EditorSettings, GraphicsSettings, InputManager, NavMeshAreas, NetworkManager, Physics2DSettings, PresetManager, ProjectSettings, QualitySettings, TagManager, TimeManager, UnityConnectSettings, VFXManager, XRSettings " tooltip="Project Settings to import if available in the game files" class="thunderkit-field-input" />
</ui:VisualElement>
<ui:VisualElement class="thunderkit-field" style="flex-grow: 1; background-color: rgba(0, 0, 0, 0); flex-direction: row;">
<ui:Label tabindex="-1" text="Log Settings Import Errors" display-tooltip-when-elided="true" class="thunderkit-field-label" style="flex-grow: 0; flex-direction: row;" />
<ui:Toggle value="false" binding-path="LogImportErrors" class="thunderkit-field-input" />
</ui:VisualElement>
</ui:UXML>