unity编辑器中打印选中物体所有子物体的坐标并复制到剪贴板
2018-01-31 16:41
731 查看
从前公司有个同事提了个标题中描述的需求,顺手做了下,分享出来也许其他人也能用上。
代码很简单,看注释即可
代码很简单,看注释即可
public class LogPosition : EditorWindow { //最终输出的数据 static string logtext; //增加菜单栏选项 [MenuItem("LOGPOSITION/LOG")] public static void OpenLoadLevel(){ //重置数据 logtext = ""; //获取编辑器中当前选中的物体 GameObject obj = Selection.activeGameObject; //如果没有选择任何物体,弹出提示并退出 if(obj == null){ EditorUtility.DisplayDialog("ERROR", "No select obj!!", "ENTRY"); return; } //遍历所有子物体,并记录数据 ForeachObjAndSave(obj); Debug.Log(logtext); //复制到剪贴板 TextEditor editor = new TextEditor(); editor.content = new GUIContent(logtext); editor.SelectAll(); editor.Copy(); } //遍历所有子物体 static void ForeachObjAndSave(GameObject obj){ foreach (Transform child in obj.transform) { logtext+= (child.localPosition.x + "," + child.localPosition.y + "," + child.localPosition.z + "\n"); } } }
相关文章推荐
- Vuforia在Unity中屏幕坐标转世界坐标,并使用lineRender画线,手指画线,选中物体并拖拽
- 【Unity】子物体坐标问题
- C# 把TextBox中选中的内容复制到剪贴板
- Unity 对选中物体实现描边效果(方法3:结合方法1的外轮廓渲染、方法2的选择网格)
- [Unity小技巧]复制组件数值粘贴至另一个物体的组件
- unity之复制文本到剪贴板
- Unity Editor 复制内容到剪贴板
- Unity 对选中物体实现描边效果(方法1:指定layer的外轮廓渲染)
- Unity的Scene场景选中物体Hierarchy窗口无法锁定选中的物体的问题
- Unity 获取所有子物体,不包括孙物体
- unity 场景编辑器中 获取点击的物体
- Xshell选中的同时把内容复制到剪贴板(还可以设置设置文本分隔符)
- 解决虚拟机中文本选中后自动被复制到剪贴板的问题
- [Unity小技巧]选中多个物体批处理
- Adobe Acrobat pro 用选择工具选中,出现 “正在复制到剪贴板”的解决办法。
- Unity中UGUI中获取鼠标点击位置以及UI物体的屏幕坐标
- Unity获得当前选中的物体(大量按钮的监听事件可用)
- 【Unity&精灵】如何通过已知道的坐标获取物体&动态生成墙壁
- unity编辑器拓展五——将场景中物体以Obj格式导入max
- Unity使用Android系统剪贴板复制&粘贴