Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Dictionary<string, MonoBehaviour> registry;
- public MonoBehaviour testComponent;
- void Start(){
- registry = new Dictionary<string, MonoBehaviour> ();
- registry.Add ("TestComponent", testComponent);
- }
- public MonoBehaviour GetScript(string name)
- {
- return registry[name];
- }
- foreach (string comp in blockInfo.components) {
- //For each of the components that need to be added
- gameObject.AddComponent(ScriptMaster.compReg.GetScript(comp));
- //I know this is incorrect, but the idea is there
- }
- //you should be able to get the correct name by typeof(T).FullName
- // or instance.GetType().FullName
- foreach (string compTypeName in blockInfo.components)
- gameObject.AddComponent(Activator.CreateInstance(null, compTypeName ).Unwrap());
Add Comment
Please, Sign In to add comment