using UnityEditor; /// <summary> /// UnityEngine.Object 型の拡張メソッドを管理するクラス /// </summary> public static partial class UnityEngineObjectExt { /// <summary> /// 指定されたオブジェクトがプレハブではない場合 true を返します /// </summary> public static bool IsNotPrefab( this UnityEngine.Object self ) { var type = PrefabUtility.GetPrefabType( self ); return type == PrefabType.None || type == PrefabType.MissingPrefabInstance || type == PrefabType.DisconnectedPrefabInstance ; } }
if ( gameObject.IsNotPrefab() )
{
...
}