Wanzyee Studio

Utility to copy UnityEngine.Component or UnityEngine.Material and paste it back. More...

Inherits EditorWindow, and IHasCustomMenu.

Public Member Functions

void AddItemsToMenu (GenericMenu menu)
 Add the window context menu items. More...
 

Static Public Member Functions

static void OpenWindow ()
 Open the window. More...
 
static bool IsCopyable (Object source)
 Determine if the specified source is able to copy to clipboard. More...
 
static void Copy (params Object[] sources)
 Copy the specified sources to clipboard. More...
 
static void Clear (Type type=null)
 Clear clipboard by specified type, or pass null to clear all. More...
 

Public Attributes

bool track
 Flag to track selection to change search filter automatically. More...
 
string search = ""
 The search filter pattern in the search bar. More...
 
bool setting
 Flag to show settings. More...
 

Properties

static bool preferPersist [get, set]
 Flag to persist new copies as asset if possible. More...
 

Detailed Description

Utility to copy UnityEngine.Component or UnityEngine.Material and paste it back.

Useful for tweaking lots of objects in the editor, even in play mode. Click the menu "Window/Clipboard" to open the window. Just play and tweak, drag and drop, copy and paste whenever. It acts as sort of preset system, edit lots of copies as presets, and paste to apply values quickly. Easy to find and manage copies with a search filter, custom item label, and foldable inspector.

Copy:

  1. Drag'n'Drop from "Inspector" to copy the inspected sources.
  2. Drag'n'Drop a UnityEngine.GameObject to copy the components on it.
  3. Show menu to specify the component type if press "Ctrl" and drop gameObjects.
  4. Or click the context menu "Copy to Clipboard".

Paste:

  1. Drag'n'Drop to "Inspector" to paste back to the inspected targets.
  2. When dragging a component, it pastes values to the first one on the gameObject, or pastes as new if none.
  3. Show menu to specify a target of multiple components if press "Ctrl" and drop.
  4. Or click the "Copy" button above any item, and paste by the target's context menu.

Filter items with the search bar:

  1. Click the "Magnifier" icon to show a context menu made from the current items to select filters easily.
  2. Or input any text to filter the item's name, just like the Project window's search bar.
  3. Prefix "t:" filters by the type, the search will include all specified types.
  4. Prefix "l:" filters by the tooltip as labels, an item has to match all specified labels.
  5. Toggle the "Link" icon at the top-right of window to filter automatically by tracking selection.

Edit the item label:

  1. Click the "Pen" button beside the label to show or hide the edit field.
  2. To save the change, just press "Ctrl-Enter" or unfocus the field after editing.
  3. The first line shows as the label title, and the full text is the tooltip.
  4. Leave the field empty to show the default text, i.e., the copy source path.

Find the copy source object:

  1. Click the "Aim" button to ping it or double-click to select it.
  2. The saved trace path is also shown as the default label tooltip.
  3. It'll beep if not found, e.g., the trace may be lost if the source is moved or renamed.

The reasons not to save the trace by references below:

  1. A scene object reference will change when load a scene.
  2. We can't save the scene reference in the project assets.
  3. We shouldn't save the edit data in user's game scene.

For component references to scene object. This creates copies and store in editor scene temporarily to ensure content correct. It means the copy will be destroyed when quitting the editor. And also, the scene references will become missing when opening another scene. The situation above is applicable to a material with scene texture, too.

For material or component without reference to any scene object. The copies will be saved with a label "Ignore" in an asset folder to make them still until manually "Clear". This tracks all copies by specific name or folder to ensure valid after script reloaded.

SVN users may clear all manually to avoid committing, or ignore the storing folder below:

  1. The default is "Temp/Clipboard" under the root folder "Assets/WanzyeeStudio".
  2. If the root is moved, it becomes "Temp/Clipboard" under the first found "WanzyeeStudio".
  3. If there's no "WanzyeeStudio" folder, it'll be "Assets/Temp/Clipboard".

Instructions, to copy and paste generic component is dangerous, even if reflect all the fields. Since we'll never know what the developer do when the component awake. As the thread I commented, we'd be very careful with which aren't made by ourselves. Finally, this was created, works in the editor with Unity built-in classes and API.

Member Function Documentation

static void OpenWindow ( )
static

Open the window.

static bool IsCopyable ( Object  source)
static

Determine if the specified source is able to copy to clipboard.

Parameters
sourceSource object.
Returns
true if is copyable; otherwise, false.
static void Copy ( params Object[]  sources)
static

Copy the specified sources to clipboard.

Parameters
sourcesSource objects.
static void Clear ( Type  type = null)
static

Clear clipboard by specified type, or pass null to clear all.

void AddItemsToMenu ( GenericMenu  menu)

Add the window context menu items.

Menu "About" to open the online manual, and "Settings" for common preferences. Menu "New Window" to open another Clipboard window.

Parameters
menuMenu.

Member Data Documentation

bool track

Flag to track selection to change search filter automatically.

string search = ""

The search filter pattern in the search bar.

bool setting

Flag to show settings.

Property Documentation

bool preferPersist
staticgetset

Flag to persist new copies as asset if possible.

Enable to save the copies for next time opening the project. Disable to make copying faster without creating asset if you don't need. It only applies to copy operations after changing this setting.