Keyboard Shortcut to Apply Prefab

“Save game objects in prefabs and apply them”. Easy task, eh? But it’s becoming tiresome when you have more than 10 of them. Luckily¬†someone made the answer in Unity Forum:

using UnityEngine;
using UnityEditor;
 
public class ApplyPrefabChanges : MonoBehaviour
{
    [MenuItem("Tools/Apply Prefab Changes %#p")]
    static public void applyPrefabChanges()
    {
        var obj = Selection.activeGameObject;
        if(obj!=null)
        {
            var prefab_root = PrefabUtility.FindPrefabRoot(obj);
            var prefab_src = PrefabUtility.GetPrefabParent(prefab_root);
            if(prefab_src!=null)
            {
                PrefabUtility.ReplacePrefab(prefab_root, prefab_src,  ReplacePrefabOptions.ConnectToPrefab);
                Debug.Log("Updating prefab : "+AssetDatabase.GetAssetPath(prefab_src));
            }
            else
            {
                Debug.Log("Selected has no prefab");
            }
        }
        else
        {
            Debug.Log("Nothing selected");
        }
    }
}

There’s also some useful tools from Trinket Studios which compiled some other great keyboar shortcut stuff in this github repo. Check them out!