【UnityEditor】使用Selection在Project面板自动选中文件、文件夹

选中文件夹

选中文件

 示例:

    //选中文件夹
    //OpenPrefabPath("Assets");
    //选中文件
    //OpenPrefabPath("Assets/Cube.prefab");

    void OpenPrefabPath(string selectPath)
    {
        //加载想要选中的文件/文件夹
        Object obj = UnityEditor.AssetDatabase.LoadAssetAtPath<Object>(selectPath);
        //在Project面板标记高亮显示
        UnityEditor.EditorGUIUtility.PingObject(obj);
        //在Project面板自动选中,并在Inspector面板显示详情
        UnityEditor.Selection.activeObject = obj;
    }

猜你喜欢

转载自blog.csdn.net/qq_39108767/article/details/120183948