Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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