Created
July 4, 2016 08:05
-
-
Save z3t0/c8afa38cf0c6df31153b22321d75e736 to your computer and use it in GitHub Desktop.
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
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