Search Unity

Making Leaderboard

Discussion in 'General Discussion' started by WirealTalha, Aug 10, 2019.

  1. WirealTalha

    WirealTalha

    Joined:
    Jul 19, 2018
    Posts:
    142
    Hi I would like to know how to decide on layout of a leaderboard. In the leaderboard I would like to add, Profile pircture and score and picture for country of the player.

    and total players in leaderboard are 100.
    what should i do? cache all 100 images on start of scene? what the best move? anyone who's implemented it, kindly point me in the right direction that uses best memory efficient technique.
     
  2. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    207
    User profile images are pretty small so can be stored on disk
    You can save an object that links the image with the userID (you can get that from Social API)
    So only download images of users not currently on disk and just read from disk for the userId you have already encountered previously.

    You may also with to add a counter to see how many times a users image is loaded and delete data from disk who hasnt been loaded for some time.
     
  3. WirealTalha

    WirealTalha

    Joined:
    Jul 19, 2018
    Posts:
    142
    Thankyou for replying. Sorry i forgot to add we are using playfab backend services.we are caching the leaderboard at the start of game and rest is easy we just have problem with memory optimization. How do we efficiently implement the 100 images bit.
     
  4. Aseemy

    Aseemy

    Joined:
    Aug 22, 2015
    Posts:
    207
    i would do it like this, anyone more experienced please comment on my method.
    i would create a single texture for all the images by combining their bytes[] values. this way 100 separate drawcalls wont be needed (am i correct in assuming that 100 different textures will take 100 draw calls if they are not batched?). Then i would store the location (row/columns pixels) of individual image in an object, the class should have the following fields, userid, lastUsedOn, locationInTexture.

    So if the image is 128x128 then you can have 256 images in one 2048 texture. Once all 256 images have been filled (or at regular intervals) you may overwrite/remove the images which have not been used in a while.
     
  5. WirealTalha

    WirealTalha

    Joined:
    Jul 19, 2018
    Posts:
    142
    hmm this is interesting. For security purposes we dont want to save other users profile pictures on clients device. From what i heard i dont think facebook even allows it. (i could be wron, ill look into it). How expensive is the Draw call function anyways? i was thinking we have 100 urls for player's profile picture and what if we create textures on the go?
    Texture2D texture = new Texture2D(128, 128). Whats the game with this texture2d?