Jump to content

Scene doesn't load: "Tree prefab at index 0 is missing."


migwellian

Recommended Posts

Hello, I have a scene that runs fine in the Unity Editor but crashes when I try to run a built version. I also get this same error when I try to load the scene from a Unity PlayMode test. As a workaround I can remove all the terrain scenes via the Terrain Loader Manager - then the scene loads fine with no error.

 

Unity 2021.3.10f1 with Gaia Pro 3.3.0-c5

The error and stack trace are:

 

Tree prefab at index 0 is missing.
UnityEngine.GameObject:.ctor (string,System.Type[])
GeNa.Core.GeNaRoadsMesh:IHBDMBNGDDL (string,GeNa.Core.GeNaRoadSegment,UnityEngine.Transform)
GeNa.Core.GeNaRoadsMesh:AEJPCGMCAPM (GeNa.Core.GeNaSpline)
GeNa.Core.GeNaRoadsMesh:Process (GeNa.Core.GeNaSpline,single,single,bool,single,bool,bool,bool,single)
GeNa.Core.GeNaRoadExtension:ProcessSpline (GeNa.Core.GeNaSpline) (at Assets/Procedural Worlds/GeNa/Scripts/Runtime/Extensions/GeNaRoadExtension.cs:402)
GeNa.Core.GeNaRoadExtension:Execute () (at Assets/Procedural Worlds/GeNa/Scripts/Runtime/Extensions/GeNaRoadExtension.cs:226)
GeNa.Core.GeNaSpline:UpdateSpline ()
GeNa.Core.GeNaSpline:Update ()
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

 

Link to comment
Share on other sites

A few things here. 
1. I was not sure what you meant by your message? 
- Are you unloading your scenes Via Terrain Loading Manager after adding them to the build settings and then make the build? 
If so this is the correct way to do so. You must unload the terrain scenes before making the build, also adding them to the build settings is also important. 

2. Looking at the stack trace here I am not seeing any issue other than a tree prefab. 
- However that would not make the build not run. 

3. What are you using for the player? 
- Are you using a custom player? If so did you use the Gaia Custom player and then attach your player and camera to that? 
You would need to do this in order for the Terrain loader to work properly as its a Gaia system. If you are using one of the Gaia Players than this also shouldnt matter. 
 

Link to comment
Share on other sites

Thanks for your reply, Bryan. Here are the answers your questions:

 

1.

Yes, I unloaded my scenes in the Terrain Loading Manager. When I click on "+ Terrains" there are 4 of them listed. If I click the "Remove Scene" button for all 4 of them, my PlayMode test passes and my build runs.

 

3.

