#OnPostprocessBuild

1 messages · Page 1 of 1 (latest)

warm cedar
#

Can i use OnPostprocessBuild to process subscenes before building game?

#

I want to create my version of "Static Batching" for ecs

#

I really need it for modular buildings but i also want to use 500x500 subscenes on editor for authoring and convert it to 80x80 subscenes on build for better streaming

terse kayak
warm cedar
summer scaffold
#

but yeah sections are still good for this

#

they actually generate an AABB as well

#

however this isn't generated from memory when subscene is open

warm cedar
#

Is there any example for it?

#

I don`t even need while it is open. This looks really promising

terse kayak
#

you could just hash the x,y coordinates of your section and put it into the section value for example

summer scaffold
#

i'd just create gameobject sections

#

add the scene section component

#

and let the level designers break it up themselves however they want

#

each section will have a SceneSectionData

warm cedar
#

This is really good way of doing. I will use meters because my game is topdown

summer scaffold
#

which will have a BoundingVolume

#

generated from the meshes in the subscene

warm cedar
#

Is it auto updated?

#

the bounding box

summer scaffold
#

anytime you bake it's calculated

warm cedar
#

With this i can stream really big worlds

#

How do you stream it? at runtime

summer scaffold
#
    public struct SceneSectionData : IComponentData
    {
        /// <summary>
        /// Represents the unique GUID to identify the scene where the section is.
        /// </summary>
        public Hash128          SceneGUID;
        /// <summary>
        /// Represents the scene section index inside the scene.
        /// </summary>
        public int              SubSectionIndex;
        /// <summary>
        /// Represents the file size for the compressed section.
        /// </summary>
        public int              FileSize;
        /// <summary>
        /// Represents the number of Unity Objects referenced in the section.
        /// </summary>
        public int              ObjectReferenceCount;
        /// <summary>
        /// Represents the scene section bounding volume.
        /// </summary>
        public MinMaxAABB       BoundingVolume;
        internal Codec          Codec;
        internal int            DecompressedFileSize;
        internal RuntimeBlobHeaderRef BlobHeader;
    }```

`        public MinMaxAABB       BoundingVolume;`
#

i just load/unload subscenes

#

as the character comes in range

#

unload distance being a bit larger than load

#

to stop flickering etc

warm cedar
#

I see

#

Loading the subscene will load all sections?

#

only 0 right?

warm cedar
#

It is really strange, i have a scene with a lot of sections but this is empty

#

this subscene has a lot sections. More than 400

#

It is not showing here too

#

Maybe the problem is i`m assigning sections on a baking system?

#

Maybe this is the problem

#

it is the problem but idk how to fix yet. Do i need to always use small subscenes?

warm cedar
#

I got streaming working except for physics colliders. Somehow they go to wrong scene section.

                     .Query<LocalToWorld>()
                     .WithNone<CullingGroupComponent>()
                     .WithEntityAccess()
                     .WithOptions(EntityQueryOptions.Default))
        {
            var section = state.EntityManager.GetSharedComponent<SceneSection>(entity);

            if (StreamableScenes.Contains(section.SceneGUID))
            {
                int sectionIndex = MathUtils.szudzikPair((int)(math.round(ltw.Position.x / 80.0f)), (int)(math.round(ltw.Position.z / 80.0f)));

                if (sectionIndex <= 0)
                {
                    sectionIndex = sectionIndex - 1;
                }

                if (sectionIndex == 57)
                {
                
                }```

This is an example code of my baking system but it adds the renderer on section 3 and the physics colliders on section 57
#
    public static int szudzikPair(int x, int y)
    {
        int xx = x >= 0 ? x * 2 : x * -2 - 1;
        int yy = y >= 0 ? y * 2 : y * -2 - 1;

        return (xx >= yy) ? (xx * xx + xx + yy) : (yy * yy + xx);
    }
#

this is somehow on section 57

#

Can i filter it idk? move it to section 0 or something like this?

#

Or run this baking system before physics?