#True convert runtime of Prefabs/GameObject into Entity without Bake v1.0.16 for Standalone build

1 messages · Page 1 of 1 (latest)

edgy flume
#

Hey

Iv been learning DOTS and ECS API for the last few weeks.
Using v1.0.16 with unity v2022 LTS, I cant find a method to convert prefabs gameobjects on run time for a standalone version.

EntitySceneReferences and EntityPrefabReference both are un-usable for a standalone build for 2 reasons I found and tested:

  1. converting directly gameobject or using sceneAsset are unityEditor only, standalone version (aka compiled game) cant access and compile it using those.
  2. from testing using GUID (aka hash128) (for both scene loading and prefab), on editor all work but on standalone the GUID wasn't leading anywhere and basically the code cried about nothing being there. I guess its because the scene/prefab wasn't part of the scene in the run.

Im really out of ideas at this point.

things to consider:

  1. I dont know which prefabs are going to be used at start or set them predate - meaning I cant use bake.
  2. I cant add their component manually as they are complex and each prefab has it own story.
  3. adding the component as object doesn't help to solve the problem.

Really hope anyone can share more info about it, iv looked everywhere to find a good solution and none came up.

granite parcel
#

what's the purpose of it anyway?

edgy flume
#

I have random "events" that use their own prefabs to execute the event content, like storm of asteroids event - depends the level/world it needs different prefabs to load.

what options I have on table?
I remember seeing on v0.50 there was a convertor API for doing those - at least from what I saw googling around the forum.

I though about making each event a sub-scene but again as wrote first msg - cant load them in a standalone (from my tests).

P.S
what does it require to build it from scratch? I know C# pretty good but never went so deep into the API or into making an addon/plugin for the editor.

edgy flume
#

True convert runtime of Prefabs/GameObject into Entity without Bake v1.0.16 for Standalone build

granite parcel
#

and load them as needed

#

oooh

#

I see what you mean now

#

basically, for things to be included in build you need to bake them in EntityPrefabReference field

#

whether it's dynamic buffer or just component

#

so then you'll have expected load same as in editor

edgy flume
#

is it possible to have unloaded sub-scene ref in code loaded into one that is already baked and running for standalone version?
I know its possible with editor as I tested it - but not standalone without pre-baking it.
I thought maybe every event could have their own one sub-scene - with all prefabs and rules and those can be loaded/unloaded as needed.

also i see on 1.2.0 they added:
Serialization support for UnityObjectRef<> which works with the build system. This means an unmanaged IComponentData can reference Unity assets and it works in a build or from a loaded SubScene the same as with Managed components.

When saying build system- they refer compiling a standalone?

BTW
I find it very strange to have multiply ways of converting prefabs/scene on the fly only having it restrict to the editor.
Im sure there is a reason related to the editor it self and they way it runs - as I had to overcome errors that wont showup during a test on editor, but do on a standalone.
But then why not work the way around to have an API or a way to-be able todo that also on a standalone ?
And if there is no plan to implement a way, why making this gap between editor-run and the standalone version from the beginning ?

edgy flume
#

expanding on the BTW:
https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/streaming-loading-scenes.html

on the doc it says:

...  The build process doesn't detect scenes referenced by GUIDs, and their entity scene files will be missing from builds. For this reason, you should avoid using GUIDs to identify scenes. ... ```
I guess builds refer to standalone version - as those files were missing in my test using GUID

but then later on the doc it says:

You can call SceneSystem.UnloadScene with a scene's GUID or an EntitySceneReference instead of the scene meta entity, but this has the following disadvantages:

The method has to search for the meta entity that represents the scene that matches the GUID, which might affect performance.
If multiple instances of the same scene are loaded, then unloading by GUID only unloads one instance.

it super confuse me hahaha.
Does it mean I can use GUID on a standalone of the sub-scene exist (not loaded) on the main scene?
or to what extand I can use ```SceneSystem.LoadSceneAsync``` on a standalone version
granite parcel
#

prefabs/scenes referenced by those will be baked during build

#

serialization during build specifically detects every value baked with those

edgy flume
#

cant bake them as random events are selected and executed during the gameplay.

still im confused regarding the EntitySceneReference
does it work on a standalone only with baking?

for EntityPrefabReference it seems to be even "worse" as I cant make a standalone version with GUID

the sub scene idea presented is not possible?

granite parcel
#

but only those structs get recognized by build system to be picked up