Skip to content

Instantly share code, notes, and snippets.

@WikkidEdd
Created September 6, 2018 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WikkidEdd/998b59c395717da2dbef4581774f7bff to your computer and use it in GitHub Desktop.
Save WikkidEdd/998b59c395717da2dbef4581774f7bff to your computer and use it in GitHub Desktop.
Fully break prefab connection so it can't be reconnected. Just put into an Editor folder and you'll find the menu option "GameObject/Break Prefab Instance Permanently"
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class BreakPrefabPermanently
{
[MenuItem("GameObject/Break Prefab Instance Permanently", priority=100)]
static void BreakPrefab()
{
GameObject prefab = PrefabUtility.CreatePrefab("Assets/BreakPrefab.prefab", Selection.activeGameObject);
PrefabUtility.ReplacePrefab(Selection.activeGameObject, prefab, ReplacePrefabOptions.ConnectToPrefab);
AssetDatabase.Refresh();
AssetDatabase.DeleteAsset("Assets/BreakPrefab.prefab");
PrefabUtility.DisconnectPrefabInstance(Selection.activeGameObject);
}
[MenuItem("GameObject/Break Prefab Instance Permanently", validate = true)]
static bool BreakPrefabValidate()
{
return Selection.activeGameObject;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment