Leaderboard game not updating

Hi guys,

I’ve a strange behavior since I add in the code the entityDisplays List. The UI don’t update but it looks like the code is correct. Ive set some debug logs as show:

 case NetworkListEvent<LeaderBoardEntityState>.EventType.Add:
                if (!entityDisplays.Any(x => x.ClientId == changeEvent.Value.ClientId))
                {
                    LeaderBoardEntityDisplay leaderboardEntity = Instantiate(leaderBoardEntityPrefab, leaderBoardEntityHolder);
                    Debug.Log(changeEvent.Value.PlayerName);
                    leaderboardEntity.Initialise(
                        changeEvent.Value.ClientId,
                        changeEvent.Value.PlayerName,
                        changeEvent.Value.Coins);
                    entityDisplays.Add(leaderboardEntity);
                    Debug.Log(entityDisplays.Count);
                }
                break;

When the host and a player spwan I m able to see in the console their name and that the list count increase. In the UI I’ve only the Host player and nothing show up
What could be wrong here?

Thanks

Hi there,
We have some code that removes extra leaderboard entity instances based on race conditions where it might be spawned when it’s not needed. I know when I was working through the course, at some point I had a different result from Nathan where it was removing too many and so it wasn’t displaying properly. I suggest getting to the end of this section of the course, because Nathan does some cleanup in the last lecture in each section. If the issue persists then, just post back here and I will help you debug the issue.

Are the debug logs above not being run at all?

HI @Yitzchak_Cohen Thanks for your answer.

At this stage, both Debug Log are running and display in the console the playerName and List count value from 1 to 2. It’s like the UI don’t get the update and do nothing.
But if I disable

leaderboardEntity.Initialise(
                        changeEvent.Value.ClientId,
                        changeEvent.Value.PlayerName,
                        changeEvent.Value.Coins);

both entities are display with the default value. I’m trying to compare with The lecture’s project change but I don’t see differences :sweat_smile:
I will continue this section and come back to you at the end if it fixed the issue or not.

Thanks

1 Like

well. I ve rewrite some code, keeping the old one to compare. done some cleanup and now it works as expected. No idea what happens. But I’ve noticed sometimes with by saving a file and switching to unity, the updated file is not correctly compiled. Maybe a bug/issue with the macbook M1?
Any way thanks for your help

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms