随风逐叶 随风逐叶
首页
  • Quick Reference (opens new window)
  • EgretEngine开发者文档 (opens new window)
  • TinaX框架
  • SSH教程
  • VSCode插件开发
关于
  • 分类
  • 标签
  • 归档

rontian

从事游戏开发10多年的老菜鸟一枚!
首页
  • Quick Reference (opens new window)
  • EgretEngine开发者文档 (opens new window)
  • TinaX框架
  • SSH教程
  • VSCode插件开发
关于
  • 分类
  • 标签
  • 归档
  • Unity

    • Unity3D UGUI生成并播放序列帧动画prefab
    • Unity3D UGUI 粒子特效层级与缩放
    • UGUI 新手引导镂空代码
    • Unity复制GameObject路径到剪切板
    • Unity模型变灰Shader
    • unity中判断iphone设备型号的方法
    • Unity Time详解
  • 游戏开发
  • Unity
rontian
2023-10-16

Unity复制GameObject路径到剪切板

/// <summary>
/// 添加Hierarychy中的右键菜单
/// 说明:"GameObject/"下[priority小于等于49]的按钮会出现在Hierarychy的右键菜单中
/// </summary>
public class HierarchyEditor
{
    private static readonly TextEditor CopyTool = new TextEditor();
    /// <summary>
    /// 将一个GameObject在Hierarchy中的完整路径拷贝的剪切板
    /// </summary>
    [MenuItem("GameObject/Copy Path", priority = 20)]
    static void CopyTransPath()
    {
        Transform trans = Selection.activeTransform;
        if(null == trans) return;
        CopyTool.text = GetTransPath(trans);
        CopyTool.SelectAll();
        CopyTool.Copy();
    }

    /// <summary>
    /// 获得GameObject在Hierarchy中的完整路径
    /// </summary>
    public static string GetTransPath(Transform trans)
    {
        if (null == trans) return string.Empty;
        if (null == trans.parent) return trans.name;
        return GetTransPath(trans.parent) + "/" + trans.name;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

转载来源:http://www.jianshu.com/p/19dac8d94f29 (opens new window)

上次更新: 2023/10/16, 17:53:06 访问次数: 0
UGUI 新手引导镂空代码
Unity模型变灰Shader

← UGUI 新手引导镂空代码 Unity模型变灰Shader→

最近更新
01
一些Shell常用的功能写法整理
10-20
02
删除git仓库submodule的步骤
10-20
03
django基本命令
10-16
更多文章>
Copyright © 2017-2025 随风逐叶
沪ICP备18008791号-1 | 沪公网安备31011502401077号

网站访问总次数: 0次
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式