Last active
December 30, 2015 04:29
-
-
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.
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
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