Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Component Copier now on the Unity Asset Store

Discussion in 'Assets and Asset Store' started by skateborden, Jan 30, 2012.

  1. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    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.

    Check out our demo video to see it in action: http://youtu.be/_neo4SYEpSQ

    You can find it on the Unity Asset Store now!
    http://u3d.as/content/is3d/component-copier/

    Of course I'd be happy to answer any questions, or hear any comments you may have.
     
    NOT_Lonely likes this.
  2. Zerk

    Zerk

    Joined:
    Jul 26, 2011
    Posts:
    4
    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.
     
  3. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    Zerk, I just submitted an update to the Asset Store that allows you to easily select/deselect all of a component's variables. I hope you like it!
     
  4. Zerk

    Zerk

    Joined:
    Jul 26, 2011
    Posts:
    4
    Perfect! Just what the doctor ordered. :) Thanks!
     
  5. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    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.
     
  6. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    Check the Asset Store AbsurdHart, I've got an update for you. ;)
     
  7. Danny_HoW

    Danny_HoW

    Joined:
    May 4, 2012
    Posts:
    47
    Nice work I like it
     
  8. CMarchal

    CMarchal

    Joined:
    May 3, 2012
    Posts:
    1
    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.

    Thanks!
     
  9. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
  10. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    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.
     
  11. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Thanks skateborden.
     
  12. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    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. :)
     
    Last edited: Jun 13, 2012
  13. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    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.
     
  14. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I'm starting to see why Unity never got around to implementing this themselves. Sounds complicated. :)

    Still, I love this asset, it's a huge time saver, even if there are some dangers to not paying attention to what you're copying.
     
  15. Tinus

    Tinus

    Joined:
    Apr 6, 2009
    Posts:
    437
    @Skateborden: Because of sleep deprivation I forgot to say: Yeah, on the whole Component Copier is a very neat piece of kit! Thanks for making it. :)
     
  16. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    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.
     
  17. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    @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.
     
  18. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    Hey skateborden,

    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.
     
  19. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    @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.
     
  20. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    It works great. Thanks skateborden.
     
  21. kayy

    kayy

    Joined:
    Jul 26, 2011
    Posts:
    110
    I noticed that the entries in Component menu are gone while tranform right click is still available and does the job. Maybe that's confusing for new users watching your video. I'm on Mac OSX 10.7.4 with Unity 3.5.3
     
  22. u0204909

    u0204909

    Joined:
    Jun 25, 2012
    Posts:
    21
    Hi, is there a way to append a component instead of overwriting a component of the same type? For example, I am using PlayMaker and my GameObject has multiple PlayMaker FSMs, each FSM a component in the GameObject. I have many prefabs that use a common FSM as well as a different FSM. So far, when I copy and paste, I will overwrite all the FSMs in my destination object. If I copied 1 FSM and my destination had 2 FSMs, they will be overwritten to become only 1 FSM. Is there a way to append a component instead of overwriting all same component types? If not, if there a way you could implement that into component copier? It will add a very practical function to the package :)
     
  23. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    @kayy I don't know why the menu options in the Component menu sometimes disappear, but I'm pretty sure it's something on Unity's side and not a problem with the Component Copier script. I'd be happy to be proven wrong, but as far as I know there isn't anything I can do about it. It seems like the right click on Transform still works for everyone, and I also added keyboard shortcuts in the last update (On Mac: Cmd+Option+C to Copy and Cmd+Option+V to paste, On Windows: Ctrl+Alt+C to copy and Ctrl+Alt+V to paste), so I'm sorry for the inconvenience but if your Component menu options disappear I recommend using those.

    @u0204909 If I understand correctly, you want an option to paste new instances of the copied components, instead of pasting over the existing ones? My only concern is that adding multiple paste options might be confusing to some people and pasting over is the functionality that most people need. What does everyone else think? If more people want this functionality then I will gladly implement it.
     
  24. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Hi Sketeborden,

    I like u0204909s idea. I have a number of components that use the same name for each instance, and that find of function would be great to have.

    Paul
     
  25. danboutros

    danboutros

    Joined:
    Mar 26, 2012
    Posts:
    32
    Hi there.

    I was very excited to hear your script works with Playmaker, and I found the right click / transform option to copy the FSM component.

    However, I copy it and I find nothing in the FSM that has newly appeared.

    I then realized there's a tick box and a drop down where I could pick details of what I copy.

    I tick everything, and it thinks the FSM is attached to the source object, so I'm reticent to change anything.

    I'm a little stuck here. I try eliminating some fields and then I get nothing copied over at all.

    It's either all, and attached to the source, or nothing and attached to the new object.

    I've tried going back and forth but the fact is, it doesn't seem to work well with PlayMaker.

    I then realized I could just copy / paste the FSM from within Playmaker using Copy / Paste.

    Lesson learned...
     
  26. MABManZ

    MABManZ

    Joined:
    Sep 29, 2011
    Posts:
    144
    Pretty old thread but I just started using this :p

    Is there a way to make "Select All" checked by default for the components? I would save me about 5-6 clicks for every component I try to copy, even using this it's still pretty tedious and barely saving me time from copying/pasting each component manually using Inspector.
     
  27. Magge

    Magge

    Joined:
    Aug 26, 2013
    Posts:
    1
    Or even better, a select all for all components and its settings - would be so nice! Thats alot of clicks less for each copy :D
     
  28. skateborden

    skateborden

    Joined:
    Apr 1, 2009
    Posts:
    35
    You can make these changes with a few minor changes to the ComponentCopier.cs script. To select all components by default add the following for loop after line 42 in the Copy() function

    Code (csharp):
    1.  
    2. 42      selectedComponents = new bool[components.Length];  // existing line in the script
    3. 43
    4. 44      for (int i = 0; i < components.Length; i++) { // new for loop
    5. 45          selectedComponents[i] = true;
    6. 46      }
    7.  
    To select all components variables by default add the following for loops at the end of the copy function, but be aware of the issues some people mention with Select All earlier in this forum thread about conflicting variables. selectedFields would have been line 107 and selectedProperties line 108 if you didn't make the previous modification, lines 111 and 112 if you did.

    Code (csharp):
    1.  
    2.             selectedFields[i] = new bool[fields[i].Count]; // existing line in the script
    3.             for (int j = 0; j < fields[i].Count; j++) { // new for loop
    4.                 selectedFields[i][j] = true;
    5.             }
    6.             selectedProperties[i] = new bool[properties[i].Count]; // existing line in the script
    7.             for (int j = 0; j < properties[i].Count; j++) { // new for loop
    8.                 selectedProperties[i][j] = true;
    9.             }
    10.     }
    11.  
     
  29. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81
    Is there a way to default to copy all the fields and not have to click the drop down and select "select all"?

    Thanks