/// <summary>
        /// Adds selectedObject to the list of objects to be migrated. Return false if the object is not of type GameObject, or SceneAsset.
        /// </summary>
        public bool TryAddObjectForMigration(Type type, Object selectedObject)
        {
            if (MigrationState == MigrationToolState.Migrating)
            {
                Debug.LogError("Objects cannot be added during migration process.");
                return(false);
            }
            else if (MigrationState == MigrationToolState.PostMigration)
            {
                ClearMigrationList();
                MigrationState = MigrationToolState.PreMigration;
            }

            if (type == null)
            {
                Debug.LogError("Migration type needs to be selected before migration.");
                return(false);
            }

            if (type != migrationHandlerInstanceType)
            {
                ClearMigrationList();
                Debug.Log("New migration type selected for migration. Clearing previous selection.");

                if (!SetMigrationHandlerInstance(type))
                {
                    return(false);
                }
            }

            if (!selectedObject)
            {
                Debug.LogWarning("Selection is empty. Please select object for migration.");
                return(false);
            }

            if (selectedObject is GameObject || selectedObject is SceneAsset)
            {
                if (CheckIfCanMigrate(type, selectedObject) && !migrationObjects.ContainsKey(selectedObject))
                {
                    migrationObjects.Add(selectedObject, new MigrationStatus());
                    return(true);
                }
                else
                {
                    Debug.Log($"{selectedObject.name} does not support {type.Name} migration. Could not add object for migration");
                    return(false);
                }
            }
            Debug.LogError("Object must be a GameObject, Prefab or SceneAsset. Could not add object for migration");
            return(false);
        }
        /// <summary>
        /// Migrates all objects from list of objects to be migrated using the selected IMigrationHandler implementation.
        /// </summary>
        /// <param name="type">A type that implements IMigrationhandler</param>
        public bool MigrateSelection(Type type, bool askForConfirmation)
        {
            if (migrationObjects.Count == 0)
            {
                Debug.LogError($"List of objects for migration is empty.");
                return(false);
            }

            if (migrationHandlerInstanceType == null)
            {
                Debug.LogError($"Please select type for migration.");
                return(false);
            }

            if (type == null || migrationHandlerInstanceType != type)
            {
                Debug.LogError($"Selected objects should be migrated with type: {migrationHandlerInstanceType}");
                return(false);
            }

            if (askForConfirmation && !EditorUtility.DisplayDialog("Migration Window",
                                                                   "Migration operation cannot be reverted.\n\nDo you want to continue?", "Continue", "Cancel"))
            {
                return(false);
            }

            if (askForConfirmation && !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return(false);
            }
            var previousScenePath = EditorSceneManager.GetActiveScene().path;
            int failures          = 0;

            MigrationState = MigrationToolState.Migrating;

            for (int i = 0; i < migrationObjects.Count; i++)
            {
                var progress = (float)i / migrationObjects.Count;
                if (EditorUtility.DisplayCancelableProgressBar("Migration Tool", $"Migrating all {type.Name} components from selection", progress))
                {
                    break;
                }
                string assetPath = AssetDatabase.GetAssetPath(migrationObjects.ElementAt(i).Key);

                if (IsSceneGameObject(migrationObjects.ElementAt(i).Key))
                {
                    MigrateGameObjectHierarchy((GameObject)migrationObjects.ElementAt(i).Key, migrationObjects.ElementAt(i).Value);
                }
                else if (IsPrefabAsset(migrationObjects.ElementAt(i).Key))
                {
                    PrefabAssetType prefabType = PrefabUtility.GetPrefabAssetType(migrationObjects.ElementAt(i).Key);
                    if (prefabType == PrefabAssetType.Regular || prefabType == PrefabAssetType.Variant)
                    {
                        // there's currently 5 types of prefab asset types - we're supporting the following:
                        // - Regular: a regular prefab object
                        // - Variant: a prefab derived from another prefab which could be a model, regular or variant prefab
                        // we won't support the following types:
                        // - Model: we can't migrate fbx or other mesh files
                        // - MissingAsset: we can't migrate missing data
                        // - NotAPrefab: we can't migrate as prefab if the given asset isn't a prefab
                        MigratePrefab(assetPath, migrationObjects.ElementAt(i).Value);
                    }
                }
                else if (IsSceneAsset(migrationObjects.ElementAt(i).Key))
                {
                    MigrateScene(assetPath, migrationObjects.ElementAt(i).Value);
                }
                migrationObjects.ElementAt(i).Value.IsProcessed = true;
                failures += migrationObjects.ElementAt(i).Value.Failures;

                Debug.Log(migrationObjects.ElementAt(i).Value.Log);
            }
            EditorUtility.ClearProgressBar();

            if (!String.IsNullOrEmpty(previousScenePath) && previousScenePath != EditorSceneManager.GetActiveScene().path)
            {
                EditorSceneManager.OpenScene(Path.Combine(Directory.GetCurrentDirectory(), previousScenePath));
            }

            if (askForConfirmation)
            {
                string msg;
                if (failures > 0)
                {
                    msg = $"Migration completed with {failures} errors";
                }
                else
                {
                    msg = "Migration completed successfully!";
                }
                EditorUtility.DisplayDialog("Migration Window", msg, "Close");
            }

            MigrationState = MigrationToolState.PostMigration;
            return(true);
        }