Skip to main content
Added image, people like images. Formatting and a little more "cutting to the chase"
Source Link
House
  • 73.3k
  • 17
  • 185
  • 273

I work with a team that calls itself Defective Studios. We'veWe've struggled with the same issue for years, and just recently I finally gave in and started writing an extension to help me merge gameobjects. It turned out so well, and we used it so much, that I prettied it up a bit and released it on the Asset Store. Sorry, it's paid, but we hope we picked a reasonable price. Basically

Basically the approach is to create an inspector-like interface in a window that lines up each gameobject, component, and property side-by-side for comparison, and provides buttons to copy values (or whole objects) from one side to another. If you're familiar with the SerializedPropertySerializedProperty class, that's what is doing the bulk of the work here. We basically create a GUI that synchronizes the foldout state between the right and left side, and creates vertical space wherever a GameObjectGameObject or ComponentComponent exists on only the right or left side. A comparison function checks equality at each level, and turns the background of each line to red or green depending on the state of the equality. Any line whose children contain a difference will also become red, and we also included a nifty button to recursively search the tree and expand all objects that are different or have differences in their children.

As well, there is a set of mask fields (a string field in Unity 3, where MaskField doesn't exist) that let you filter certain component types out of the comparison. GameObject attributes like name, layer, and tag are also compared. We use SerializedObjectSerializedObject and SerializedPropertySerializedProperty to loop through the gameObject'sgameObject's properties, and draw them just like they're drawn in the inspector. This ensures consistency, and is a heck of a lot easier to code! As a result, there are a few cases (GUIStyles being one known issue that jumps to mind) where the comparison is a little screwy, and for now we let them default to "equal" so as not to throw of the parent comparison. In this regard, the tool still needs a little bit of work (and stress testing!). One

enter image description here

One last nifty detail is that the comparison process (triggered when the objects are loaded and whenever a change is made) is run in an ad-hoc coroutine that is updated by the EditorWindow.UpdateEditorWindow.Update function, so that in case you are comparing a hugely complicated object, the window doesn't lock up the editor. This was a must when comparing objects with hundreds (or thousand!) of children. All in all, it was kind of a "lego project" as my friend likes to say, but definitely an invaluable tool which instantly became a part of our collaboration workflow.

The tool, Unity Merge is documented on the Unify wiki, which includes a roadmap and an e-mail address for feedback and issue reporting. If you're really struggling with a complicated merge, give it a shot and let us know what you think! Also, I didn't bother to build it into a DLL (you can just decompile it anyway), so feel free to poke around at the source. The ad-hoc coroutine implementation and SerializedPropertySerializedProperty manipulations, as well as a few GUI tricks that I ended up needing are a great part of your editor extension toolkit. I'm very interested in changes/improvements that users might have, so please get in touch!

I work with a team that calls itself Defective Studios. We've struggled with the same issue for years, and just recently I finally gave in and started writing an extension to help me merge gameobjects. It turned out so well, and we used it so much, that I prettied it up a bit and released it on the Asset Store. Sorry, it's paid, but we hope we picked a reasonable price. Basically the approach is to create an inspector-like interface in a window that lines up each gameobject, component, and property side-by-side for comparison, and provides buttons to copy values (or whole objects) from one side to another. If you're familiar with the SerializedProperty class, that's what is doing the bulk of the work here. We basically create a GUI that synchronizes the foldout state between the right and left side, and creates vertical space wherever a GameObject or Component exists on only the right or left side. A comparison function checks equality at each level, and turns the background of each line to red or green depending on the state of the equality. Any line whose children contain a difference will also become red, and we also included a nifty button to recursively search the tree and expand all objects that are different or have differences in their children.

As well, there is a set of mask fields (a string field in Unity 3, where MaskField doesn't exist) that let you filter certain component types out of the comparison. GameObject attributes like name, layer, and tag are also compared. We use SerializedObject and SerializedProperty to loop through the gameObject's properties, and draw them just like they're drawn in the inspector. This ensures consistency, and is a heck of a lot easier to code! As a result, there are a few cases (GUIStyles being one known issue that jumps to mind) where the comparison is a little screwy, and for now we let them default to "equal" so as not to throw of the parent comparison. In this regard, the tool still needs a little bit of work (and stress testing!). One last nifty detail is that the comparison process (triggered when the objects are loaded and whenever a change is made) is run in an ad-hoc coroutine that is updated by the EditorWindow.Update function, so that in case you are comparing a hugely complicated object, the window doesn't lock up the editor. This was a must when comparing objects with hundreds (or thousand!) of children. All in all, it was kind of a "lego project" as my friend likes to say, but definitely an invaluable tool which instantly became a part of our collaboration workflow.

The tool, Unity Merge is documented on the Unify wiki, which includes a roadmap and an e-mail address for feedback and issue reporting. If you're really struggling with a complicated merge, give it a shot and let us know what you think! Also, I didn't bother to build it into a DLL (you can just decompile it anyway) so feel free to poke around at the source. The ad-hoc coroutine implementation and SerializedProperty manipulations, as well as a few GUI tricks that I ended up needing are a great part of your editor extension toolkit. I'm very interested in changes/improvements that users might have, so please get in touch!

I work with a team that calls itself Defective Studios. We've struggled with the same issue for years, and just recently I finally gave in and started writing an extension to help me merge gameobjects.

Basically the approach is to create an inspector-like interface in a window that lines up each gameobject, component, and property side-by-side for comparison, and provides buttons to copy values (or whole objects) from one side to another. If you're familiar with the SerializedProperty class, that's what is doing the bulk of the work here. We basically create a GUI that synchronizes the foldout state between the right and left side, and creates vertical space wherever a GameObject or Component exists on only the right or left side. A comparison function checks equality at each level, and turns the background of each line to red or green depending on the state of the equality. Any line whose children contain a difference will also become red, and we also included a nifty button to recursively search the tree and expand all objects that are different or have differences in their children.

As well, there is a set of mask fields that let you filter certain component types out of the comparison. GameObject attributes like name, layer, and tag are also compared. We use SerializedObject and SerializedProperty to loop through the gameObject's properties, and draw them just like they're drawn in the inspector. This ensures consistency, and is a heck of a lot easier to code!

enter image description here

One last nifty detail is that the comparison process (triggered when the objects are loaded and whenever a change is made) is run in an ad-hoc coroutine that is updated by the EditorWindow.Update function, so that in case you are comparing a hugely complicated object, the window doesn't lock up the editor. This was a must when comparing objects with hundreds (or thousand!) of children. All in all, it was kind of a "lego project" as my friend likes to say, but definitely an invaluable tool which instantly became a part of our collaboration workflow.

The tool, Unity Merge is documented on the Unify wiki, which includes a roadmap and an e-mail address for feedback and issue reporting. If you're really struggling with a complicated merge, give it a shot and let us know what you think! Also, I didn't bother to build it into a DLL, so feel free to poke around at the source. The ad-hoc coroutine implementation and SerializedProperty manipulations, as well as a few GUI tricks that I ended up needing are a great part of your editor extension toolkit. I'm very interested in changes/improvements that users might have, so please get in touch!

Source Link
scone
  • 141
  • 1

I work with a team that calls itself Defective Studios. We've struggled with the same issue for years, and just recently I finally gave in and started writing an extension to help me merge gameobjects. It turned out so well, and we used it so much, that I prettied it up a bit and released it on the Asset Store. Sorry, it's paid, but we hope we picked a reasonable price. Basically the approach is to create an inspector-like interface in a window that lines up each gameobject, component, and property side-by-side for comparison, and provides buttons to copy values (or whole objects) from one side to another. If you're familiar with the SerializedProperty class, that's what is doing the bulk of the work here. We basically create a GUI that synchronizes the foldout state between the right and left side, and creates vertical space wherever a GameObject or Component exists on only the right or left side. A comparison function checks equality at each level, and turns the background of each line to red or green depending on the state of the equality. Any line whose children contain a difference will also become red, and we also included a nifty button to recursively search the tree and expand all objects that are different or have differences in their children.

As well, there is a set of mask fields (a string field in Unity 3, where MaskField doesn't exist) that let you filter certain component types out of the comparison. GameObject attributes like name, layer, and tag are also compared. We use SerializedObject and SerializedProperty to loop through the gameObject's properties, and draw them just like they're drawn in the inspector. This ensures consistency, and is a heck of a lot easier to code! As a result, there are a few cases (GUIStyles being one known issue that jumps to mind) where the comparison is a little screwy, and for now we let them default to "equal" so as not to throw of the parent comparison. In this regard, the tool still needs a little bit of work (and stress testing!). One last nifty detail is that the comparison process (triggered when the objects are loaded and whenever a change is made) is run in an ad-hoc coroutine that is updated by the EditorWindow.Update function, so that in case you are comparing a hugely complicated object, the window doesn't lock up the editor. This was a must when comparing objects with hundreds (or thousand!) of children. All in all, it was kind of a "lego project" as my friend likes to say, but definitely an invaluable tool which instantly became a part of our collaboration workflow.

The tool, Unity Merge is documented on the Unify wiki, which includes a roadmap and an e-mail address for feedback and issue reporting. If you're really struggling with a complicated merge, give it a shot and let us know what you think! Also, I didn't bother to build it into a DLL (you can just decompile it anyway) so feel free to poke around at the source. The ad-hoc coroutine implementation and SerializedProperty manipulations, as well as a few GUI tricks that I ended up needing are a great part of your editor extension toolkit. I'm very interested in changes/improvements that users might have, so please get in touch!