#How "heavy" are event calls? General advice

1 messages · Page 1 of 1 (latest)

celest totem
#

When doing states of something, should I have checks within built events or outside?
For example, using:
public void OnPointerEnter(PointerEventData eventData)
Should I have a check in there like if(someStateCheck != true){ //don't continue the function}
or, should I have it elsewhere and customize something similar to OnPointerEnter that doesn't fire unless the check is valid.

Basically - how heavy are events that might constantly check a condition? If I have a grid game where during selection, the tile has an OnPointerEvent (so that I can select units on the grid) - but when the state of play changes to watching units move, act, etc... I don't want that event to consider the pointer being over it, right? Should I turn off the Physics Raycaster on the camera in this case during the action phase? Does it matter?

full cypress
#

Is this more of a ff tactics/xcom grid game or like age of empires type thinng

#

If it’s the former shouldn’t be heavy enough to be concerned

celest totem
#

ff tactics/xcom I guess

#

Okay, thanks - just curious then, what would be your approach if it was the latter?

#

In terms of how much you'd leverage the built-in Unity event system

#

Nvm, thank you!

ornate shard
#

if you have like, 100000 events, maybe that's an issue, but that's just because it's 100000, not because they're events

#

don't worry about perf unless a) you start having perf issues, b) you are working in the millions of iterations, or c) you are working with extremely limited hardware, like an arduino or an NES

celest totem
ornate shard
#

worry about it making sense first, if perf is an issue then worry about that

celest totem
#

Yeah okay thanks, I have a problem with getting stuck in that... I just need to take the good enough approach and continue. Appreciate it

ornate shard
#

but when the state of play changes to watching units move, act
i could totally see pausing and wanting to hover over units to see more info (or even in real time) - not recommending that as a feature exactly, but as an example of something you might want to add in the future

#

having them move doesn't fundamentally make them completely uninteractive UI-wise, does it

#

customize something similar to OnPointerEnter that doesn't fire unless the check is valid.
(to answer this question directly) the difference here ends up being that you don't have 1 extra stack frame. that's not going to matter in the overall picture

#

it's technically faster, but it's nanoseconds

celest totem
#

ah okay, that's a good point on the mechanic as well

ornate shard
celest totem
#

awesome - this definitely answers the question and for my needs I can move forward - I appreciate it

ornate shard
#

consider the M/G in the MHz/GHz of modern processors think

#

that's millions/billions

#

(tbf, it's not a very intuitive scale, not really your fault)