PopPeerView.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using SC.XR.Unity;
  2. using System;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.EventSystems;
  6. public class PopPeerView : RemoteSingleton<PopPeerView>
  7. {
  8. public Transform list;
  9. public List<GameObject> v3 = new List<GameObject>();
  10. public List<PeerBigView> bigList = new List<PeerBigView>();
  11. public GameObject view;
  12. public int viewCount=0;
  13. public static Action CloseView;
  14. public override void Awake()
  15. {
  16. base.Awake();
  17. view.SetActive(false);
  18. }
  19. public override void initShow()
  20. {
  21. base.initShow();
  22. view.SetActive(false);
  23. viewCount = 0;
  24. }
  25. public void addBigView(CustomPeer cp)
  26. {
  27. if(viewCount<=0)
  28. {
  29. viewCount = 0;
  30. }
  31. Debug.Log("增加:1===>"+ viewCount);
  32. GameObject bigView = GameObject.Instantiate(view);
  33. bigView.SetActive(true);
  34. bigView.transform.parent = view.transform.parent;
  35. bigView.transform.position = v3[viewCount].transform.position;
  36. bigView.transform.eulerAngles = v3[viewCount].transform.eulerAngles;
  37. PeerBigView pbv = bigView.GetComponent<PeerBigView>();
  38. pbv.cPeer = cp;
  39. pbv.initView();
  40. bigList.Add(pbv);
  41. viewCount ++;
  42. }
  43. public void closeView(PeerBigView view)
  44. {
  45. if (!view.isMove)
  46. viewCount--;
  47. Destroy(view.gameObject);
  48. Debug.Log("删除:1===>" + viewCount);
  49. }
  50. public void ViewOut(PeerBigView view)
  51. {
  52. viewCount--;
  53. Debug.Log("删除:1===>" + viewCount);
  54. }
  55. public void DestoryAll()
  56. {
  57. if (bigList.Count > 0)
  58. {
  59. for (int i = bigList.Count - 1; i >= 0; i--)
  60. {
  61. Destroy(bigList[i].gameObject);
  62. bigList.Remove(bigList[i]);
  63. }
  64. bigList.Clear();
  65. }
  66. }
  67. }