UserManager.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using DG.Tweening;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using XRTool.Util;
  8. public class UserManager :Singleton<UserManager>
  9. {
  10. public AccountData NowChoose = null;
  11. public GameObject NowChooseGo = null;
  12. public void removeUser()
  13. {
  14. NowChooseGo.SetActive(false);
  15. NowChoose = null;
  16. }
  17. public void setNowUser(AccountData ad,Transform t,Texture tex)
  18. {
  19. NowChoose = ad;
  20. if (Instance.NowChooseGo==null)
  21. Instance.NowChooseGo = GameObject.Instantiate(WindowsManager.Instance.GetPrefab(WindowConfig.windowType.Login,"UserIcon")).gameObject;
  22. Instance.NowChooseGo.GetComponent<RawImage>().texture = tex;
  23. Instance.NowChooseGo.transform.localScale = Vector3.one;
  24. Instance.NowChooseGo.transform.localEulerAngles = Vector3.zero;
  25. Instance.NowChooseGo.transform.position = t.position;
  26. }
  27. public void MoveIcon(Vector3 v3,Transform t,Action callback)
  28. {
  29. if (Instance!=null&&Instance.NowChooseGo != null)
  30. {
  31. Instance.NowChooseGo.transform.SetParent(t);
  32. Instance.NowChooseGo.transform.localEulerAngles = Vector3.zero;
  33. Instance.NowChooseGo.transform.localScale = Vector3.one;
  34. Instance.NowChooseGo.transform.DOLocalMove(v3, 0.5f).OnComplete(() => {
  35. callback.Invoke();
  36. });
  37. Instance.NowChooseGo.transform.GetComponent<RectTransform>().DOSizeDelta(t.GetComponent<RectTransform>().sizeDelta, 0.5f).OnComplete(() => {
  38. });
  39. }
  40. }
  41. }