コンポーネントのContextMenuからコンポーネントをコピペできます。
この記事ではこれらをスクリプトから実行する方法を紹介します。
方法
UnityEditorInternal.CommandUtilityクラスのメソッドを使うだけです。
UnityEditorInternal.ComponentUtility.CopyComponent(); UnityEditorInternal.ComponentUtility.PasteComponentAsNew(); UnityEditorInternal.ComponentUtility.PasteComponentValues();
UnityEditorInternalのものなのでエディタ上でのみ使えます。
GameObjectのコンポーネントをすべてコピペ
GameObjectにアタッチされているコンポーネントをすべてコピペする方法は下記で紹介されています。