From Unify Community Wiki
Revision as of 10:10, 10 January 2012 by NCarter (Talk | contribs)

Jump to: navigation, search

Author: Steve Allison-Bunnell (with thanks to aarku)


Allows you to copy the local position, rotation, and scale of the currently selected object in the scene. Then you can paste this transform information into another object. Useful for positioning new prefabs in the location of a different prefab if you want to swap them.


You must place the script in a folder named Editor in your project's Assets folder for it to work properly.

Select an object in the scene heirarchy, then choose Transform Copier -> Copy Transform. This copies the local position, rotation, and scale of the selected object. Then select another object and choose Transform Copier -> Paste Transform. This will apply the copied transform to the new object. Both objects must either be at the root of the scene heirarchy or within the same parent for the transform to be applied properly.

Zipped file:

C# - CopyTransform.cs

using UnityEngine;
using UnityEditor;
using System.Collections;
public class TransformCopier : ScriptableObject
        private static Vector3 position;
        private static Quaternion rotation;
        private static Vector3 scale;
        private static string myName; 
    [MenuItem ("Custom/Transform Copier/Copy Transform")]
    static void DoRecord()
       position = Selection.activeTransform.localPosition;
       rotation = Selection.activeTransform.localRotation;
       scale = Selection.activeTransform.localScale;
       myName =;       
        EditorUtility.DisplayDialog("Transform Copy", "Local position, rotation, & scale of "+myName +" copied relative to parent.", "OK", "");
    [MenuItem ("Custom/Transform Copier/Paste Transform")]
    static void DoApply()
        Selection.activeTransform.localPosition = position;
        Selection.activeTransform.localRotation = rotation;
        Selection.activeTransform.localScale = scale;      
        EditorUtility.DisplayDialog("Transform Paste", "Local position, rotation, and scale of "+myName +"  pasted relative to parent of "".", "OK", "");
[[Category:Editor Scripts]]
[[Category:C Sharp]]
Personal tools