using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine; 
 | 
using UnityEditor; 
 | 
  
 | 
public static class ApplyHelper 
 | 
{ 
 | 
  
 | 
    [MenuItem("Edit/ApplyHelper %q", false, 1)] 
 | 
    static void ApplySelected() 
 | 
    { 
 | 
        var selectedsGameobject = Selection.gameObjects; 
 | 
        for (int i = 0; i < selectedsGameobject.Length; i++) 
 | 
        { 
 | 
            var obj = selectedsGameobject[i]; 
 | 
            var root = PrefabUtility.FindPrefabRoot(obj); 
 | 
            if (PrefabUtility.GetPrefabType(root) == PrefabType.PrefabInstance) 
 | 
            { 
 | 
                var parentObject = PrefabUtility.GetPrefabParent(root); 
 | 
                PrefabUtility.ReplacePrefab(root, parentObject, ReplacePrefabOptions.ConnectToPrefab); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        AssetDatabase.SaveAssets(); 
 | 
        AssetDatabase.Refresh(); 
 | 
    } 
 | 
  
 | 
} 
 |