UGUIDOTS icon indicating copy to clipboard operation
UGUIDOTS copied to clipboard

Subscene Support

Open psuong opened this issue 4 years ago • 8 comments

With runtime conversion possibly not the ideal workflow, it would be a good idea for me to support subscenes very soon. One of the issues I've been running into is adding a component object such as a texture or a material to an entity in a subscene - as the entity when loaded from the subscene does not have the said material.

psuong avatar Mar 20 '20 17:03 psuong

Putting this on hold for now until I figure out how to add referenced based objects on scene conversion.

psuong avatar Apr 03 '20 00:04 psuong

Alright, with subscenes working with managed component datas, I think it would be best to start adding support to generate the vertices in subscenes. This might work really well with a procedural renderer instead of building meshes in runtime (issue #60). Runtime support will still be added in case the entire hierarchy needs to be rebuilt.

psuong avatar Sep 10 '20 13:09 psuong

image Subscenes work but looks like the canvas data isn't exactly baked nicely. So as a workaround - I'll bake information to a scriptable object which I'll read during conversion to generate the correct vertices.

That said, Unity doesn't like me attempting to override the TransformSystem without write groups (which I have no idea how to do in a GameObjectConversionSystem). So as an alternative I will likely write up a minimal transformation system without using rotations (I don't expect myself or users to really be rotating vertices (technically you can defer this to a shader).

psuong avatar Sep 14 '20 14:09 psuong

image Okay baked data into a scriptable object that is read on conversion. The results are quite nice when loading in a subscene! In place transform data is in - but supplement transform systems will need to be in. This means that we don't store matrix information anymore, but just the minimal amount of data to create the matrix (in this case just translation (float2) and scale (float2)).

Additionally, some clean up will be required on the canvas entity.

psuong avatar Sep 15 '20 12:09 psuong

image Text is now supported again!

psuong avatar Sep 20 '20 18:09 psuong

image Also some additional quality of life features. Names will be applied directly to the entity on the initial frame - this is an Editor only system and currently lives in UGUIDOTS.Conversions.Diagnostic assembly definition (also you will need to enable UGUIDOTS_DEBUG in your scripting defines - this is only meant to be an Editor only tool!)

Without it - the EntityDebugger will look like so:

image

Lastly, since static functions and properties which return a texture and default material don't play nicely with inactive subscenes - the SharedTexture and SharedMaterial component data contain some Get methods which will assign the texture if the value is null. Currently - I assume an unassigned material/image has the intention of using Unity's default.

psuong avatar Sep 20 '20 18:09 psuong

So this is pretty much a redesign of the entire framework system. For StretchImageSystem ideally if the aspect ratio is not the same, I need to rebuild stretched images.

Currently, I'm thinking that the Update loop should have the step where all of the indices are rebuilt in the buffer. And in late update, the mesh should be rebuilt to handle a different aspect ratio.

Rebuilding Images

For most intensive purposes images just need to rebuild in their current indices since the # of vertices aren't intended to change.

Rebuilding Text

I think this is where it becomes really tricky. For most intensive purposes my workflow with handling text is knowing which text is dynamic and which is static. Static text like labels wil llikely have a typical TextMeshProUGUI component without any other additional components. But, if I wanted to manipulate text, just adding a custom MonoBehaviour which references TextMeshProUGUI would mean that text is intended to be manipulated. to emulate this kind of workflow - batching all the text to be the last kind of meshes in the batch would make sense.

psuong avatar Oct 04 '20 21:10 psuong

screen-res-working

Text and image scaling is working much more nicely now.

psuong avatar Oct 25 '20 02:10 psuong