#SubScene missing in build

1 messages · Page 1 of 1 (latest)

rare marten
#

Hello everyone. I have problems building my project. It does work, but the subscene is not available. I tried building with the platform package and also with the normal workflow but both didn't work. I am on version 1.0.0-pre.65. Can anyone help me?

frank sentinel
#

Is your subscene in a scene, and is this scene (not the subscene) included in the scene list in the build window?

proud charm
#

in other words: for subscene to get baked it must be part of included in a build scene.

rare marten
#

Yes the subscene is in the scene that I build. I tried also building both scenes don't know if this helps or not

proud charm
#

share details how exactly it is not available

rare marten
#

Yes I can share tomorrow some pictures and the exact log. Sorry this was a late night idea to post this question on the Discord

dusk orbit
#

and what platform you're building for

rare marten
#

From Windows to windows

dusk orbit
#

yep, that should work. i do personally recommend updating to 1.0.8, but i'm not specifically aware of an issue fixed about subscenes not appearing in builds (except for webgl)

#

but yeah, wait for tomorrow when you can paste the exact message

rare marten
#

This is the exception:

#

NullReferenceException: Object reference not set to an instance of an object
at Unity.Entities.EntityQueryImpl.GetSingleton[T] () [0x00053] in .\Library\PackageCache\com.unity.entities@1.0.0-pre.65\Unity.Entities\Iterators\EntityQuery.cs:1419
at Unity.Entities.EntityQuery.GetSingleton[T] () [0x00000] in .\Library\PackageCache\com.unity.entities@1.0.0-pre.65\Unity.Entities\Iterators\EntityQuery.cs:2693
at Spawner.Start () [0x0004e] in C:\Users\denni\Unity\2D\FactoryMain\Factory\Assets\Scripts\Buildings\Spawner.cs:27

(Filename: ./Library/PackageCache/com.unity.entities@1.0.0-pre.65/Unity.Entities/Iterators/EntityQuery.cs Line: 1419)

NullReferenceException: Object reference not set to an instance of an object
at Unity.Collections.LowLevel.Unsafe.UnsafeUtility.WriteArrayElement[T] (System.Void* destination, System.Int32 index, T value) [0x00001] in C:\build\output\unity\unity\Runtime\Export\Unsafe\UnsafeUtilityPatched.cs:60
at Unity.Entities.DynamicBuffer1[T].set_Item (System.Int32 index, T value) [0x00001] in .\Library\PackageCache\com.unity.entities@1.0.0-pre.65\Unity.Entities\Iterators\DynamicBuffer.cs:193 at Unity.Entities.DynamicBuffer1[T].Add (T elem) [0x00012] in .\Library\PackageCache\com.unity.entities@1.0.0-pre.65\Unity.Entities\Iterators\DynamicBuffer.cs:347
at Spawner.SpawnTrashcan (Unity.Mathematics.int2 pos) [0x0005a] in C:\Users\denni\Unity\2D\FactoryMain\Factory\Assets\Scripts\Buildings\Spawner.cs:187
at TestGenerator.SpawnIronBlueprint (System.Int32 x, System.Int32 y) [0x000b5] in C:\Users\denni\Unity\2D\FactoryMain\Factory\Assets\Scripts\TestGenerator.cs:42
at TestGenerator.Start () [0x00021] in C:\Users\denni\Unity\2D\FactoryMain\Factory\Assets\Scripts\TestGenerator.cs:16

#

And this is my build config:

frank sentinel
#

I suspect you don't have a require for update dependency -edit-seems like you're trying to do this from a monobehaviour start which I doubt will ever work in a build

#

And that you've done all your testing in editor with your subscene open

#

Subscenes load async

#

The world will tick multiple frames before the Entities load from it

#

If you have an open subscene in editor its entities always exist but this is not how it works in builds

rare marten
#

Oh well this is a good guess. I have required for update in my systems but not in my MonoBehaviour. Can you do this there as well?

frank sentinel
#

No. But your entities won't exist in start

rare marten
#

Ok then I will try a workaround for this. Thank you very much

frank sentinel
#

(I have a personal rule never to access entity world from game objects because life cycle management is way too much of a problem)

#

(I only drive gameobject behaviour from systems, but never the other way)

#

If you do need to do it this way you'll have to query until entity exists or something

rare marten
#

I spawn some entities from pressing a button. What would the best approach for this?

frank sentinel
#

I do this all in systems

rare marten
#

How do you connect the button to the system?

frank sentinel
#

Well I use uitoolkit which requires no gameobjects

#

But there are many ways you can link your ugui gameobjects

#

As simple as some statics

#

As complex as messaging systems

rare marten
#

Ok thank you. Then I will have a look at this uitoolkit

reef crescent
#

I'm facing this issue too right now :/

#

I got all the null exceptions cleared up by adding RequireForUpdate<SpawnerComponent>(); but it never actually makes it to OnUpdate. Like the component never ends up loading in the build.