I want to have a custom menu item that creates a prefab for me. I tried doing this:
public class ImportAnimations : ScriptableWizard {
public Texture2D spritesheet;
public TextAsset spritedoc;
[MenuItem("Custom/Animations/ImportAnimations...")]
static void CreateWizard()
{
ScriptableWizard.DisplayWizard("Import Animations from:", typeof(ImportAnimations), "Import");
}
void OnWizardCreate()
{
GameObject go = new GameObject("TestAsset");
go.AddComponent(typeof(Animation));
go.SetActiveRecursively(false);
AssetDatabase.CreateAsset(go, "Assets/Prefabs/TestAsset.prefab");
GameObject.DestroyImmediate(go);
}
}
This creates the prefab, but it also keeps the GameObject in the scene. If I delete the GameObject the prefab will be empty (the Animation component is lost). If I delete the prefab from my project folder before deleting the GameObject in my scene Unity crashes. (reported bug) Is there another way to do this? Or is it just a bug? (using b7)