Last active
March 31, 2025 14:45
-
-
Save leestuartx/9e1bc376fd5cda583d098ecfc309120b to your computer and use it in GitHub Desktop.
Batch import Unity packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice script you got there! Cheers!