Skip to content

Conversation

@quentin452
Copy link
Contributor

@quentin452 quentin452 commented Mar 22, 2025

current bugs :

  • If i export a cube which using "resources/units/cube" to somewhere in the project browser , i need to restart the editor completly to be here correctly , if i don't restart the editor the object isn't drawed or something like that (probably need a recompile)
  • After exporting the unit and importing it into the editor, the original name and prefab of the object I clicked on to export are changed. The prefab name is set to , and the unit name is set to . However, the exported unit itself is correct
  • doesn't support children components (fbx)
  • resources path not get exported correctly
  • need to recreate Guid at export

current enhancements :

  • Need to support FBX
  • Need to set FileChooserDialog default path to the source folder
  • Need to refactor the exporter code to become easier to read

@quentin452 quentin452 marked this pull request as draft March 22, 2025 06:48
@quentin452 quentin452 changed the title Can export unit to file (.unit , .material , .mesh) when right clicking on a unit from the level tree Can export unit to file (.unit , .material , .mesh, .fbx , .importer_settings) when right clicking on a unit from the level tree Mar 22, 2025
@quentin452 quentin452 marked this pull request as ready for review March 23, 2025 02:00
@dbartolini
Copy link
Collaborator

Thanks, this is a very much needed feature, however, why the need to copy materials/meshes/etc.?

I didn't think about this too much, but saving a prefab should be equivalent to duplicating an object and then saving it to a file.

If that's the case, calling Database.duplicate(unit_id, prefab_id) and then Database.save(prefab_path, prefab_id) should do it; yes, that creates unwanted objects into the main database, but you can remove them after save() or just extend duplicate() to output into a different Database.

@quentin452
Copy link
Contributor Author

ok , then l'il see this later , for now i am on the pr #318

@quentin452
Copy link
Contributor Author

the problem is that , duplicate and save saves only modified_components, not components and children components ,so idk if i will use duplicate and save from database

@dbartolini
Copy link
Collaborator

duplicate(object) copies the whole object (all its fields), and all its sub-objects recursively.

You are only getting modified_components back because you are calling duplicate() on a freshly spawned cube. But that's actually what I would expect. If you notice, you also get a prefab key that refers to the original .unit prefab you spawned (i.e. core/units/primitives/cube). And that's a valid prefab to save().

Try creating a new empty unit (Create -> Empty Unit), and add components to it via the Inspector. Then save that unit and you will see a different thing.

@dbartolini
Copy link
Collaborator

Implemented in: #395

@dbartolini dbartolini closed this May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants