unity3D 判断Selection 选中的是否是Project视窗中的object

方法一:

EditorUtility.IsPersistent(Object target)

方法二:

AssetDatabase.GetAssetPath(Selection.activeObject)
如果是hierarchy中的则会返回空
如果是Project中的则会返回资源路径

public static string GetAssetPath(int instanceID);
public static string GetAssetPath([Object]

Returns
string The asset path name, or null, or an empty string if the asset does not exist.

Description
Returns the path name relative to the project folder where the asset is stored.

All paths are relative to the project folder, for example: "Assets/MyTextures/hello.png".

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容