- Home /
Can no longer create pre-fab
Hi all,
I don't know why, but I can no longer create prefabs on my project. Whenever I click on Assets > Create > Prefab, the console displays this message:
NullReferenceException: Object reference not set to an instance of an object UnityEditor.BaseProjectWindow.BeginPreimportedName Editing (Int32 instanceID, EndAction endAction, System.String pathName, UnityEngine.Texture2D icon, System.String resourceFile) UnityEditor.ProjectWindowUtil.StartNameEditingIfPr ojectWindowExists (Int32 instanceID, EndAction endAction, System.String pathName, UnityEngine.Texture2D icon, System.String resourceFile) UnityEditor.ProjectWindowUtil.CreatePrefab ()
Has this happened to anyone? How can I solve it? Note that at one point, I deleted my project's cache folder. This might have broken something. Is there any way to repair it?
What about from the Project window? (Create > Prefab) Do you get the same error? Deleting project folders wouldn't be the cause I$$anonymous$$O, you may possibly need to re-install Unity.
Creating from Project window does the same thing. Also, I ported the project to another computer in which I also have Unity and it did the same, so I think it's something broken in the project itself, not the installation.
What about try creating a new project, then in an empty scene try to create prefab. If it is a new project (i.e. no cache/library) with a new blank scene, then there is nothing in the project to affect Unity. This should be a good test.
Unless you have some custom Editor doing something then I would try submitting a Bug Report, and probably re-installing Unity. (I'll upvote your question to see if one of the pro's can help) =]
Hi again,
If using a new project, Prefabs work as expected.
Answer by tutiplain1 · Jul 24, 2012 at 10:34 PM
Solved. I exported all my assetts into a unity package, created a new project, and reimported the package. Prefabs now work correctly!
so bizzare, really couldn't see how that was happening, even if you have successfully imported and are using the same scripts and assets! $$anonymous$$ust have been something in the cache/library files, but how, what??
A bit late but if it ever happens again, before exporting/importing, test by deleting the whole Library folder (not just cache).
Really happy you got it working, thumb up for not giving up =]
Thanks, and thanks for your suggestions. I think I have a backup of the "damaged" project folder. I will try deleting the Library folder on that and report back.
Your answer
Follow this Question
Related Questions
Object reference to set to instance on an instantiated object 1 Answer
Instantiate: Create Connection 1 Answer
The public variables of a prefab dont reset when I open the game. 1 Answer
how to CORRECTLY load all assets (using Resources.LoadAll) 1 Answer
Problem when setting variable in an instantiated gameobject 0 Answers