public void loadObjects()
		{
			UrlDir.UrlConfig[] configs = GameDatabase.Instance.GetConfigs("STATIC");
			
			foreach(UrlDir.UrlConfig conf in configs)
			{
				StaticModel model = new StaticModel();
				model.path = Path.GetDirectoryName(Path.GetDirectoryName(conf.url));
				model.config = conf.url;
				model.configPath = conf.url.Substring(0, conf.url.LastIndexOf('/')) + ".cfg";
				model.settings = KKAPI.loadConfig(conf.config, KKAPI.getModelSettings());

				if (model.settings.ContainsKey("LocalToSave"))
				{
					if ((string)model.getSetting("LocalToSave") == "True")
					{
						// Debug.Log("KK: Static Config is local to save. Skipping model and its instances.");
						continue;
					}
				}

				foreach (ConfigNode ins in conf.config.GetNodes("MODULE"))
				{
					// Debug.Log("KK: Found module: "+ins.name+" in "+conf.name);
					StaticModule module = new StaticModule();
					foreach (ConfigNode.Value value in ins.values)
					{
						switch (value.name)
						{
							case "namespace":
								module.moduleNamespace = value.value;
								break;
							case "name":
								module.moduleClassname = value.value;
								break;
							default:
								module.moduleFields.Add(value.name, value.value);
								break;
						}
					}
					model.modules.Add(module);
					// Debug.Log("KK: Adding module");
				}

				loadInstances(conf.config, model);
				
				staticDB.registerModel(model);
			}
		}
        public void loadObjects()
        {
            UrlDir.UrlConfig[] configs = GameDatabase.Instance.GetConfigs("STATIC");

            foreach(UrlDir.UrlConfig conf in configs)
            {
                StaticModel model = new StaticModel();
                model.path = Path.GetDirectoryName(Path.GetDirectoryName(conf.url));
                model.config = conf.url;
                model.configPath = conf.url.Substring(0, conf.url.LastIndexOf('/')) + ".cfg";
                model.settings = KKAPI.loadConfig(conf.config, KKAPI.getModelSettings());

                if (model.settings.ContainsKey("LocalToSave"))
                {
                    if ((string)model.getSetting("LocalToSave") == "True")
                        continue;
                    // Ignore it for second pass
                }

                /* if (model.settings.ContainsKey("mesh"))
                {
                    string sMesh = (string)model.getSetting("mesh");
                    if (sMesh.Contains(".mu"))
                    {}
                    else
                    {
                        Debug.Log("KK: mesh name missing suffix. Adding it.");
                        sMesh = sMesh + ".mu";
                        model.setSetting("mesh", sMesh);
                    }
                } */

                if (model.settings.ContainsKey("pointername"))
                {
                    if ((string)model.getSetting("pointername") != "None")
                        continue;
                    // Ignore it for second pass
                }

                foreach (ConfigNode ins in conf.config.GetNodes("MODULE"))
                {
                    StaticModule module = new StaticModule();
                    foreach (ConfigNode.Value value in ins.values)
                    {
                        switch (value.name)
                        {
                            case "namespace":
                                module.moduleNamespace = value.value;
                                break;
                            case "name":
                                module.moduleClassname = value.value;
                                break;
                            default:
                                module.moduleFields.Add(value.name, value.value);
                                break;
                        }
                    }
                    model.modules.Add(module);
                }

                loadInstances(conf.config, model);

                staticDB.registerModel(model);
            }
        }
        public void loadObjects()
        {
            UrlDir.UrlConfig[] configs = GameDatabase.Instance.GetConfigs("STATIC");

            foreach(UrlDir.UrlConfig conf in configs)
            {
                StaticModel model = new StaticModel();
                model.path = Path.GetDirectoryName(Path.GetDirectoryName(conf.url));
                model.config = conf.url;
                model.configPath = conf.url.Substring(0, conf.url.LastIndexOf('/')) + ".cfg";
                model.settings = KKAPI.loadConfig(conf.config, KKAPI.getModelSettings());

                foreach (ConfigNode ins in conf.config.GetNodes("MODULE"))
                {
                    Debug.Log("KK: Found module: "+ins.name+" in "+conf.name);
                    StaticModule module = new StaticModule();
                    foreach (ConfigNode.Value value in ins.values)
                    {
                        switch (value.name)
                        {
                            case "namespace":
                                module.moduleNamespace = value.value;
                                break;
                            case "name":
                                module.moduleClassname = value.value;
                                break;
                            default:
                                module.moduleFields.Add(value.name, value.value);
                                break;
                        }
                    }
                    model.modules.Add(module);
                    Debug.Log("KK: Adding module");
                }

                foreach (ConfigNode ins in conf.config.GetNodes("Instances"))
                {
                    // Debug.Log("KK: Loading models");
                    StaticObject obj = new StaticObject();
                    obj.model = model;
                    obj.gameObject = GameDatabase.Instance.GetModel(model.path + "/" + model.getSetting("mesh"));

                    if (obj.gameObject == null)
                    {
                        Debug.Log("KK: Could not find " + model.getSetting("mesh") + ".mu! Did the mod forget to include it or did you actually install it?");
                        continue;
                    }
                    // Debug.Log("KK: mesh is " + (string)model.getSetting("mesh"));

                    obj.settings = KKAPI.loadConfig(ins, KKAPI.getInstanceSettings());

                    if (!obj.settings.ContainsKey("LaunchPadTransform") && obj.settings.ContainsKey("LaunchSiteName"))
                    {

                        if (model.settings.Keys.Contains("DefaultLaunchPadTransform"))
                        {
                            obj.settings.Add("LaunchPadTransform", model.getSetting("DefaultLaunchPadTransform"));
                        }
                        else
                        {
                            Debug.Log("KK: Launch site is missing a transform. Defaulting to " + obj.getSetting("LaunchSiteName") + "_spawn...");

                            if (obj.gameObject.transform.Find(obj.getSetting("LaunchSiteName") + "_spawn") != null)
                            {
                                obj.settings.Add("LaunchPadTransform", obj.getSetting("LaunchSiteName") + "_spawn");
                            }
                            else
                            {
                                Debug.Log("KK: FAILED: " + obj.getSetting("LaunchSiteName") + "_spawn does not exist! Attempting to use any transform with _spawn in the name.");
                                Transform lastResort = obj.gameObject.transform.Cast<Transform>().FirstOrDefault(trans => trans.name.EndsWith("_spawn"));

                                if (lastResort != null)
                                {
                                    Debug.Log("KK: Using " + lastResort.name + " as launchpad transform");
                                    obj.settings.Add("LaunchPadTransform", lastResort.name);
                                }
                                else
                                {
                                    Debug.Log("KK: All attempts at finding a launchpad transform have failed (╯°□°)╯︵ ┻━┻ This static isn't configured for KK properly. Tell the modder.");
                                }
                            }
                        }
                    }

                    staticDB.addStatic(obj);
                    spawnObject(obj, false);
                    if (obj.settings.ContainsKey("LaunchSiteName"))
                    {
                        LaunchSiteManager.createLaunchSite(obj);
                    }
                }

                staticDB.registerModel(model);
            }
        }