Tree prefab at index 0 is missing. Please Help!

Hello,

Really hoping someone can help. I’m having a build error where a tree prefab is missing:


Tree prefab at index 0 is missing.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

Tree prefab at index 1 is missing.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

Tree prefab at index 2 is missing.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

Tree prefab at index 3 is missing.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

Build completed with a result of ‘Failed’ in 24 seconds (24098 ms)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun () (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindow.cs:123)

UnityEditor.BuildPlayerWindow+BuildMethodException: 10 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002be] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:190
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun () (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindow.cs:123)


This has happened to me again recently and I had to start a whole new project because I couldn’t build. They game will Play but not build.

There are no missing trees in the terrain trees inspector and I even tried deleting all the trees from the scene and from the tree palette and tried deleting the whole terrain itself and even the tree prefabs and I still get the error. I only have 1 terrain and have only created 1 terrain. I even tried deleting the Library/Cache folder…

Running 2020.3.26f1 in HDRP.

So frustrating. Does anyone have an idea?

Thank you!

I had this error, and decided to type “terrain” in my scene hierarchy search bar to see if there were any terrains I didn’t know about. As it turns out, there were. And precisely at the index numbers the console mentioned, there were missing trees in those terrains. Removing those trees from those hidden terrains, stopped the console messages for me.

If you have Terrain prefabs in your assets folder, you might want to check those too.

I have not taken a build yet, because our project is massive and build times are long. But I’m typing this here in-case it helps you.

For those having this issue and using mapmagic:

When working with MapMagic, it is recommended to periodically ‘unpin’ and then ‘re-pin’ your terrain. This practice is particularly useful, as using the ‘generate’ function in MapMagic might not always produce the expected results. By regularly unpinning and repinning your terrain, you can effectively address and resolve most issues that may arise during your work with MapMagic.