Search Unity

  1. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice

Improved clipboard copy/paste

Discussion in '2020.1 Beta' started by Aras, Feb 24, 2020.

  1. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,691
    Since 2020.1 alpha 23 there is this release notes item: "Editor: Added Copy/Paste support for most inspector fields (vectors, colors, object references, gradients, animation curves ...). All they produce text in system clipboard, and the copied values can be sent to someone else or pasted into another Unity instance." Here's a bit more about it.

    Added Copy/Paste keyboard shortcuts and context menus to Serialized Property fields (e.g. in Inspector, or anywhere else they are displayed) for most types. This is: Vector2, Vector3, Vector4, Quaternion, Color, Object Reference, Gradient, Animation Curve, Rect, Bounds, LayerMask, Enum, Bool, RectInt, Vector2Int, Vector3Int.


    All these produce text-based representation in the system Clipboard, so you can send that to someone else on a chat, or paste into a text document, or into another Unity instance, etc. Examples of text representations produced by copying simple fields:

    Vector3(10,11,12)
    Vector3(60.0,30.0,45.0)
    Quaternion(0.531975687,0.0222599953,0.200562119,0.822363079)
    #ACFF04
    Color(0.1,3,4,1)
    Bounds(1,-2.5,3.7,1.5,-2,7.7)



    More complex ones are copied/pasted from a TypePrefix:JSON format, for example an animation curve:
    UnityEditor.AnimationCurveWrapperJSON:{"curve":{"serializedVersion":"2","m_Curve":[{"serializedVersion":"3","time":0.016666412353515626,"value":0.660369873046875,"inSlope":2.0,"outSlope":2.0,"tangentMode":0,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408},{"serializedVersion":"3","time":1.0,"value":1.0,"inSlope":0.0,"outSlope":0.0,"tangentMode":0,"weightedMode":0,"inWeight":0.3333333432674408,"outWeight":0.3333333432674408}],"m_PreInfinity":2,"m_PostInfinity":2,"m_RotationOrder":4}}

    Some fields have slightly more specialized context menus, e.g. Quaternion fields can copy either euler angles, or the raw quaternion:


    Or an object reference field can also copy path or the GUID:


    Scene view camera window menu can now copy/paste the camera placement (position+rotation), and the settings themselves. And again that produces just a text in clipboard, so you can send that off to someone else and they can paste into their own scene view.


    In the Animation Window, animation events can also be copied/pasted, either via keyboard shortcuts or the context menus:


    The same is for the animation clip editor in the model import settings events part:




    Let us know what you think!




    Note: a bunch of possible clipboard improvements are not made yet, for example:
    • C# APIs to copy/paste typed things into Clipboard from code,
    • Support for more SerializedProperty field types (custom structs/classes, arrays, ...)
    • Change "Copy Component" and friends to also produce text-based data in system clipboard, so you could paste that into another Unity instance, send to someone, etc.
    • Look into a hundred other places in the editor, where Copy/Paste would be needed, and add that there.
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,584
    Deozaan, hippocoder, mh114 and 2 others like this.
  3. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    That's cool, thanks !
    One thing that would be really useful (I almost need it every day I'm working in Unity) is to be able to copy/paste every value of every component attached to a gameObject. (Right now you can only do it for one component :()

    Use case is, for example, trying things (mostly UI) in playmode, when you get the desired result -> right click the gameObject -> "Copy components values" -> stop playmode -> Paste

    That would be neat !
     
    DoctorShinobi likes this.
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,691
    Sounds like what you really want is a "save playmode changes" feature? :)
     
    Lars-Steenhoff, transat and Ofx360 like this.
  5. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,691
    Yes, as long as clipboard contents is one of: #RGB, #RRGGBB, #RGBA, #RRGGBBAA or "Color(r,g,b,a)"
     
    Peter77 and DoctorShinobi like this.
  6. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Not necessarily, but it would be useful too ! Being able to copy an object (you actually can do that already by creating a prefab within playmode, then unpack it after) with two clicks would be great :)
     
    Kingblade likes this.
  7. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,991
    Oh wow, this finally happened :D This has been easily my top editor annoyances for years and have many times hoped Unity would implement this (can't remember how many times I've asked about this in past).

    Thank you! :)
     
  8. jbergs

    jbergs

    Joined:
    Feb 13, 2014
    Posts:
    14
    Not sure if this is part of this system but the ability to Cut/Paste keys in the Animation window and Timeline window would be awesome. I spend lots and lots of time copying > pasting > then deleting old keys.
     
  9. frarf

    frarf

    Joined:
    Nov 23, 2017
    Posts:
    26
    Are we supposed to take that as a hint? ;)
     
  10. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,991
    That apply button should be there :) like just have a way to apply the changes before you exit playmode. The copy / paste setup helps but it's tedious.

    This is something people have always struggled with Unity. In Unity 4 I worked around the lack of copy/paste by just dragging a prefab from gameobject while the game was running and then swapped the GO with the prefab once stopped the play in the editor :D

    ScriptableObjects getting more commonly used have also helped a lot.
     
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,899
    I love this so much. Thanks!

    Btw when you get a chance (I know this is cheeky) but a major, major quality of life thing I added was having a back and forward shortcut. This is the same in visual studio or your browser, it would be such an instinctive and phenomenal navigation tool when you're object hopping around the project window.
     
    Arathorn_J, Peter77 and SugoiDev like this.
  12. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,691
    On the list, but not related to copy/paste!
     
    hippocoder likes this.
  13. SirIntruder

    SirIntruder

    Joined:
    Aug 16, 2013
    Posts:
    43
    While on this subject, any hint of copy/cut/paste of files in the project window? :) Moving a a file from folder A to folder B in big projects is quite a bit of effort currently
     
  14. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,899
    I did try using the new Properties (context menu) feature to get a folder and not just an object in focus but it didn't work. Perhaps it could be expanded? right click a target folder and you get a neat project window pop with the top level being that folder.

    Seems slightly unusual but no less useful.

    (for now you could bookmark a folder and drag something in there - at least in theory that would work)
     
  15. SirIntruder

    SirIntruder

    Joined:
    Aug 16, 2013
    Posts:
    43
    yeah, I could also open an another project window and lock it. But in all cases I need to awkwardly navigate back and forth, instead of cut -> go to destination folder -> paste.
     
  16. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,973
    On the topic of copy/paste, any chance copy/paste was added to the Assets (e.g. Prefabs, Materials, etc...)?
     
  17. Kingblade

    Kingblade

    Joined:
    Jan 15, 2014
    Posts:
    8
    Would love to be able to copy an entire game object hierarchy from one project to another with a simple CTR+C, CTR+V
     
    transat likes this.
  18. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    772
    Screen Shot 2020-04-22 at 10.49.02 pm (2).png


    @Aras, I'd like to right click here to paste components, rather than on the tiny vertical ellipsis.
     
    Havokki, Aras, Baste and 4 others like this.
  19. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,584
    Most GameObjects in my projects have Components attached, there is no free space to right-click in most cases, unless you search for it.

    What I think should be supported is to paste Components with the Ctrl+V shortcut. If you copied a Component, select another GameObject and press Ctrl+V, it should paste the Component to the selected GameObject. "Paste values" if a the same Component exists on the target GO already, or add the Component if it does not exist yet.

    This would allow to paste a Component without having to scroll down in the inspector to find the free space at the bottom to right-click and choose "Paste" in the context-menu.


    PS: You don't have to click the vertical ellipsis button, you can also right-click on any Component header.
     
    firstuser likes this.
  20. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,391
    Why be humble about it:

    upload_2020-4-23_10-26-33.png

    I'm all in favour about being able to right click on the empty space, but also next to the add component button and really wherever.

    Just let me throw my mouse over there and go "paste" and not have to aim would be A+++. Might be usability stuff I haven't thought about, but copy-pasting is great and having to aim to do it is lame.
     
    firstuser, Kingblade and transat like this.
  21. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    772
    I get what you're saying but as @Baste pointed out it doesn't have to be one or the other. Personally I would never use Ctrl+V as I would not be confident that I'd be pasting the component in the right place, especially considering you can have 2 inspectors open (with one locked)... a scenario which might not be so uncommon if you're copying and pasting components from one GO to another.

    PS - Didn't know I could click on any component header. Handy tip! Cheers!
     
    Peter77 and hippocoder like this.
  22. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,899
    Yeah there can be multiple inspectors and it's not easy to figure which would be selected (like properties). Best not have keyboard shortcuts for those. Keep keyboard shortcuts for values or for scene operations.
     
  23. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,391
    ctrl+v would (probably) work on the current active window, so you'd click in the inspector you want to paste in before pasting.

    If you hit paste and you have the wrong window focused, you just ctrl+z, so it's no biggie.
     
  24. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,899
    They'd need to increase the visibility of which inspector to use. With the new right-click properties feature, people can have a ton of these.

    Is it worth having inspectors have this highlighted border, or fading and unfading it, really worth it to support a single copy and paste keyboard shortcut?

    Especially shortcuts that are shared with other tasks. I'd say it's all possible but I wouldn't want to be the people coding the supporting work required for it or documenting it.
     
    transat likes this.
  25. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,691
    New in 2020.2 alpha 8 related to clipboard (https://unity3d.com/unity/alpha/2020.2.0a8):
    • User-written serializable C# class & struct fields can be copy-pasted in the inspector
    • Keyboard shortcuts for "copy scene camera placement" and "paste scene camera placement" (no shortcuts are assigned by default; use shortcuts dialog)
     
  26. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,391
    @Aras, thoughts about pasting into the area below the Add Component button? Bad idea, Good idea will do it, Good idea not sure if will do it, Jury Still Out?
     
  27. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,691
    Added into a todo list, but not sure when exactly we'll get to actually do it :)
     
    Baste likes this.
unityunity