美文网首页Unity编辑器开发分享Unity教程合集
Unity获取物体在项目工程的目录

Unity获取物体在项目工程的目录

作者: 循环渐进123456 | 来源:发表于2017-08-21 09:12 被阅读18次

转载:http://blog.csdn.net/liqiangeastsun/article/details/42123551

using UnityEngine;
using System;
using UnityEditor;

// 该脚本放在 Editor 文件夹下
//选中一个对象,然后右键,在弹出的菜单栏中点击 "DebugDatabase" 打印被选择的物体在项目中的路径名
// 如 在项目中选择一个 ABC.txt 文件,打印结果为 
//"Assets/StreamingAssets/RoleParameter/ABC.txt"
public class Test : Editor
{
    [MenuItem("Assets/DebugDatabase")]
    static void BuildScenes()
    {
        string selectPath = AssetDatabase.GetAssetOrScenePath(Selection.activeObject);
        Debug.Log(selectPath);
    }
}

相关文章

网友评论

    本文标题:Unity获取物体在项目工程的目录

    本文链接:https://www.haomeiwen.com/subject/vkfcdxtx.html