GameObjectがPrefabかどうか(SceneにInstantiateされていないGameObjectであるか)を判定します。
public static bool IsPrefab(this GameObject gameObject)
{
return !gameObject.scene.IsValid();
}
GameObjectがPrefabの場合、GameObject.scene.IsValid()はfalseになります。
UnityEngine.SceneManagement.Sceneはstructなので、IsValidを使用して判定します。
↧