Almost got this working, this is a hackish way of trying to break a prefab connection in one click. Can anyone see why it wouldn’t work? Thanks
@MenuItem ("DW3D_FX/BreakPrefab")
static function BreakPrefab () {
var objs = Selection.gameObjects;
for (var go : GameObject in objs)
{
go.AddComponent(AudioSource);
Debug.Log ("Prefab Connection is now broken. Object is now independent");
DestroyImmediate(go.GetComponent(AudioSource));
}
}
@MenuItem ("DW3D_FX/BreakPrefab")
static function BreakPrefab () {
var objs = Selection.gameObjects;
for (var go : GameObject in objs)
{
go.AddComponent(tempScript);
}
}
But doing a test build to webby I get this error:
BCE0064: No attribute with the name ‘MenuItem’ or ‘MenuItemAttribute’ was found (attribute names are case insensitive).
This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add “using UnityEditor;” at the beginning of the script.