ソースコード
using UnityEditor; public static class UnityObjectExt { public static bool IsNotPrefab( this UnityEngine.Object self ) { var type = PrefabUtility.GetPrefabAssetType( self ); return type == PrefabAssetType.NotAPrefab; } }
使用例
Debug.Log( gameObject.IsNotPrefab() );
プレハブもしくはプレハブのインスタンスの場合 false になります
この拡張メソッドはエディタ拡張でのみ使用できます