Skip to content

Instantly share code, notes, and snippets.

@z3t0
Created July 4, 2016 08:05
Show Gist options
  • Save z3t0/c8afa38cf0c6df31153b22321d75e736 to your computer and use it in GitHub Desktop.
Save z3t0/c8afa38cf0c6df31153b22321d75e736 to your computer and use it in GitHub Desktop.
loader.createInstance = (Type t) =>
{
bool found = false;
string fileName = t.ToString() + ".cs";
foreach (var mod in modLoader.mods) {
string modPath = mod.path + "/Scripts/";
foreach (var script in mod.scripts) {
string shortPath = script.Substring(modPath.Length);
if(shortPath == fileName) {
if(typeof(Component).IsAssignableFrom(t)){
Debug.Log("found a match: '" + fileName + "' is from Mod: '" + mod.name + "'");
// return mod.gameobject.AddComponent(t);
mod.loadedScripts.Add(fileName, t);
found = true;
}
}
}
}
if (!found)
Debug.LogError("Script: '" + fileName + "' cannot find its Mod");
return (object) fileName;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment