unity3D 判断Selection 选中的是否是Projec

2017-08-12  本文已影响81人  UnityAsk

方法一:

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".

上一篇下一篇

猜你喜欢

热点阅读