Search Unity

Quality of Life Feature Request

Discussion in 'Editor & General Support' started by Sesshomurai, Nov 26, 2020.

  1. Sesshomurai

    Sesshomurai

    Joined:
    Jun 14, 2020
    Posts:
    19
    Hi,
    I'm new to Unity, but one thing I thought would be very useful is to copy multiple fields of an object while in Play mode, and then paste those fields back in edit mode, on the original fields.

    Currently, I can only cut and paste one field and it will paste wherever I paste it.

    What would be better is, let's say in play mode to modify an objects Position and Scale. I want to right click on Positon->Copy and then right click on Scale->copy. Now both values are in the clipboard.

    I go back into Edit mode and then in the inspector, I right click on Scale->Paste. This pastes the Scale values.
    I then right click on Position->Paste. This pastes the position values.

    Thanks
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    One way you can SORT of get this, to a limited degree, is during the run, press PAUSE, then drag the hierarchy you care about into the project area, which will make a spontaneous prefab.

    Once you stop running, you now have that prefab as a frozen "snapshot" of your runtime values, and you can load it alongside other assets and copy / paste / replace stuff at your leisure.
     
    adamgolden likes this.
  3. Sesshomurai

    Sesshomurai

    Joined:
    Jun 14, 2020
    Posts:
    19
    Ok, thanks. But cherry picking values and pasting them over should be a pretty simple implementation so maybe a dev catches this post one day.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Short of just making a "deep multi-object clipboard" I can't even imagine what the UI for this feature would look like.

    Let's say you have 7 positions and 4 scales to click and paste. So you go through the paused running scene and hoover those 7 positions up, copy, copy, copy.

    Then you stop the editor and get to the prefab or scene and start pasting all 7 positions back along with all 4 scales... How do you ensure you keep them all straight? Names? What about dupe names? Position in hierarchy? What if things move or change at runtime?
     
  5. Sesshomurai

    Sesshomurai

    Joined:
    Jun 14, 2020
    Posts:
    19
    It's pretty simple. Every property has a name. No UI changes for this feature needed.
    Let's say I Copy 7 different properties. Whenever I paste over top a property that I already copied from (it's in the clipboard), just use that stored copy by its name (if I copied position and I paste over a position property, then paste the position property not the scale property etc). If I past a value on a different field, then just take the last copied property like it is now.
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    You could make an editor script that iterates and hoovers up all the items at runtime (while paused), writes them to a JSON file, perhaps indexed by their full hierarchy name.

    Then at edit-time read in the JSON and inject it throughout the scene. You could make it graphical so that you select/deselect only the fields (or names) you want to copy (like checkboxes).
     
  7. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Good idea - you might also be able to persist data from Play Mode->Edit Mode using EditorPrefs (with a string from JsonUtility.ToJson example). I haven't personally tried setting EditorPrefs during play mode but I imagine it should work ?
     
  8. ledshok

    ledshok

    Joined:
    Oct 28, 2012
    Posts:
    28
    You can copy and paste component values (in play mode or edit mode) using the dotted menu:
    upload_2020-11-27_20-4-44.png
     
    adamgolden likes this.