Skip to content

Instantly share code, notes, and snippets.

@karl-
Created December 3, 2013 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karl-/7776063 to your computer and use it in GitHub Desktop.
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.
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