Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
Last active December 30, 2015 04:29
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 AngryAnt/7775939 to your computer and use it in GitHub Desktop.
Save AngryAnt/7775939 to your computer and use it in GitHub Desktop.
A quick example demonstrating how unpacking logic for an asset store package could be set up to be contingent on the presence of a specific code dependency.
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies ())
{
string location = Path.GetDirectoryName (assembly.CodeBase).Replace (Path.DirectorySeparatorChar, '/');
if (location.StartsWith ("file:"))
{
location = location.Substring ("file:".Length);
}
if (!location.BeginsWith (Application.dataPath.Substring (0, Application.dataPath.Length - "Assets".Length)))
// Only search assemblies present in this project (including those resulting from user script compilation)
{
continue;
}
Type
solutionAtype = assembly.GetType ("SolutionAType"),
solutionBtype = assembly.GetType ("SolutionB.Type"); // Remembering to specify namespaces if relevant
if (solutionAtype != null)
{
InstallForSolutionA ();
break;
}
else if (solutionBtype != null)
{
InstallForSolutionB ();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment