// 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. Linux操作_常用命令操作练习

    1,新键一个用户,该用户名为自己姓名首字母缩写+学号最后2位组成(如王东,学号最后2位为18,则该用户名为wd18),为该用户设置密码,并将其加到users组:将该用户的相关信息更改(要求:Name为 ...

  2. Python——errno

    该模块实现标准的 errno 系统符号,每一个对应于一个整数,名称和描述借鉴了 linux/include/errno.h.  errno.errorcode 包含从 errno 到底层系统中错误名称 ...

  3. 浅谈android中只使用一个TextView实现高仿京东,淘宝各种倒计时

    今天给大家带来的是只使用一个TextView实现一个高仿京东.淘宝.唯品会等各种电商APP的活动倒计时.近期公司一直加班也没来得及时间去整理,今天难得歇息想把这个分享给大家.只求共同学习,以及自己兴许 ...

  4. Kubeadm 安装

    version 1.7.0 已解决: echo "1" > /proc/sys/net/bridge/bridge-nf-call-iptables error: faile ...

  5. C# listview控件右击导出数据到txt文本

    private void 导出成功点击ToolStripMenuItem_Click(object sender, EventArgs e) { ) { MessageBox.Show("列 ...

  6. 强大!HTML5 3D美女图片旋转实现教程

    又到周末,来弄点HTML5的特效玩玩,今天要折腾的是HTML5 3D图片特效,图片在垂直方向上被分割成一条条小矩形,在图片上拖动鼠标即可让每一个小矩形旋转,从而让图片形成3D立体的效果,来看看效果图: ...

  7. shell特殊符号cut命令 sort_wc_uniq命令 tee_tr_split命令 shell特殊符号

    shell特殊符号cut命令 特殊符号 *  通配符,任意个任意字符 ? 任意一个字符 # 注释字符 \  脱义字符 c=\$a\$b echo  $c | 管道符 cat  1.txt |less ...

  8. linux nginx配置多个网站

    1.建立wwwroot(/home/wwwrooot) 另建立一个wwwroot/test/index.html(网站目录) 2.建立vhost文件(/usr/local/nginx/conf/vho ...

  9. Vue slot简单理解

    情形一: 子组件定义了具名的slot,父组件使用具名的slot,slot显示顺序为子组件定义slot的顺序 子组件: Vue.component('child',{ template:`<div ...

  10. 1 最简单的hello world

    preface 今天我开始自学flask了,由此记录学习中的点点滴滴. 有问题请联系我(Mr.Leo 18500777133@sina.cn) include: 简介flask hello world ...