What it does is record the current position, scale, rotation of selected objects. Then later you can select “Apply Saved Transforms” (and you don’t have to have anything selected) and those recorded transform informations will be applied back to those objects you selected.
It’s useful for letting the physics engine position things and then applying that back to your actual scene.
It’s kind of confusing, so if anyone has an idea on how to make it better please chime in and I may see about fixing it.
What you would like to do is very possible too, I just don’t think there is a script on the wiki to do it right now.
Jon, would it be a matter of changing the functions to work with one object at a time and then to change the apply function to target the currently selected object instead of the old one?
It’d be a simpler script. In the record/copy function, you would record the localPosition, localScale, and localRotation of something like Selection.activeTransform into some static data structure. (Three static Vector3 would be just fine.)
Then in the apply/paste function, you would set the localPosition, localScale, and localRotation of something like Selection.activeTransform to the values contained in your stored static variables.
Shouldn’t be more than a few lines for each function. Probably more work here to type this post, but I think it’d be advantageous to just try it and come back if you hit a wall.
Jon, I did it! My first real Unity script and my first C# script:
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 = Selection.activeTransform.name;
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 "+Selection.activeTransform.name+".", "OK", "");
}
}
This does what I need it to, but it has no error checking to make sure that there’s an object selected, or to warn you if you can’t do what it says it’s going to do.
For some reason, the two commands are also reversed in order in the menu. I’m not sure why.
How about a Select unused assets one? For the project window
Ive installed all those wizard scripts, and theyre great-Cheers Jon!
I highly recommend them to everyone
AC