Last active
July 30, 2019 03:25
-
-
Save TsubameUnity/2e6b0dd8a0120e158793279990a44c33 to your computer and use it in GitHub Desktop.
AssetDatabase.ImportPackageを連続で呼び出す
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 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