I just wanted to let everyone know that I released my Component Copier editor extension on the Unity Asset Store. It lets you easily copy and paste components and their variable values.
A simple, intuitive interface gives you granular control over which components and variables to copy, and then paste onto multiple GameObjects.
I’m using it now. Very nice and handy. However, I could not find an option to select “All” from the copy component list. Is there one? if not, it would be a nice feature. I have components with a lot of variables and I found it quite tiresome to have to go through and check them all… and all are needing to be copied sometimes.
I noticed if you try to copy multiple components of the same type from one game object to the other the Component Copier only copies one instance of that type to the new game object.
For instance, let’s say I have three different Audio Sources on one game object and I want to copy all three of them to another game object, when I paste the three Audio Source components to the new game object, only one of the Audio Sources is copied to the new game object.
Is there a solution or workaround to this? Or can you add this to the Component Copier? Thank you.
Great script so far! However, I ran into an instancing issue as well.
For example. I select a prefab, and in the Inspector I have some custom components scripts that house some color values. When I copy that component onto another prefab, adjust the colors, it like-wise changes the color from the original source. Essentially instancing it. Have you run into this, or do you further plan to expound on the script to not have this happen? It would be great if next to the copy button in the Component Copier dialog box, you had a couple of radio buttons that gives you the option to either “Instance or Copy” the component.
Cmarchal, I think I have an idea of what you are talking about. For example, if you copy a Mesh Renderer and copy it’s sharedMaterial property you will get a reference to the Material that is shared between both objects. If you change the color of this Material it will change the color on both objects, and any other object that shares this Material.
However if you copy the Mesh Renderer’s material property you will get a new instance of the Material and changes to the color will not affect other objects that have separate instances of the Material. Also, if you copy the material property Unity will give you an error about leaking Materials into the scene. I’ve noticed the same thing happens with MeshFilters and it’s mesh/sharedMesh properties.
One thing that concerns me about this is that with the ability to Select All people will end up for example selecting to copy both the sharedMaterial and material properties without really thinking about it. It seems that when you do this the material property wins out and an instance is created.
As you can see it’s not really an issue of creating “Instance or Copy” radio buttons, but rather which properties you choose to copy.
I think I found a bug, or an incompatability issue. I’m not completely sure component copier is to blame, but considering it is what lead me to my solution, anyway.
I’m working on a game that features two robot arms built out of configurable joints. Their movement was very snappy when development started, since I used very high values for spring force and dampening.
At some point I used Component Copier to copy some of the physics settings between hierarchies. After that, the arms were sluggish and wobbly, no matter how high I set their spring force values.
Over the last 5 hours I examined every single setting in meticulous detail, comparing asset server snapshots of before and after. I couldn’t find a single thing in the inspector or in my code that made the difference.
Finally my eye spotted the “ComponentCopier.cs - Added” log, and I grew suspicious.
I completely removed and readded all the physics components, manually keyed in the settings I used before, and everything is fixed. So I’m kind of hitting the conclusion that Component Copier messed up some hidden settings in either Configurable Joint or Rigidbody. I’m too tired to verify this right now, but I might tomorrow.
Tinus, I’m sorry to hear you are having trouble. One thing I would recommend is only selecting the specific variables you know for sure that you need rather than using “Select All”. Occasionally people get strange results selecting all with some of Unity’s internal classes when they aren’t familiar with every variable, as some have conflicting effects like the sharedMaterial/material issue I described in response to Cmarchal a few posts ago in this thread.
I do have a question: lets say I import a mesh with 20 materials, each material mapped with one color map, each texture different for each material. Once the mesh is in Unity, I want to change the first material to a different one and than to copy&replace the old material with the new one on all the other materials in one go. All this with keeping the old texture in place, not being replaced by the texture from the new material that needs to overwrite the old material? Is it possible? It`ll be a huge time saver.
Thanks.
@Mark_T Unfortunately I don’t think the Component Copier can help you with this as materials are not technically components and the Component Copier does not have access to their properties. However I do have a suggestion that might be helpful to you. If you want to use the same shader for all 20 of your materials, but you just want different textures for each you could combine your textures into one texture atlas and then you would only need one material instead of 20. This would also give you much better rendering performance as Unity will be able to batch your whole mesh into one draw call instead of 20.
If you really need to do things the way you describe it wouldn’t be that difficult to write an editor script that loops through the materials on a GameObject’s renderer, stores their textures, loops through again to change them all to new instances of the one material you want, and then loop through once more to set the new material instances to use the original textures.
I noticed with Component Copier you can only copy public variables/fields, is there anyway you can have it so we can copy any type of variable. That would save me a lot of time, because a lot of the time my variables are private/protected, but Serialized just to be set in the inspector, but when I try to copy them and paste them, they don’t show up. Thanks.
@AbsurdHart I’ve submitted an update that now shows private and protected fields that use the SerializeFields attribute. It looks like it’s live in the Asset Store now, so give it a try and let me know what you think.