HomeView_Tip.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class HomeView_Tip : MonoBehaviour
  5. {
  6. [SerializeField] List<GameObject> tipObjList;
  7. [SerializeField] GameObject connectObj;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. }
  12. public void setHomeTip(int index) {
  13. if (index == 0) {
  14. GameObject _IconConnect = GameObject.Find("IconConnect");
  15. //Debug.Log("IconConnect:" + _IconConnect.transform.position);
  16. ////position x,127.5f,left 30
  17. //Camera UICamera = null;
  18. //Canvas canvas = GameObject.Find("ViewMgr").GetComponent<Canvas>();
  19. //if (canvas.renderMode == RenderMode.ScreenSpaceCamera
  20. // || canvas.renderMode == RenderMode.WorldSpace)
  21. //{
  22. // UICamera = canvas.worldCamera;
  23. //}
  24. //else if (canvas.renderMode == RenderMode.ScreenSpaceOverlay)
  25. //{
  26. // UICamera = null;
  27. //}
  28. //Vector3 centerPos = RectTransformUtility.WorldToScreenPoint(UICamera, _IconConnect.transform.position);
  29. //Debug.Log("IconConnect:" + centerPos + " == " + _IconConnect.transform.position);
  30. //Vector3 globalMousePos;
  31. ////UI屏幕坐标转换为世界坐标
  32. //RectTransformUtility.ScreenPointToWorldPointInRectangle(connectObj.GetComponent<RectTransform>(), centerPos, UICamera, out globalMousePos);
  33. //Debug.Log("IconConnect:" + _IconConnect.GetComponent<RectTransform>().rect);
  34. //Rect rect = _IconConnect.GetComponent<RectTransform>().rect;
  35. connectObj.transform.position = new Vector3(_IconConnect.transform.position.x, _IconConnect.transform.position.y, 0);
  36. }
  37. for (int i = 0; i < tipObjList.Count; i++)
  38. {
  39. tipObjList[i].SetActive(index == i);
  40. }
  41. }
  42. public void OnClick_Back()
  43. {
  44. //AudioMgr.ins.PlayBtn();
  45. ViewManager2.HideView(ViewManager2.Path_HomeViewTip);
  46. }
  47. }