#Is it feasible to mix Entities into a Monobehaviour project (damage text)?

1 messages · Page 1 of 1 (latest)

spice roost
#

We have a (monobehaviour based) game in which we have hundreds of Damage Text objects spawning in the world. Im having trouble optimizing these damage numbers which are essentially TMProText objects animating in world space. I have jobified this already for some gains, but there is seemingly no way around a rather large canvas cost (even when using non UGUI version) and the cost of .SetText() which is doing way too much work for our simple case (numbers up to 6-8 digits).

I had the idea of importing Entities into the project, for this purpose. A Text system that can spawn and animate hundreds of quads (entity baked from a prefab) with an SDF shader material, which would do a simple UV lookup to find the glyph for the digit in question, but I dont know whether I can mix Entities Graphics with "normal" graphics. Would this work? Hybrid renderer instancing would also give some gains here I suspect.

vale pumice
#

I believe this is okay, but depending on your experience with entities this may cost you some time.

Many people here will advise against mixing entities and monobehaviours, but I suppose here you will have a monobehaviour adding/removing data in the ECS world at runtime, without trying to get data back, so I think it's fine.

That being said, I suspect you could already get a big improvement by doing exactly what you describe without entities, by manipulating a vertex buffer directly. This may be easier.

spice roost
#

I do have some experience with Entities already, but I have never mixed them. I suppose you are correct, that I could do this without entities. The allure is the ability to instantiate 500 quads at neglible cost, compared to monobehaviours

#

And yes, this would be totally 1-way. The texts do not interact with anything in the world

polar mauve
spice roost
#

Well, legacy reasons mostly. The original texts were written by the games prototype designer, so they are set up as individual TMPro objects that start their own coroutines which animate them. Ive moved that bit into jobs. Im not sure what you mean by doing everything in a shader? They are using the built in SDF shader for text rendering, but you mean something else?

#

Here is an example of how it looks. Notable features we use from TMPro are gradient colors and Underlay

polar mauve
#

Well what I do in my game, is I have a SystemBase that scans the world for where it needs to put damage numbers, and single threadedly tells the shader graph where to put those damage numbers, and the shader graph handles the animations/colours/w/e else.
I can have literally millions of singular numbers on my screen this way, but it's still single threaded because you need to talk with shader graph, aka managed components. I'm not at home so can't show it.
I'll try to search for the example a bit.

spice roost
#

Thats an interesting approach, can you get the same sort of quality as seen above?

#

Sure, theres no rush here. I'd like to hear more about this solution whenever you are at your machine

polar mauve
spice roost
#

Well, we usually have SOME overlap but not more than whats seen above

#

Also a lot of other stuff going on, so if z-depth is incorrect for a few of them, no one will ever notice

polar mauve
#

Well I'll look at it this evening. Can't find the example anymore sadly, but I should be able to with the demo project I made for the damage numbers.

spice roost
#

Thanks a bunch

regal fable
#

I am the "people" who would advise against it, because entities on their own != performance in any way. Neither they even have anything for text drawing at all.
Meanwhile trying to use two of them, with game objects at rule - is similar to trying to use different engine for some feature.

#

from what you described - can be easily done with VFX graph btw

spice roost
#

@regal fable Thanks for your input. I will have to look more into VFX graph. (perhaps the poster above meant vfx graph instead of shader graph?) There is some API to send events to a graph, but they looked limited to me. Like 1 event per frame, and no way to pass in arrays. Perhaps I need to re investigate that route

#

Also, drawing and animating text in VFX graph, need to look into that because I cant find much online about it

polar mauve
spice roost
#

No worries, I had a feeling 🙂

polar mauve
#

And yeah the search was a pain for me too when I did it, there is only 1 guy on github that had a good example of it. Just forgot the name of the repo.

#

But you can just feed a font to the VFX graph and spawn text that way.

#

Anyhow, in an hour or so I'm home, I'll show some stuff then.

spice roost
#

Thanks again

vale pumice
polar mauve
#

And you can probably optimize is way more then I did if you would want, but this was enough at first.

spice roost
#

But how do you pass in positions for each one at runtime? I get that its possible to spawn them at static points but my enemies are moving 🙂

polar mauve
spice roost
#

Nice, that should help me along. Thank you so much for sharing

polar mauve
spice roost
#

I wish he had put the non-ecs version on Github as well, but I guess the magic sauce is in how you write to the vfx graph

#

Right

#

Okay, so I just gotta study that screenshot of the graph, he didnt include the TextParticleController script 🙂

polar mauve
#

Or new 🤔

#

That has the script you want

spice roost
#

Ooohh there it is! Thank you