以下の内容はhttps://baba-s.hatenablog.com/entry/2020/03/04/090000より取得しました。


【Unity】ゲームオブジェクトがどのプレハブから生成されたインスタンスかエディタ拡張で確認する方法

概要

using UnityEditor;
using UnityEngine;

public class Example
{
    [MenuItem( "Tools/Hoge" )]
    private static void Hoge()
    {
        var go   = GameObject.Find( "Cube" );
        var path = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot( go );

        Debug.Log( path );
    }
}

PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot を使用することで
ゲームオブジェクトがどのプレハブから生成されたインスタンスか確認できます

f:id:baba_s:20200213162817p:plain

例えば上記のような状況で前述のエディタ拡張を実行すると
Assets/Cube.prefab という文字列を取得できます




以上の内容はhttps://baba-s.hatenablog.com/entry/2020/03/04/090000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14