chore: optimize avatar names#833
Conversation
|
After the CI passes:
|
MeasurementsStill WIP. Benchmark in Unity Editor Standing StillMoving around |
MeasurementsBenchmark in Build |
Remove old AvatarName implementation
D4rWiNSS
left a comment
There was a problem hiding this comment.
LGTM! Some suggestions were added.
I think we should somehow ( maybe each X seconds ) change the names of the avatars when we are moving and we are above the max numbers of avatar names.
Imagine that you are in a concert and we are moving on to where our friends are. So we are moving from the entrance to the other part of the concert. You will want to see the avatar names of the nears players and not the first 200 avatars names.
Take this into account for the future!
|
|
||
| private void OnEnable() | ||
| { | ||
| canvasRect.GetComponent<Canvas>().sortingOrder = -2; |
There was a problem hiding this comment.
We should move this to somewhere common to the project like Settings, So in the future, if we need to change the sorting order in other parts of the project we have some visibility about the current canvas ordering. What do you think?
There was a problem hiding this comment.
Not sure about that, this is an specific sorting set for the AvatarNames. I dont think any other part of the project should be aware of what sorting order does the AvatarNames canvas have.
|
|
||
| public void DestroyUIElements() | ||
| { | ||
| Object.Destroy(background.gameObject); |
There was a problem hiding this comment.
Shouldn't we use GameObject.Destroy instead of Object in unity objects?
There was a problem hiding this comment.
Destroy is a member of Object. GameObject has it because inherits Object.
There was a problem hiding this comment.
Yes, but Unity uses an implementation where he passes the time to be destroyed, not sure if it makes any change though
There was a problem hiding this comment.
I mean, GameObject doesn't override Destroy. It's the same call
| protected override IEnumerator TearDown() | ||
| { | ||
| if (hudView != null) | ||
| Object.Destroy(hudView.gameObject); |
There was a problem hiding this comment.
Same here, GameObject instead of Object?
sandrade-dcl
left a comment
There was a problem hiding this comment.
Reviewed and tested, LGTM! I only left some suggestions/doubts. Good work.
| private MinimapMetadata.MinimapUserInfo avatarUserInfo = new MinimapMetadata.MinimapUserInfo(); | ||
| bool initializedPosition = false; | ||
|
|
||
| private PlayerStatus playerStatus = null; |
There was a problem hiding this comment.
In order to avoid confussions, maybe a better name for this playerStatus would be avatarStatus? As this data is managed by any avatar in the world and not only by our avatar... What do you think?
There was a problem hiding this comment.
It contains information about the player, such as name and the voice chat status along the position. I think it would be more confussing to have it named avatarStatus.
| if (playerStatus != null) | ||
| playerStatus.worldPosition = entity.gameObject.transform.position; |
There was a problem hiding this comment.
Couldn't we do this position update in the OnEntityTransformChanged() instead of do it in each frame?
There was a problem hiding this comment.
The entity transform position is not where the Avatar is rendered, we interpolate the target position to make it smoothly. We actually have to do it each frame or the AvatarName will be lagging behind. A nice "side-effect" is that the minimap is now smoother as well (since it can use this data).
@Suduck Yeah I was thinking the same but as I started benchmarking I noticed we can drastically increase the number of Avatar Names in screen (thanks the the batching of the UI parts). It's a nice suggestion but it wouldn't have much use until we can comfortably have more than 200 users on screen. |
Fixes #825
To optimize the Avatar Names we are going to:
Approach:
AvatarNames.DataStoreto keep aPlayerStatuscollection.Minimaprefactoring to use the newPlayerStatuscollection.AvatarNameHUDimplementation.It must be tested with this Kernel:
decentraland/explorer#2503
Test Link: https://play.decentraland.zone/branch/chore/avatar-names-optimization/index.html?renderer=urn:decentraland:off-chain:renderer-artifacts:chore/optimize-avatar-names