unity3d:复制选中物体transform信息到剪切板

2023-08-24 14:30:02 浏览数 (2)

代码语言:javascript复制
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class SaveTransInfo : EditorWindow
{

    [MenuItem("SaveTransInfo/SaveOriInfoTo #`")]
    static void SaveOriInfoTo()
    {
        GameObject obj = Selection.activeGameObject;
        Transform trans = obj.transform;
        string angles = trans.localEulerAngles.x   ","   trans.localEulerAngles.y   ","   trans.localEulerAngles.z;
        string str = trans.localPosition.x   ","   trans.localPosition.y   ","   trans.localPosition.z   ";"   angles;

        TextEditor te = new TextEditor();
        te.content = new GUIContent(str);
        te.SelectAll();
        te.Copy();
    }
}

配合策划改表

0 人点赞