glTFast
glTFast copied to clipboard
Exclude certain children when exporting? Or specify specific Renderers only?
Is your feature request related to a problem? Please describe. In my situation, I have a parent "main" mesh that has children that are only visible by a certain camera (mini map system). I want to export only the parent "main" meshes to a file, excluding its children.
Describe the solution you'd like Maybe just add a bool to the ExportSettings to indicate that the GameObject[] being passed in is specifically of only the objects to export, and not to include their children? This would [optionally] allow for more customization of what exactly is exported.
Describe alternatives you've considered The only thing that comes to mind is to unparent, export, then reparent the undesired children, but that's just clunky and not a great solution.
Additional context
For some context, attached is an image of my scene in the SceneView (Left) and GameView (Right). The entire scene is either constructed procedurally or designed at runtime. You can see there are additional meshes to display a stylized view to an ortho camera. I only want the "full 3D" meshes exported.
In MenuEntries.cs line 114, you could set it to false instead of true and hide gameobjects you don't want to export. Not sure if that works for you
Hi @SceneForgeStudio ,
Thanks for the feedback. Export definitely needs more ability to customize what shall get exported. Ideas:
- Do not export recursively (what you ask for, essentially)
- A component with per-GameObject settings that could include a "do not export" flag amonst other stuff (e.g. ignore mesh, camera, etc.)
- Overridable scene iteration (most complex bust also most customizable way)
I'd like to give this enough thought before going for a solution.
What already works as of today:
Objects that are not active (in the hierarchy), are not exported (if you didnt pass custom GameObjectExportSettings
with onlyActiveInHierarchy
flag to false). You could:
- Set all childrens' active flag to false
- Export
- Reset all childrens' active flag to true (or whatever it was before)
hth
Thanks for the replies!
@kyapp69 Ideally I wouldn't just hide exported objects in the resulting files, but actually exclude them from the exports, but I appreciate the suggestion!
@atteneder Not exporting recursively is exactly what I would like! I realize my explanation might have been overboard, haha!
I think a simple bool flag for that would be the easiest, if most basic solution. (Though still perfect for my needs, personally).
I was also thinking the same thing as a component (if I'm understanding correctly) or even a new data type that allows for easier customization. Maybe rather than an array of GameObjects themselves, an array of some new configurable object that represents individual GameObjects each with individual settings.
I didn't realize that currently only active objects get exported, I will just set them as inactive for now.
Thanks!
PS: Does the runtime exporter include cameras?
For reference, UnityGltf allows customization in a couple ways:
- decide to include/exclude by GameObject active state
- decide to include/exclude based on layers, auto-set layers by "main camera visibility" is the default - this might work here already
Update: In the current main
branch and in the upcoming 5.x release you can include/exclude:
- GameObjects by (in)active state (with an option to ignore it)
- GameObjects by layer mask
- GameObjects with
EditorOnly
tag (and their children) are always excluded - By component type (currently available: Mesh, Camera and Light)
- Individual components (like
Renderer
,Camera
orLight
) by their enabled state
I think this will be sufficient for most needs. It does not directly allow your requested workflow, which is not exporting root GameObjects recursively. I recommend to use either GameObject active state (temporarily set children inactive) or layers to solve that. Another option is to write a custom Exporter (by forking GameObjectExport
).
hth
I consider this issue resolved. Re-open (or raise another, specific issue) if you disagree.
PS: Does the runtime exporter include cameras?
Sorry, I missed that question: Yes, it does.