Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Transformのコピーアンドペースト
using UnityEngine;
using UnityEditor;
using System.Collections;
/// <summary>
/// Transformのコピーアンドペースト
/// </summary>
/// <author>
/// Create by yumehachi on 2013/12/02
/// </author>
public class TransformCopyAndPaste : ScriptableObject
{
private static Vector3 position;
private static Quaternion rotation;
private static Vector3 scale;
/// <summary>
/// Transformをコピーします
/// </summary>
[MenuItem ("Edit/Transform Copy &%c")]
static void Copy ()
{
position = Selection.activeTransform.localPosition;
rotation = Selection.activeTransform.localRotation;
scale = Selection.activeTransform.localScale;
}
/// <summary>
/// Transformを貼付けします
/// </summary>
[MenuItem ("Edit/Transform Paste &%v")]
static void AllPaste ()
{
Selection.activeTransform.localPosition = position;
Selection.activeTransform.localRotation = rotation;
Selection.activeTransform.localScale = scale;
}
/// <summary>
/// Positionのみ貼付けます
/// </summary>
[MenuItem ("Edit/Transform Position Paste &%p")]
static void PositionPaste ()
{
Selection.activeTransform.localPosition = position;
}
/// <summary>
/// Rotationのみ貼付けます
/// </summary>
[MenuItem ("Edit/Transform Rotation Paste &%r")]
static void RotationPaste ()
{
Selection.activeTransform.localRotation = rotation;
}
/// <summary>
/// Scaleのみ貼付けます
/// </summary>
[MenuItem ("Edit/Transform Scale Paste &%s")]
static void ScalePaste ()
{
Selection.activeTransform.localScale = scale;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment