Last active
July 4, 2016 07:36
-
-
Save z3t0/12c3f400827ae915446182537b0ba32d 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) => | |
{ | |
string fileName = t.ToString() + ".cs"; | |
Debug.Log(t.GetType()); | |
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) { | |
Debug.Log("found a match: '" + fileName + "' is from Mod: '" + mod.name + "'"); | |
if(typeof(Component).IsAssignableFrom(t)){ | |
return mod.gameobject.AddComponent(t); | |
// return mod.loadedScripts.Add(fileName, t); | |
} | |
} | |
} | |
} | |
Debug.Log("Script: '" + fileName + "cannot find its Mod"); | |
return System.Activator.CreateInstance(t); | |
}; |
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
void CreateNewInstances() | |
{ | |
if (assembly == null) return; | |
foreach (var type in assembly.GetTypes()) | |
{ | |
manager.synchronizedInvoke.Invoke((System.Action)(() => | |
{ | |
instances.Add(manager.createInstance(type)); | |
}), null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment