BlenderTools icon indicating copy to clipboard operation
BlenderTools copied to clipboard

Send2Unreal - Support multiple scenes

Open garyritchie opened this issue 3 years ago • 4 comments

  • Addon: send2unreal
  • Workflow: For complex projects I like to use Blender Scenes for organization
  • Description: If you've already initialized send2unreal, and have the export collections in your scene ("Scene") you will not be able to use Pipeline -> Utilities -> Create Pre-defined Collections on subsequent scenes -- because those collections already exist in your initial scene.
  • Workaround: Rename the initial collections located in the first scene.

garyritchie avatar Nov 24 '21 21:11 garyritchie

@garyritchie Good point. So I took a look at the logic, and it only creates and links the collection if that actual collection data block does not exist.
https://github.com/EpicGames/BlenderTools/blob/144a441743739c0f9cf0d8ed84e1e1b538173e81/send2ue/addon/functions/utilities.py#L609

So in the case of multiple scenes it doesn't create the collections, because it already has them in the data blocks, which also by passes the call to link them to the current scene context.

So one option would be to change it to something like this:

collection = bpy.data.collections.get(collection_name)
if not collection:
    collection = bpy.data.collections.new(collection_name)

if not bpy.context.scene.collection.children.get(collection_name):
    bpy.context.scene.collection.children.link(collection)

What this would do is link the collection to the active scene context if it already exists.

image

image

One thing to note about this is this would also link all data contained in that collection as well. Here you can see the cube is now in the second scene as well as the first.

image

Another option would be to create a new collection for each scene that is name spaced with the scene name, so as to keep there data separate.

image

I think I am leaning more towards name spacing collections by scene, cause I think in general people would use separate scenes to keep there exports unique to a scene. What are your thoughts?

james-baber avatar Dec 03 '21 15:12 james-baber

@james-baber in the case of the first option, I think we can control export via visibility/render flags -- which would make that fix a good-enough option in my book.

While name-spacing scenes sounds like the proper fix, it also sounds more difficult to implement.

garyritchie avatar Dec 03 '21 16:12 garyritchie

Ok fair enough, I can just ensure that collections get linked to the active scene, and that should be an easy fix

james-baber avatar Dec 03 '21 16:12 james-baber

Cool, thank you!

garyritchie avatar Dec 03 '21 17:12 garyritchie