PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot

切换到手册
public static string GetPrefabAssetPathOfNearestInstanceRoot (Object instanceComponentOrGameObject);

参数

instanceComponentOrGameObject用于获取其资源路径的预制件实例中的对象。

返回

string 资源路径。

描述

返回指定对象所属的最近预制件实例根的资源路径。

该方法将在变换层级视图中查找游戏对象或其最近祖先,后者是任何预制件实例的根游戏对象,并返回该预制件资源的资源路径。

对于预制件变体,返回的是变体,而不是其基础。

如果对象不是预制件实例的一部分,则该方法返回 null。