zoukankan      html  css  js  c++  java
  • Unity---在Hierarchy视图中将选中的对象的层级目录复制到剪切板

    using UnityEditor;
    using UnityEngine;
    
    public class ObjPathCopyTool : ScriptableObject
    {
        [MenuItem("Custom/Copy path %Q")]    //自定义快捷键
        static void CopyPath()
        {
            Object[] objs = Selection.objects;
            if (objs.Length < 1)
                return;
    
            GameObject obj = objs[0] as GameObject;
            if (!obj)
                return;
    
            string path = obj.name;
            Transform parent = obj.transform.parent;
            while (parent)
            {
                path = string.Format("{0}/{1}", parent.name, path);
                parent = parent.parent;
            }
    
            Debug.Log(path);
            CopyString(path);
        }
    
        //将字符串赋值到剪切板
        static void CopyString(string str)
        {
            TextEditor te = new TextEditor();
            te.text = str;
            te.SelectAll();
            te.Copy();
        }
    
    }

    Unity自定义快捷:

    % - CTRL on Windows / CMD on OSX
    ‘# - Shift’
    & -Alt
    LEFT/RIGHT/UP/DOWN - Arrow keys
    F1 … F2 - F keys
    HOME,END,PGUP,PGDN
    字母键 - _ + 字母(如:_g代表按键)
    还可以几种合并

  • 相关阅读:
    E
    C
    航空母舰-03
    航空母舰-02
    航空母舰-01
    新概念4-30
    html
    翁凯-编程学习方法
    机器学习Ng-02
    民法-钟秀勇-导学
  • 原文地址:https://www.cnblogs.com/luguoshuai/p/10689553.html
Copyright © 2011-2022 走看看