美文网首页
unity3D 判断Selection 选中的是否是Projec

unity3D 判断Selection 选中的是否是Projec

作者: UnityAsk | 来源:发表于2017-08-12 15:22 被阅读81次

    方法一:

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

    相关文章

      网友评论

          本文标题:unity3D 判断Selection 选中的是否是Projec

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