unity script detect if in prefab edition mode

Code Example - unity script detect if in prefab edition mode

                
                        using UnityEditor;
using UnityEditor.Experimental.SceneManagement;

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