Skip to content

Instantly share code, notes, and snippets.

@TsubameUnity
Last active July 30, 2019 03:25
Show Gist options
  • Save TsubameUnity/2e6b0dd8a0120e158793279990a44c33 to your computer and use it in GitHub Desktop.
Save TsubameUnity/2e6b0dd8a0120e158793279990a44c33 to your computer and use it in GitHub Desktop.
AssetDatabase.ImportPackageを連続で呼び出す
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
public class ImportPackageList : ScriptableSingleton<ImportPackageList>
{
public List<string> list;
}
public class Import
{
[MenuItem("Import/テスト")]
static void ImportTest()
{
ScriptableSingleton<ImportPackageList>.instance.list =
new List<string> { @"C:\Users\Desktop\1.unitypackage", @"C:\Users\Desktop\2.unitypackage" };
AssetDatabase.importPackageCompleted += Complete;
ImportTest2();
}
static void ImportTest2()
{
if (ScriptableSingleton<ImportPackageList>.instance.list?.Count <= 0)
{
return;
}
AssetDatabase.ImportPackage(ScriptableSingleton<ImportPackageList>.instance.list[0], true);
ScriptableSingleton<ImportPackageList>.instance.list.RemoveAt(0);
}
public static void Complete(string name)
{
Debug.Log($"{nameof(Complete)}/{name}");
ImportTest2();
}
}
public class ImportProcessor : AssetPostprocessor
{
static void OnGeneratedCSProjectFiles()
{
Debug.Log("call");
Import.Complete("");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment