I am creating a prefab from scratch using the EditorUtility functions, however I cannot seem to remove the prefab from the Hierarchy without removing it from the Project as well.
Any Suggestions?
I am creating a prefab from scratch using the EditorUtility functions, however I cannot seem to remove the prefab from the Hierarchy without removing it from the Project as well.
Any Suggestions?
In your project panel, have you done Create->Prefab and then dragged the object from the hierarchy to there? You should then be able to delete the prefab from the scene hierarchy but still have it available in the project. (Unless I misread what you got going on)
this is my prefab creation code. at the end you can destroy Selection.activeObject to delete it from the scene.
using UnityEngine;
using UnityEditor;
public class SelectionToPrefab
{
[MenuItem("Tools/create prefab from sellection %1")]
public static void Something()
{
if (Selection.activeObject != null)
{
Object o = EditorUtility.CreateEmptyPrefab("assets/" + Selection.activeObject.name + "Pb.prefab");
if (o != null)
{
EditorUtility.ReplacePrefab(Selection.activeGameObject, o);
}
}
}
}
why don’t you ask these questions in unity answers?[/code]