From Unify Community Wiki
Revision as of 04:13, 20 October 2006 by DocSWAB (Talk | contribs)

Jump to: navigation, search

Author: Steve Allison-Bunnell


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.

C# - CopyTransform.cs

<csharp> using UnityEngine; using UnityEditor; using System.Collections;

public class TransformCopier : ScriptableObject {

       private static Vector3 position;
       private static Quaternion rotation;
       private static Vector3 scale;  
   [MenuItem ("Custom/Transform Copier/Copy Selected Transform")]
   static void DoRecord()
      position = Selection.activeTransform.localPosition;
      rotation = Selection.activeTransform.localRotation;
      scale = Selection.activeTransform.localScale;       
       EditorUtility.DisplayDialog("Transform Copier Copy", "Local Transform 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 Copier Paste", "Local Transform Pasted Relative to Parent.", "OK", "");

} </csharp>

Personal tools