UnityPackage的导入开始、完成、取消、失败回调事件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public static class UnityPackageImportListener
{
static UnityPackageImportListener()
{
// .unitypackage开始导入
AssetDatabase.importPackageStarted += packageName =>
{
Debug.Log( packageName );
};
// .unitypackage导入完成
AssetDatabase.importPackageCompleted += packageName =>
{
Debug.Log( packageName );
};
// .unitypackage取消导入
AssetDatabase.importPackageCancelled += packageName =>
{
Debug.Log( packageName );
};
// .unitypackage导入失败
AssetDatabase.importPackageFailed += ( packageName, errorMessage ) =>
{
Debug.Log( errorMessage );
};
}
}