欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Unity2018编辑模式通过GameObject查找prefab unityPrefabUtilityGetPrefabAssetPathOfNearestInstanceRoot

程序员文章站 2022-05-17 15:48:05
...
var prefabObj = PrefabUtility.GetCorrespondingObjectFromSource(childTrans.gameObject);
if (!prefabObj)
{
    continue;
}

string prefabPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(prefabObj);
if (string.IsNullOrEmpty(prefabPath))
{
    Debug.Log("cant find prefabPath");
    continue;
}