Skip to content

Instantly share code, notes, and snippets.

@leestuartx
Last active March 31, 2025 14:45
Show Gist options
  • Save leestuartx/9e1bc376fd5cda583d098ecfc309120b to your computer and use it in GitHub Desktop.
Save leestuartx/9e1bc376fd5cda583d098ecfc309120b to your computer and use it in GitHub Desktop.
Batch import Unity packages
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using System.IO;
public class BatchImportAssetPackages : ScriptableWizard
{
public string packagePath = "";
[MenuItem("Game Gen/Asset/Import Packages")]
static void CreateWizard()
{
ScriptableWizard.DisplayWizard("Create Menu", typeof(BatchImportAssetPackages));
}
void OnWizardCreate()
{
packagePath = packagePath.Replace("\\", "/") + "/";
string[] allFilePaths = Directory.GetFiles(Path.GetDirectoryName(packagePath));
try
{
foreach (string curPath in allFilePaths)
{
string fileToImport = curPath.Replace("\\", "/");
if (Path.GetExtension(fileToImport).ToLower() == ".unitypackage")
{
Debug.Log("Importing: " + fileToImport);
AssetDatabase.ImportPackage(fileToImport, false);
}
}
}
catch (System.Exception ex)
{
Debug.Log("Error: " + ex.Message);
}
}
}
@AldeRoberge
Copy link

Nice script you got there! Cheers!

@Acceleration2299
Copy link

Hi, How do you use this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment