Created
December 3, 2013 19:35
-
-
Save karl-/7776063 to your computer and use it in GitHub Desktop.
Bundled with a unitypackage, this script will search for PACKNAME and load an editor window when imported.
This file contains 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
class MyPackInstaller : EditorWindow | |
{ | |
public static void Init() | |
{ | |
EditorWindow.GetWindow<MyPackInstaller>().Show(); | |
} | |
void OnGUI() | |
{ | |
// code to load pack with options here | |
} | |
} | |
class MyPackagePostProcessor : AssetPostprocessor | |
{ | |
const string PACKNAME = "MyPackage"; | |
static void OnPostprocessAllAssets ( | |
string[] importedAssets, | |
string[] deletedAssets, | |
string[] movedAssets, | |
string[] movedFromAssetPaths) | |
{ | |
foreach(var str in importedAssets) | |
{ | |
// Detect a new unity package | |
if(str.Contains(".unitypackage") && str.Contains(PACKNAME)) | |
{ | |
MyPackInstaller.Init(); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment