AvatarUtil.cs 555 B

12345678910111213141516171819202122232425
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. namespace UI.Hall
  5. {
  6. public class AvatarUtil
  7. {
  8. public static void DisplayAvatar(Image image, string avatarIdString)
  9. {
  10. var avatarId = 1;
  11. try
  12. {
  13. avatarId = int.Parse(avatarIdString);
  14. }
  15. catch (Exception e)
  16. {
  17. Debug.LogError(e);
  18. }
  19. var s = Resources.Load<Sprite>("Image/Avatar/" + avatarId.ToString("D3"));
  20. image.sprite = s;
  21. }
  22. }
  23. }