Yes, I am using a custom player. My scene uses Cinemachine, and I was under the impression (perhaps wrongly?) that I therefore need to use a custom player. In the Gaia Player I have set the camera to be the "Main Camera" object, which has a "CinemachineBrain" component, and I have set the player to be my "Racer" object (it's a racing game) which has a Rigidbody and is the subject of my CinemachineVirtualCamera so it is always on screen.

 

I tried changing Gaia Player's Controller Type to "Flying Camera" and rerunning my PlayMode test and my build - they failed in the same way, however something appears to be setting the Controller Type back to "Custom" so I don't think I have actually verified if changing this fixes the problem.

 

2.

I will describe in more detail what happens when I run the Playmode test. Here is the code, it's very simple.

 

        [UnityTest]
        public IEnumerator YouCanLoadTheScene()
        {
            SceneManager.LoadScene("Demo Track");
            yield return null;
        }

Here is a description of what happens when I run the code:

 

  • Frame 1: Two scenes are loaded, "InitTestScene<number>" and "DontDestroyOnLoad"
  • Around frame 8: Scene "InitTestScene<number>" is unloaded, and scene "Demo Track" is loaded.
  • One frame later: Sub-scenes "Terrain_1_1_<timestamp>" and "Terrain_0_1<timestamp>" are loaded (but not the other two "Terrain_0_0_<timestamp>" and "Terrain_1_0_<timestamp>")
  • Then the test immediately crashes
  • After the test ends, there is only one scene loaded, "Terrain_0_0_<timestamp>". Scene "Demo Track" is not loaded.

 

I'm seeing a variety of different errors of the form `Tree prefab at index <n> is missing` with varying stack traces. The index `<n>` seems to correspond to the Terrain scene, e.g. typically the test attempts to load two of the Terrain scenes before it crashes so I get errors referring to `index 0` and `index 1`.

 

Tree prefab at index 0 is missing.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Gaia.GaiaSessionManager:GetWorldMinMax (single&,single&,bool,Gaia.Stamper) (at Assets/Procedural Worlds/Gaia/Scripts/SessionSystem/GaiaSessionManager.cs:473)
Gaia.Spawner:UpdateMinMaxHeight () (at Assets/Procedural Worlds/Gaia/Scripts/SpawningSystem/Spawner.cs:907)
Gaia.Spawner:OnEnable () (at Assets/Procedural Worlds/Gaia/Scripts/SpawningSystem/Spawner.cs:793)
Tree prefab at index 0 is missing.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Tree prefab at index 0 is missing.
UnityEngine.GameObject:.ctor (string,System.Type[])
GeNa.Core.GeNaRoadsMesh:IHBDMBNGDDL (string,GeNa.Core.GeNaRoadSegment,UnityEngine.Transform)
GeNa.Core.GeNaRoadsMesh:AEJPCGMCAPM (GeNa.Core.GeNaSpline)
GeNa.Core.GeNaRoadsMesh:Process (GeNa.Core.GeNaSpline,single,single,bool,single,bool,bool,bool,single)
GeNa.Core.GeNaRoadExtension:ProcessSpline (GeNa.Core.GeNaSpline) (at Assets/Procedural Worlds/GeNa/Scripts/Runtime/Extensions/GeNaRoadExtension.cs:402)
GeNa.Core.GeNaRoadExtension:Execute () (at Assets/Procedural Worlds/GeNa/Scripts/Runtime/Extensions/GeNaRoadExtension.cs:226)
GeNa.Core.GeNaSpline:UpdateSpline ()
GeNa.Core.GeNaSpline:Update ()
Tree prefab at index 0 is missing.
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
Tree prefab at index 0 is missing.
UnityEditor.EditorApplication:Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange)
Tree prefab at index 0 is missing.
UnityEditor.SceneManagement.EditorSceneManager:OpenScene (string,UnityEditor.SceneManagement.OpenSceneMode)
Gaia.TerrainScene:LoadScene (UnityEngine.SceneManagement.Scene,bool&,Gaia.LoadState&,bool) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:457)
Gaia.TerrainScene:UpdateLoadState (System.Collections.Generic.List`1<UnityEngine.GameObject>,Gaia.LoadState&,bool&,bool&,bool) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:303)
Gaia.TerrainScene:AddRegularReference (UnityEngine.GameObject) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:144)
Gaia.TerrainLoaderManager:UpdateTerrainLoadState (Gaia.BoundsDouble,Gaia.BoundsDouble,UnityEngine.GameObject,single,single,single,single) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainLoaderManager.cs:1043)
Gaia.TerrainLoader:UpdateTerrains () (at Assets/Procedural Worlds/Gaia/Gaia Pro/Scripts/MultiTerrainSystem/TerrainLoader.cs:190)
Gaia.TerrainLoader:Awake () (at Assets/Procedural Worlds/Gaia/Gaia Pro/Scripts/MultiTerrainSystem/TerrainLoader.cs:133)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

 

Link to comment
Share on other sites

Hi @migwellian, I know this error for about the tree prefab from a different context - usually this can be seen when a terrain is being used that was made in a different project originally and the tree prefabs that were used to populate the terrain with trees are not present in the target project. 
When you load the terrain scenes manually by opening the scene file from the "Terrain Scenes" directory in your session folder, do you see the same error appearing as well? Can you also please check on the terrains in these scenes if there is anything unusual going on in the tree tab on the terrain inspector? If there is a missing prefab listed, it would need to be removed or the prefab would need to be brought back into the project again.


image.png

What I currently assume is going on is that there is such a missing prefab in one of the scenes, and there is an error thrown whenever Gaia or GeNa tries to access the terrain data for that terrain during runtime, and this leads to the crash.

  • Like 1
Link to comment
Share on other sites

Thank you so much Peter! You've solved the issue and taught me something too. Apologies, I am new to both Gaia and terrains so I didn't know how to do the basic things like inspect the trees. They were missing just as you described, and once I removed the references to them, the errors disappeared. I can now successfully run tests that call `SceneManager.LoadScene`.

 

Thanks also to Bryan for helping out earlier.

 

Unfortunately I still have another issue because the built version isn't working properly - I just get a black screen. I will open a separate ticket for that once I have more information. It's tricky because there's no error or other clues in the log file.

Link to comment
Share on other sites

Glad that issue was solved. 
As far as the black screen goes, this can be a number of things so its hard to tell. 

You may want to make a developer build and see if you can get the console to pop up in the build. 
If that doesnt work then you would want to check the player log file, and you can see some weird error at the bottom. 
If that doesnt help you would want to deactivate every game object and start to reactivate everything more and more until you find the issue. 

Link to comment
Share on other sites

Thanks! I have dug into it hard the past few days. Developer build, console logs, Profiler and Memory Profiler in the Unity Editor. I haven't turned up any useful clues yet but I do have a workaround, which is to put the terrains directly into my scene rather than loading them as additive scenes via Gaia's Terrain Loader Manager.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...