I want to replace the mesh of two objects in different scenes with one from a different blend file, but if I try to load the library from two different scripts, It obviously won’t work because “the blend file is already open”.
Is there any way to access a library that is already opened in another script?
You don’t have to load the library in two different scripts, you just need to access the already loaded mesh in two different scenes, which is completely OK. So load the library in your main scene in some startup script, then do something like this whenever/wherever you need swap out some mesh:
from bge import logic
cont = logic.getCurrentController()
me = cont.owner
scenes = logic.getSceneList()
mainScene = [scene for scene in scenes if scene.name == "Scene"][0] #yuck...
mesh = mainScene.objectsInactive['doDad'].meshes[0]
me.replaceMesh(mesh)
… edit …
Hmm, this works… sorta, but after playing around with it for a while, it does not behave how I would have expected it to. The mesh is rendered as if the objects its linked to are all in the same scene. Camera position in overlay scenes is not respected.
Seems like a bug… though I could just be overlooking something…
Now I have another problem because I want one scene to be the overlay scene of the other. I made an example blend to show you:
(I’m sorry, it’s hard to understand what’s going on, but I did what I could.)
edit: Just read your edit… It’s exactly that problem.
Is there really no solution to this?