// 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. MapReduce 图解流程超详细解答(1)-【map阶段】

    转自:http://www.open-open.com/lib/view/open1453097241308.html 在MapReduce中,一个YARN  应用被称作一个job, MapReduc ...

  2. 解决jar包乱码 in 创新实训 智能自然语言交流系统

    今天用eclipse的fat jar插件,打成jar包.之后再命令行运行...程序的功能是切分大的文件...结果是切分的很正确,但是里面的中文都变成了乱码. 最开始以为是在Eclipse中的编码设置有 ...

  3. Cisco无线控制器配置Radius

    使用Cisco无线控制器管理AP,配置Radius服务器,用于企业加密wifi的认证. 结合上一篇文档进行操作: http://www.cnblogs.com/helloworldtoyou/p/80 ...

  4. Android hide Navigation bar

    最近一个app需要隐藏Navigation bar导航栏. 参考文档 http://blog.csdn.net/zwlove5280/article/details/52823128 http://j ...

  5. JDBC Statements, PreparedStatement和CallableStatement语句

    当获得了与数据库的连接后,就可以与数据库进行交互了. JDBC Statement,CallableStatement和PreparedStatement接口定义了可用于发送SQL或PL/SQL命令, ...

  6. Ubuntu 14.04 安装 DevStack与遇到的的问题记录

    本文总结Ubuntu 14.04下部署DevStack的过程以及一些可能遇到的问题. 一.安装 以下的操作最好在普通用户下进行,至少在git clone devstack的时候使用普通用户,这样可以避 ...

  7. Lemon OA第2篇:功能解析方法

    Lemon OA,整个系统功能也算是比较丰富,OA的很多功能都能看见影子,虽然做得不是很强大 接触Lemon OA,起源于Activiti的学习热情,既然这样,研究Lemon OA的目标有3: 1.L ...

  8. 纯CSS3实现牛奶般剔透的3D按钮特效

    今天我们要来看一款非常特别的纯CSS3 3D按钮,它的外观酷似纯白剔透的牛奶,点击按钮的时候还会出现一种很柔和的弹力效果.按钮按下时,按钮会轻轻的弹动一下,非常逼真.本文我们在观赏演示的同时,也将源代 ...

  9. EayRadius 于 2013-7-19 进行体验度更新,增加用户体验度

    EasyRadius于2013-7-19进行更新,此次更新并没有更新通讯接口,通讯接口将统一更新,包括对其他路由的支持 下面我将主要更新的地方向大家描述一下 如果你有疑问或者建议,可以致电137799 ...

  10. linux中service的问题

    1.描述问题 2.解决方案 systemctl stop firewalld systemctl mask firewalld Then, install the iptables-services ...