// TransformCopier.cs v 1.1
// homepage: http://wiki.unity3d.com/index.php/CopyTransform 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 ("Window/Transform Copier/Copy",false,)]
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", "");
} // PASTE POSITION:
[MenuItem ("Window/Transform Copier/Paste Position",false,)]
static void DoApplyPositionXYZ () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localPosition = position;
} [MenuItem ("Window/Transform Copier/Paste Position X",false,)]
static void DoApplyPositionX () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localPosition = new Vector3(position.x, selection.localPosition.y, selection.localPosition.z);
} [MenuItem ("Window/Transform Copier/Paste Position Y",false,)]
static void DoApplyPositionY () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localPosition = new Vector3(selection.localPosition.x, position.y, selection.localPosition.z);
} [MenuItem ("Window/Transform Copier/Paste Position Z",false,)]
static void DoApplyPositionZ () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localPosition = new Vector3(selection.localPosition.x, selection.localPosition.y, position.z);
} // PASTE ROTATION:
[MenuItem ("Window/Transform Copier/Paste Rotation",false,)]
static void DoApplyRotationXYZ () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localRotation = rotation;
} [MenuItem ("Window/Transform Copier/Paste Rotation X",false,)]
static void DoApplyRotationX () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localRotation = Quaternion.Euler(rotation.eulerAngles.x, selection.localRotation.eulerAngles.y, selection.localRotation.eulerAngles.z);
} [MenuItem ("Window/Transform Copier/Paste Rotation Y",false,)]
static void DoApplyRotationY () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localRotation = Quaternion.Euler(selection.localRotation.eulerAngles.x, rotation.eulerAngles.y, selection.localRotation.eulerAngles.z);
} [MenuItem ("Window/Transform Copier/Paste Rotation Z",false,)]
static void DoApplyRotationZ () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localRotation = Quaternion.Euler(selection.localRotation.eulerAngles.x, selection.localRotation.eulerAngles.y, rotation.eulerAngles.z);
} // PASTE SCALE:
[MenuItem ("Window/Transform Copier/Paste Scale",false,)]
static void DoApplyScaleXYZ () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localScale = scale;
} [MenuItem ("Window/Transform Copier/Paste Scale X",false,)]
static void DoApplyScaleX () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localScale = new Vector3(scale.x, selection.localScale.y, selection.localScale.z);
} [MenuItem ("Window/Transform Copier/Paste Scale Y",false,)]
static void DoApplyScaleY () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localScale = new Vector3(selection.localScale.x, scale.y, selection.localScale.z);
} [MenuItem ("Window/Transform Copier/Paste Scale Z",false,)]
static void DoApplyScaleZ () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localScale = new Vector3(selection.localScale.x, selection.localScale.y, scale.z);
} // CHANGE LOCAL ROTATION :
[MenuItem ("Window/Transform Copier/localRotation.x + 90",false,)]
static void localRotateX90 () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localRotation = selection.localRotation*Quaternion.Euler(90f,0f,0f);
} [MenuItem ("Window/Transform Copier/localRotation.y + 90",false,)]
static void localRotateY90 () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localRotation = selection.localRotation*Quaternion.Euler(0f,90f,0f);
} [MenuItem ("Window/Transform Copier/localRotation.z + 90",false,)]
static void localRotateZ90 () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localRotation = selection.localRotation*Quaternion.Euler(0f,0f,90f);
} // SWAP:
[MenuItem ("Window/Transform Copier/Swap Y and Z Scale", false, )]
static void SwapYZScale () {
Transform[] selections = Selection.transforms;
foreach (Transform selection in selections) selection.localScale = new Vector3 (selection.localScale.x,selection.localScale.z,selection.localScale.y);
}
}

CopyTransform的更多相关文章

随机推荐

  1. 【转】腾讯移动品质中心TMQ [腾讯 TMQ] 测试管理平台大比拼

    简介 测试管理平台是贯穿测试整个生命周期的工具集合,它主要解决的是测试过程中团队协作的问题,比如缺陷管理.用例管理.测试任务管理等. 目前市面上比较流行的测试管理工具有QC. Mantis. BugZ ...

  2. [kafka] 005_kafka_Java_API

    1.生产者Producer 1)添加依赖 <dependency> <groupId>org.apache.kafka</groupId> <artifact ...

  3. 多线程系列四:AQS-AbstractQueuedSynchronizer

    什么是AbstractQueuedSynchronizer?为什么我们要分析它?  AQS:抽象队列同步器,原理是:当多个线程去获取锁的时候,如果获取锁失败了,当前线程就会被打包成一个node节点放入 ...

  4. unity提高----------射线使用【unity3d 怎样获得当前鼠标点击的对象】

    unity3d 怎样获得当前鼠标点击的对象 最佳答案   var ray = Camera.main.ScreenPointToRay (Input.mousePosition);var hit : ...

  5. sqlite学习笔记1:编译数据库

    首先说下我使用的是Linux环境 一 下载源代码 官网下载:点这里 二 编译 1 解压 下载完毕之后通常会在当前用户的"下载"文件夹中,首先cd到下载文件夹,然后创建一个文件件.用 ...

  6. ASP.NET MVC Castle Windsor 教程

    一.[转]ASP.NET MVC中使用Castle Windsor 二.[转]Castle Windsor之组件注册 平常用Inject比较多,今天接触到了Castle Windsor.本篇就来体验其 ...

  7. A:LinkedList实现了List接口; B: AbstractSet实现了Set接口; C: HashSet继承自AbstractSet基类; D: WeakMap继承自 AbstractMap

    List,Set,Map在java.util包下都是接口 List有两个实现类:ArrayList和LinkedListSet有两个实现类:HashSet和LinkedHashSetAbstractS ...

  8. linux环境下获取真实的ip地址

    package inas.test; import java.net.Inet6Address; import java.net.InetAddress; import java.net.Networ ...

  9. 下拉刷新XListView的简单分析

    依照这篇博文里的思路分析和理解的 先要理解Scroller,看过的博文: http://ipjmc.iteye.com/blog/1615828 http://blog.csdn.net/wangji ...

  10. Array.prototype.removeBeginWithVal(删除数组内以某值开头的字符串对象)

    Array扩展方法: //author: Kenmu //created time: 2015-03-16 //function: 删除数组内以某值开头的字符串对象 Array.prototype.r ...