private void OnEnable() { VRModule.onActiveModuleChanged += OnActiveModuleChanged; VRModule.Initialize(); UpdateHeight(); }
private static void LoadModsFromAssembly(Assembly assembly) { try { foreach (Type t in assembly.GetLoadableTypes()) { if (t.IsSubclassOf(typeof(VRCMod))) { try { VRCMod modInstance = Activator.CreateInstance(t) as VRCMod; Mods.Add(modInstance); ModControllers.Add(new VRCModController(modInstance)); VRCModInfoAttribute modInfoAttribute = modInstance.GetType().GetCustomAttributes(typeof(VRCModInfoAttribute), true).FirstOrDefault() as VRCModInfoAttribute; if (modInfoAttribute != null) { modInstance.Name = modInfoAttribute.Name; modInstance.Version = modInfoAttribute.Version; modInstance.Author = modInfoAttribute.Author; modInstance.DownloadLink = modInfoAttribute.DownloadLink; } } catch (Exception e) { VRCModLogger.Log("[WARN] [ModManager] Could not load mod " + t.FullName + " in " + assembly.GetName() + "! " + e); } } if (t.IsSubclassOf(typeof(VRModule))) { try { ModuleInfoAttribute moduleInfo; if ((moduleInfo = (t.GetCustomAttributes(typeof(ModuleInfoAttribute), true).FirstOrDefault() as ModuleInfoAttribute)) != null) { VRCModLogger.Log("Adding component " + t); VRModule vrmodule = ModComponent.modulesGameObject.gameObject.AddComponent(t) as VRModule; Modules.Add(vrmodule); vrmodule.Initialize(moduleInfo, moduleManager); } } catch (Exception e) { VRCModLogger.Log("[WARN] [ModManager] Could not load module " + t.FullName + " in " + assembly.GetName() + "! " + e); } } } } catch (Exception e) { VRCModLogger.LogError("[ModManager] Could not load " + assembly.GetName() + "! " + e); } }