using UnityEditor; using UnityEditor.Experimental.SceneManagement; if (PrefabStageUtility.GetCurrentPrefabStage() == null) {} // If null it mean you are not in prefab editing mode