InfraredScreenPositioningView.cs 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using LineUI;
  5. using UnityEngine.UI;
  6. using System.Linq;
  7. using ZIM;
  8. using o0;
  9. using Color = UnityEngine.Color;
  10. using InfraredManager;
  11. using Org.BouncyCastle.Asn1.Crmf;
  12. using ZIM.Unity;
  13. using o0.Project;
  14. public class LinePosition
  15. {
  16. public int index;
  17. public List<Vector3> pos;
  18. }
  19. public class InfraredScreenPositioningView : JCUnityLib.ViewBase
  20. {
  21. [SerializeField]
  22. RectTransform canvasRectTransform;
  23. [SerializeField]
  24. RectTransform draggableParent;
  25. [SerializeField]
  26. GameObject mask;
  27. [SerializeField]
  28. GameObject cameraLight;
  29. [SerializeField]
  30. RectTransform pointsParent;
  31. [SerializeField]
  32. RectTransform pos1;
  33. [SerializeField]
  34. RectTransform pos2;
  35. [SerializeField]
  36. RectTransform pos3;
  37. [SerializeField]
  38. RectTransform pos4;
  39. //画线时候的点偏移量
  40. float offset = 10;
  41. [SerializeField]
  42. Line line;
  43. List<LinePosition> oldLinePosition;
  44. Vector3 beginPos;
  45. Vector3 endPos;
  46. //相机感光部分
  47. [SerializeField]
  48. Slider slider;
  49. [SerializeField]
  50. RawImage rawImage;
  51. [SerializeField]
  52. RectTransform crosshair;
  53. [SerializeField]
  54. GameObject textTip1;
  55. [SerializeField]
  56. GameObject textTip2;
  57. [SerializeField]
  58. Button btnAuto;
  59. [SerializeField]
  60. Button btnHandMovement;
  61. [SerializeField]
  62. BtnRecordInfrared btnRecordInfrared;
  63. bool bAuto = true;
  64. [SerializeField] Color normalColor = Color.white;
  65. [SerializeField] Color highlightedColor = Color.green;
  66. [SerializeField] Color normalTextColor = Color.black;
  67. [SerializeField] Color highlightedTextColor = Color.white;
  68. [SerializeField] TextAutoLanguage2 markerTextAutoLanguage2;
  69. [SerializeField]
  70. GameObject LayoutStart;
  71. [SerializeField]
  72. GameObject LayoutMarker;
  73. [SerializeField]
  74. GameObject LayoutSuccessful;
  75. [Tooltip("选择框的Line")]
  76. [SerializeField]
  77. Sprite[] ResultLines;// 0: 选中状态, 1: 未选中状态
  78. [Tooltip("选择框图片")]
  79. [SerializeField]
  80. Image[] ResultImages;
  81. [Tooltip("选择框按钮")]
  82. [SerializeField]
  83. Button[] ResultImagesButtons;
  84. [SerializeField]
  85. Button[] ResultButtons; // 结果选择按钮
  86. [SerializeField]
  87. RawImage CameraFirstImage; //第一个结果屏幕
  88. [SerializeField]
  89. RawImage CameraSecondImage; //第二个结果屏幕
  90. [SerializeField] LineGenerator FirstUILineGenerator;//第一个结果屏幕线条
  91. [SerializeField] LineGenerator SecondUILineGenerator;//第二个结果屏幕线条
  92. bool doLocateAuto;
  93. int DefaultResolutionIndex;
  94. private void Awake()
  95. {
  96. offset = line.MyThickness;
  97. }
  98. void Start()
  99. {
  100. doLocateAuto = false;
  101. textTip1.SetActive(true);
  102. //设置btnAuto 高亮
  103. OnButtonClick(btnAuto);
  104. textTip2.SetActive(false);
  105. //动态设置marker的提示语
  106. if (BluetoothAim.ins!=null && markerTextAutoLanguage2 != null)
  107. {
  108. string name = "";
  109. bool switchValue = false;
  110. if (BluetoothAim.ins.isMainConnectToHOUYIPRO())
  111. {
  112. name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-HOUYIPro");
  113. }
  114. else if (BluetoothAim.ins.isMainConnectToARTEMISPRO())
  115. {
  116. name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-ArtemisPro");
  117. }
  118. else if (BluetoothAim.ins.isMainConnectToGun())
  119. {
  120. //name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-M9");
  121. switchValue = true;
  122. }
  123. if (switchValue)
  124. {
  125. markerTextAutoLanguage2.SetTextKey("TitleTipMarker-M9");
  126. }
  127. else {
  128. markerTextAutoLanguage2.textFormatArgs = new object[] { name };
  129. }
  130. }
  131. //手动不高亮
  132. //ResetButton(btnHandMovement);
  133. //quadUnityVectorList.Clear();
  134. //quadUnityVectorList.Add(new Vector2(16.39f, 35.91f));
  135. //quadUnityVectorList.Add(new Vector2(233.35f, 51.08f));
  136. //quadUnityVectorList.Add(new Vector2(94.15f, 219.11f));
  137. //quadUnityVectorList.Add(new Vector2(243.12f, 237.40f));
  138. Debug.Log("quadUnityVectorList count:" + ScreenLocate.quadUnityVectorList.Count);
  139. if (ScreenLocate.quadUnityVectorList.Count == 0)
  140. {
  141. Debug.Log("GetLocalPos");
  142. GetLocalPos();
  143. }
  144. else
  145. {
  146. Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
  147. Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
  148. //自动识别时候四个点
  149. SyncQuadUnityVectorListToPos();
  150. //pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  151. //pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  152. //pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  153. //pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  154. }
  155. //记录操作的位置信息
  156. oldLinePosition = new List<LinePosition>();
  157. SetLinePos();
  158. //相机感光度
  159. if (InfraredDemo._ins)
  160. {
  161. //重置偏移量
  162. InfraredDemo._ins.ResetCenterOffset();
  163. //重置识别点
  164. ScreenLocate.Main.ScreenIdentification.ClearQuadCache();
  165. //清除一下记录的点
  166. ScreenLocate.quadUnityVectorList.Clear();
  167. slider.onValueChanged.AddListener((value) =>
  168. {
  169. InfraredDemo._ins.onSliderEvent(value);
  170. });
  171. InfraredDemo._ins.onSetSliderValue(slider);
  172. offset = line.MyThickness = InfraredDemo._ins.lineWidth.Get();
  173. }
  174. else {
  175. //编辑器使用
  176. if (Application.isEditor || Application.platform == RuntimePlatform.WindowsPlayer) {
  177. slider.onValueChanged.AddListener((value) =>
  178. {
  179. double originalMin = 0.0;
  180. double originalMax = 10.0;
  181. double targetMin = -1;
  182. double targetMax = 1;
  183. // 计算转换后的值
  184. double result = InfraredDemo.MapValue(value, originalMin, originalMax, targetMin, targetMax);
  185. //int _current = (int)(result);
  186. Debug.Log("_current:" + value + " , result:" + result);
  187. ScreenLocate.Main.pcContrast = (float)result;
  188. });
  189. float v = ScreenLocate.Main.pcContrast;
  190. // 目标区间 [0, 10] 的边界值
  191. double targetMin = 0.0;
  192. double targetMax = 10.0;
  193. double originalMin = -1;
  194. double originalMax = 1;
  195. // 计算转换后的值
  196. double v2 = InfraredDemo.MapValue(v, originalMin, originalMax, targetMin, targetMax);
  197. Debug.Log("PC获取相机的感光度:" + v + " = " + v2);
  198. slider.SetValueWithoutNotify((float)v2);
  199. }
  200. }
  201. initSelectInfo();
  202. //if (ScreenLocate.Main.getUVCTexture)
  203. //{
  204. // //渲染相机画面
  205. // rawImage.texture = ScreenLocate.Main.getUVCTexture;
  206. // //Debug.Log("rawImage.texture:" + rawImage.texture.name);
  207. //}
  208. //slider.onValueChanged.AddListener((value) => {
  209. // //onSliderEvent(value);
  210. // InfraredDemo._ins.SetBrightness(value);
  211. //});
  212. //slider.value = InfraredDemo._ins.brightness.Get();
  213. //修改分辨率。是否清晰一点?
  214. //DefaultResolutionIndex = InfraredDemo._ins?.ResolutionIndex ?? 0;
  215. //Debug.Log("[InfraredScreenPositioningView]开始记录进入时候的分辨率:" + DefaultResolutionIndex);
  216. //InfraredDemo._ins?.SetResolutionNew(ScreenLocate.Main.HighScreenLocateResolutionIndex);
  217. //if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked)
  218. //{
  219. // SB_EventSystem.ins.AwakenSimulateMouse();
  220. // // Debug.Log("simulate-mouse-close");
  221. //}
  222. }
  223. private void OnDestroy()
  224. {
  225. //修改回进入手动调节页面时候的分辨率
  226. //InfraredDemo._ins?.SetResolutionNew(DefaultResolutionIndex);
  227. Debug.Log("OnDestroy*********************************AwakenSimulateMouse:" + SB_EventSystem.ins.simulateMouseIsAwaked);
  228. if (SB_EventSystem.ins && !SB_EventSystem.ins.simulateMouseIsAwaked)
  229. {
  230. SB_EventSystem.ins.AwakenSimulateMouse();
  231. }
  232. }
  233. public RawImage Bg => rawImage;
  234. void Update()
  235. {
  236. if (enterFromZimWebCamera && ScreenLocate.Main.DebugOnZIMDemo) {
  237. // ZimWebCamera场景测试
  238. rawImage.texture = ScreenLocate.Main.outputRawImages[7].texture;
  239. if (ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.HasValue)
  240. {
  241. // 检测到光点
  242. var posInCanvas = ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.Value.pixelToLocalPosition_AnchorCenter(ScreenLocate.Main.CameraSize, rawImage.rectTransform.rect);
  243. crosshair.gameObject.SetActive(true);
  244. crosshair.anchoredPosition = posInCanvas;
  245. }
  246. else
  247. crosshair.gameObject.SetActive(false);
  248. //渲染相机画面
  249. CameraSecondImage.texture = rawImage.texture;
  250. CameraFirstImage.texture = rawImage.texture;
  251. }
  252. else if (InfraredDemo.running)
  253. {
  254. //渲染相机画面
  255. Texture texture = InfraredDemo.infraredCameraHelper.GetCameraTexture();
  256. if (rawImage.texture == null || texture.GetNativeTexturePtr() != rawImage.texture.GetNativeTexturePtr())
  257. {
  258. rawImage.texture = texture;
  259. //渲染相机画面
  260. CameraSecondImage.texture = rawImage.texture;
  261. CameraFirstImage.texture = rawImage.texture;
  262. }
  263. //rawImage.material = InfraredDemo.infraredCameraHelper.GetCameraMaterial();
  264. }
  265. }
  266. public void OnClick_Back()
  267. {
  268. AudioMgr.ins.PlayBtn();
  269. ViewMgr.Instance.DestroyView<InfraredScreenPositioningView>();
  270. }
  271. /// <summary>
  272. /// 进入屏幕标记
  273. /// </summary>
  274. public void OnClick_EnterMarker() {
  275. LayoutStart.SetActive(false);
  276. LayoutMarker.SetActive(true);
  277. }
  278. /// <summary>
  279. /// 自动识别
  280. /// </summary>
  281. public void OnClick_Auto()
  282. {
  283. bAuto = true;
  284. doLocateAuto = true;
  285. textTip1.SetActive(false);
  286. textTip2.SetActive(true);
  287. ResetButton(btnAuto);
  288. if (enterFromZimWebCamera)
  289. {
  290. ScreenLocate _screenLocate = FindAnyObjectByType<ScreenLocate>();
  291. _screenLocate.EnterScreenLocateManualAuto();
  292. return;
  293. }
  294. if (InfraredDemo.running)
  295. {
  296. InfraredDemo.infraredCameraHelper.EnterScreenLocateManualAuto();
  297. }
  298. }
  299. /// <summary>
  300. /// 切换成手动方式
  301. /// </summary>
  302. public void onHandMovement()
  303. {
  304. bAuto = false;
  305. doLocateAuto = false;
  306. draggableParent.gameObject.SetActive(true);
  307. pointsParent.gameObject.SetActive(false);
  308. mask.SetActive(false);
  309. cameraLight.SetActive(true);
  310. }
  311. /// <summary>
  312. /// 自动识别后同步
  313. /// </summary>
  314. public void SyncScreenPosition()
  315. {
  316. //Debug.Log("quadUnityVectorList[i]:" + quadUnityVectorList[i]);
  317. Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
  318. Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
  319. //自动识别时候四个点
  320. //pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  321. //pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  322. //pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  323. //pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  324. SyncQuadUnityVectorListToPos();
  325. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  326. //自动识别后隐藏手动按钮
  327. draggableParent.gameObject.SetActive(false);
  328. pointsParent.gameObject.SetActive(true);
  329. if (ScreenLocate.Main) {
  330. ZIM.Unity.QuadrilateralInCamera screen = ScreenLocate.Main.ScreenIdentification.Screen.QuadInCamera;
  331. //设置points点
  332. for (int i = 0; i < 4; i++)
  333. {
  334. RectTransform t = pointsParent.GetChild(i) as RectTransform;
  335. t.anchoredPosition = screen.Quad[i].pixelToLocalPosition_AnchorCenter(screen.CameraSize, pointsParent.rect);
  336. }
  337. }
  338. //显示最后结果
  339. LayoutMarker.SetActive(false);
  340. LayoutSuccessful.SetActive(true);
  341. //设置两个线段
  342. QuadrilateralInCamera screenAuto = ScreenLocate.Main.ScreenIdentification.QuadAuto;
  343. QuadrilateralInCamera screenSemiAuto = ScreenLocate.Main.ScreenIdentification.QuadSemiAuto;
  344. var lo = new Vector2(-0.5f, -0.5f);
  345. if (screenAuto != null)
  346. {
  347. FirstUILineGenerator.Points = new Vector2[4] {
  348. 2 * (new Vector2(screenAuto.Quad[0].x/texSize.x,screenAuto.Quad[0].y/texSize.y) + lo),
  349. 2 * (new Vector2(screenAuto.Quad[1].x/texSize.x,screenAuto.Quad[1].y/texSize.y) + lo),
  350. 2 * (new Vector2(screenAuto.Quad[3].x/texSize.x,screenAuto.Quad[3].y/texSize.y) + lo),
  351. 2 * (new Vector2(screenAuto.Quad[2].x/texSize.x,screenAuto.Quad[2].y/texSize.y) + lo) };
  352. // 打印 Points 的值,合并为一个字符串
  353. string pointsOutput = "1 Points: ";
  354. for (int i = 0; i < FirstUILineGenerator.Points.Length; i++)
  355. {
  356. pointsOutput += "[" + FirstUILineGenerator.Points[i].x + ", " + FirstUILineGenerator.Points[i].y + "]";
  357. if (i < FirstUILineGenerator.Points.Length - 1)
  358. {
  359. pointsOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  360. }
  361. }
  362. Debug.Log(pointsOutput);
  363. // 打印 Quad 的值,合并为一个字符串
  364. int[] customOrder = new int[] { 0, 1, 3, 2 };
  365. string quadOutput = "1 Quad Points: ";
  366. for (int i = 0; i < customOrder.Length; i++)
  367. {
  368. quadOutput += "[" + screenAuto.Quad[customOrder[i]].x + ", " + screenAuto.Quad[customOrder[i]].y + "]";
  369. if (i < customOrder.Length - 1)
  370. {
  371. quadOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  372. }
  373. }
  374. Debug.Log(quadOutput);
  375. }
  376. else {
  377. Debug.LogError("screenAuto 不存在!");
  378. }
  379. if (screenSemiAuto != null)
  380. {
  381. SecondUILineGenerator.Points = new Vector2[4] {
  382. 2 * (new Vector2(screenSemiAuto.Quad[0].x/texSize.x,screenSemiAuto.Quad[0].y/texSize.y) + lo),
  383. 2 * (new Vector2(screenSemiAuto.Quad[1].x/texSize.x,screenSemiAuto.Quad[1].y/texSize.y) + lo),
  384. 2 * (new Vector2(screenSemiAuto.Quad[3].x/texSize.x,screenSemiAuto.Quad[3].y/texSize.y) + lo),
  385. 2 * (new Vector2(screenSemiAuto.Quad[2].x/texSize.x,screenSemiAuto.Quad[2].y/texSize.y) + lo) };
  386. // 打印 Points 的值,合并为一个字符串
  387. string pointsOutput = "2 Points: ";
  388. for (int i = 0; i < SecondUILineGenerator.Points.Length; i++)
  389. {
  390. pointsOutput += "[" + SecondUILineGenerator.Points[i].x + ", " + SecondUILineGenerator.Points[i].y + "]";
  391. if (i < SecondUILineGenerator.Points.Length - 1)
  392. {
  393. pointsOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  394. }
  395. }
  396. Debug.Log(pointsOutput);
  397. // 打印 Quad 的值,合并为一个字符串
  398. int[] customOrder = new int[] { 0, 1, 3, 2 };
  399. string quadOutput = "2 Quad Points: ";
  400. for (int i = 0; i < customOrder.Length; i++)
  401. {
  402. quadOutput += "[" + screenSemiAuto.Quad[customOrder[i]].x + ", " + screenSemiAuto.Quad[customOrder[i]].y + "]";
  403. if (i < customOrder.Length - 1)
  404. {
  405. quadOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  406. }
  407. }
  408. Debug.Log(quadOutput);
  409. }
  410. else {
  411. Debug.LogError("screenSemiAuto 不存在!");
  412. }
  413. }
  414. #region 绘制线段部分
  415. //点击拖拽的开始位置
  416. public void onBeginPos(int index, Vector3 pos)
  417. {
  418. Debug.Log("pos begin: " + pos);
  419. beginPos = pos;
  420. }
  421. public void onDragPos(int index, Vector3 pos)
  422. {
  423. //设置线段的点
  424. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  425. }
  426. //点击拖拽的结束位置
  427. public void onEndPos(int index, Vector3 pos)
  428. {
  429. Debug.Log("pos end: " + pos);
  430. endPos = pos;
  431. if (beginPos == endPos) return;
  432. //Debug.Log(index+",最后的点:" + pos);
  433. //再记录一次最后的点
  434. SetLinePos();
  435. }
  436. //同步设置图片对应的位置到line
  437. public void SetLinePos()
  438. {
  439. //记录一个操作点的操作位置
  440. AddOldLinePosition();
  441. //设置线段的点
  442. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  443. }
  444. void AddOldLinePosition()
  445. {
  446. Vector3[] v = new Vector3[4];
  447. pos1.GetWorldCorners(v);
  448. Vector3[] v1 = new Vector3[4];
  449. pos1.GetLocalCorners(v1);
  450. //for (int i = 0; i < 4; i++)
  451. //{
  452. // Debug.Log(i + " =1= " + v[i]);
  453. // Debug.Log(i + " =2= " + v1[i]);
  454. //}
  455. //记录一个操作点的操作位置
  456. List<Vector3> screenPositions = new List<Vector3>();
  457. screenPositions.Add(pos1.localPosition);
  458. screenPositions.Add(pos2.localPosition);
  459. screenPositions.Add(pos3.localPosition);
  460. screenPositions.Add(pos4.localPosition);
  461. LinePosition linePosition = new LinePosition();
  462. linePosition.index = oldLinePosition.Count;
  463. linePosition.pos = screenPositions;
  464. oldLinePosition.Add(linePosition);
  465. }
  466. //转换绘制线段的点
  467. List<Vector2> linePosConversion(Vector3 _pos1, Vector3 _pos2, Vector3 _pos3, Vector3 _pos4)
  468. {
  469. List<Vector2> _screenPositions = new List<Vector2>();
  470. //点为负数的增大 offset,正数减少 offset
  471. //Vector2 startPos1 = new Vector2(_pos1.x - pos1.rect.width * 0.5f + offset, _pos1.y - pos1.rect.height * 0.5f + offset);
  472. //Vector2 startPos2 = new Vector2(_pos2.x + pos2.rect.width * 0.5f - offset, _pos2.y - pos2.rect.height * 0.5f + offset);
  473. //Vector2 startPos3 = new Vector2(_pos3.x + pos3.rect.width * 0.5f - offset, _pos3.y + pos3.rect.height * 0.5f - offset);
  474. //Vector2 startPos4 = new Vector2(_pos4.x - pos4.rect.width * 0.5f + offset, _pos4.y + pos4.rect.height * 0.5f - offset);
  475. Vector2 startPos1 = new Vector2(_pos1.x + offset, _pos1.y + offset);
  476. Vector2 startPos2 = new Vector2(_pos2.x - offset, _pos2.y + offset);
  477. Vector2 startPos3 = new Vector2(_pos3.x - offset, _pos3.y - offset);
  478. Vector2 startPos4 = new Vector2(_pos4.x + offset, _pos4.y - offset);
  479. _screenPositions.Add(startPos1);
  480. _screenPositions.Add(startPos2);
  481. _screenPositions.Add(startPos3);
  482. _screenPositions.Add(startPos4);
  483. return _screenPositions;
  484. }
  485. void SetRectanglePoints(List<Vector2> screenPositions)
  486. {
  487. line.SetLine(screenPositions);
  488. }
  489. //撤回上一个元素
  490. public void onRecall()
  491. {
  492. // 获取并删除最后一个元素,并且保留一个元素
  493. if (oldLinePosition.Count > 1) // 确保列表不为空
  494. {
  495. // 获取回退的那个元素点
  496. LinePosition lastElement_second = oldLinePosition[oldLinePosition.Count - 2];
  497. // 获取最后一个元素
  498. //LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  499. //Debug.Log(JsonUtility.ToJson(lastElement) + " = " + oldLinePosition.Count);
  500. oldLinePosition.RemoveAt(oldLinePosition.Count - 1); // 删除最后一个元素
  501. pos1.localPosition = lastElement_second.pos[0];
  502. pos2.localPosition = lastElement_second.pos[1];
  503. pos3.localPosition = lastElement_second.pos[2];
  504. pos4.localPosition = lastElement_second.pos[3];
  505. //设置线段的点
  506. SetRectanglePoints(linePosConversion(lastElement_second.pos[0], lastElement_second.pos[1], lastElement_second.pos[2], lastElement_second.pos[3]));
  507. }
  508. }
  509. //是不是从Demo界面进入该页面的
  510. public bool enterFromInfraredDemo { get; set; } = false;
  511. //是否从测试场景进入
  512. public bool enterFromZimWebCamera { get; set; } = false;
  513. //确认修改
  514. public void onConfirmation()
  515. {
  516. if (enterFromZimWebCamera)
  517. {
  518. ConfirmScreenLocateManualTest();
  519. if (oldLinePosition.Count > 1) // 确保列表不为空
  520. {
  521. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  522. oldLinePosition.Clear();
  523. oldLinePosition.Add(lastElement);
  524. }
  525. SaveLocalPos();
  526. AudioMgr.ins.PlayBtn();
  527. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  528. return;
  529. }
  530. if (!ConfirmScreenLocateManual()) return;
  531. if (oldLinePosition.Count > 1) // 确保列表不为空
  532. {
  533. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  534. oldLinePosition.Clear();
  535. oldLinePosition.Add(lastElement);
  536. }
  537. if (InfraredDemo.running)
  538. {
  539. //跳转入界面
  540. AudioMgr.ins.PlayBtn();
  541. if (!enterFromInfraredDemo)
  542. {
  543. //每次初始化重置一下引导
  544. InfraredDemo._ins.resetInfraredPlayerPrefs();
  545. //GameObject connectGuidanceView = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_ConnectGuidanceView);
  546. //connectGuidanceView.GetComponent<ConnectGuidanceView>().showTextipInfrared();
  547. if (!PlayerPrefs.HasKey("hideInfraredBowAndArrow"))
  548. {
  549. //如果是红外连接成功,记录一个tag
  550. PlayerPrefs.SetInt("hideInfraredBowAndArrow", 1);
  551. }
  552. onEnterInfrared();
  553. }
  554. else {
  555. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  556. }
  557. }
  558. //存储一次节点
  559. SaveLocalPos();
  560. }
  561. //重置位置
  562. public void onReset()
  563. {
  564. oldLinePosition.Clear();
  565. // 获取屏幕的四个角的像素坐标
  566. Vector2 bottomLeft = new Vector2(0, 0);
  567. // 将屏幕像素坐标转换为 Canvas 的局部坐标
  568. Vector2 localBottomLeft;
  569. RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, bottomLeft, null, out localBottomLeft);
  570. // 打印结果
  571. Debug.Log("Local Bottom Left: " + localBottomLeft);
  572. //int _x = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.x) - 120), _y = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.y) - 77);
  573. int _x = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.x)), _y = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.y));
  574. pos1.anchoredPosition = new Vector3(-_x, -_y, 0); //Bottom Left
  575. pos2.anchoredPosition = new Vector3(_x, -_y, 0); //Bottom Right
  576. pos3.anchoredPosition = new Vector3(_x, _y, 0); //Top Right
  577. pos4.anchoredPosition = new Vector3(-_x, _y, 0); //Top Left
  578. //pos1.anchoredPosition = new Vector3(_x, _y, 0);
  579. //pos2.anchoredPosition = new Vector3(-_x, _y, 0);
  580. //pos3.anchoredPosition = new Vector3(-_x, -_y, 0);
  581. //pos4.anchoredPosition = new Vector3(_x, -_y, 0);
  582. //设置一次位置
  583. SetLinePos();
  584. btnRecordInfrared.Reset();
  585. ScreenLocate.Main.ScreenIdentification.ClearQuadCache();
  586. if (enterFromZimWebCamera)
  587. {
  588. ScreenLocate.Main.ScreenQuad.gameObject.SetActive(false);
  589. ScreenLocate.Main.UILineGenerator.Points = new Vector2[0];
  590. }
  591. }
  592. /// <summary>
  593. /// 标准四个点
  594. /// </summary>
  595. /// <param name="index"></param>
  596. /// <param name="pos"></param>
  597. public void onManualNewPos(int index, Vector3 pos)
  598. {
  599. Debug.Log("pos end: " + pos);
  600. if (index == 0)
  601. pos1.localPosition = pos;
  602. else if (index == 1)
  603. pos2.localPosition = pos;
  604. else if (index == 2)
  605. pos3.localPosition = pos;
  606. else if (index == 3)
  607. pos4.localPosition = pos;
  608. //再记录一次最后的点
  609. SetLinePos();
  610. }
  611. /// <summary>
  612. /// 处理新流程,先记录手动,然后到自动识别处理
  613. /// </summary>
  614. public void onManualToAutomatic() {
  615. if (enterFromZimWebCamera)
  616. {
  617. ConfirmScreenLocateManualTest();
  618. if (oldLinePosition.Count > 1) // 确保列表不为空
  619. {
  620. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  621. oldLinePosition.Clear();
  622. oldLinePosition.Add(lastElement);
  623. }
  624. SaveLocalPos();
  625. //到自动
  626. OnClick_Auto();
  627. return;
  628. }
  629. if (!ConfirmScreenLocateManual()) {
  630. Debug.LogError("ConfirmScreenLocateManual is false!");
  631. return;
  632. }
  633. if (oldLinePosition.Count > 1) // 确保列表不为空
  634. {
  635. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  636. oldLinePosition.Clear();
  637. oldLinePosition.Add(lastElement);
  638. }
  639. //存储一次节点
  640. SaveLocalPos();
  641. bAuto = true;
  642. doLocateAuto = true;
  643. //自动校准
  644. InfraredDemo.infraredCameraHelper.EnterScreenLocateManualAuto();
  645. }
  646. #endregion
  647. List<Vector2> _locatePointList = new();
  648. float _texWidth;
  649. float _texHeight;
  650. void RecordLocatePoint(RectTransform p, Vector2 pivot)
  651. {
  652. Vector2 pos = JCUnityLib.RectTransformUtils.GetPositionByPivot(p, pivot);
  653. pos.x = Mathf.Clamp01(pos.x / Screen.width);
  654. pos.y = Mathf.Clamp01(pos.y / Screen.height);
  655. _locatePointList.Add(pos);
  656. }
  657. bool ConfirmScreenLocateManual()
  658. {
  659. if (InfraredDemo.running)
  660. {
  661. //渲染截图
  662. Texture2D texture2D = InfraredDemo.infraredCameraHelper.EnterScreenLocateManual();
  663. if (texture2D == null)
  664. {
  665. Debug.Log("EnterScreenLocateManual = null");
  666. InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(null);
  667. return false;
  668. }
  669. _locatePointList.Clear();
  670. _texWidth = texture2D.width;
  671. _texHeight = texture2D.height;
  672. RecordLocatePoint(pos1, new Vector2(0, 0));
  673. RecordLocatePoint(pos2, new Vector2(1, 0));
  674. RecordLocatePoint(pos3, new Vector2(1, 1));
  675. RecordLocatePoint(pos4, new Vector2(0, 1));
  676. //RecordLocatePoint(pos1, new Vector2(0.5f, 0.5f));
  677. //RecordLocatePoint(pos2, new Vector2(0.5f, 0.5f));
  678. //RecordLocatePoint(pos3, new Vector2(0.5f, 0.5f));
  679. //RecordLocatePoint(pos4, new Vector2(0.5f, 0.5f));
  680. InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(_locatePointList);
  681. FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, 1, 1);
  682. //同步数据
  683. ScreenLocate.quadUnityVectorList.Clear();
  684. ScreenLocate.quadUnityVectorList.Add(_locatePointList[0]);
  685. ScreenLocate.quadUnityVectorList.Add(_locatePointList[1]);
  686. //两个点切换,顺序不一样
  687. ScreenLocate.quadUnityVectorList.Add(_locatePointList[3]);
  688. ScreenLocate.quadUnityVectorList.Add(_locatePointList[2]);
  689. ScreenLocate.SaveScreenLocateVectorList();
  690. return true;
  691. }
  692. return false;
  693. }
  694. void ConfirmScreenLocateManualTest()
  695. {
  696. //渲染截图
  697. ScreenLocate _screenLocate = FindAnyObjectByType<ScreenLocate>();
  698. Texture2D texture2D = _screenLocate.EnterScreenLocateManual();
  699. if (texture2D == null)
  700. {
  701. _screenLocate.QuitScreenLocateManual(null);
  702. return;
  703. }
  704. _locatePointList.Clear();
  705. _texWidth = texture2D.width;
  706. _texHeight = texture2D.height;
  707. RecordLocatePoint(pos1, new Vector2(0, 0));
  708. RecordLocatePoint(pos2, new Vector2(1, 0));
  709. RecordLocatePoint(pos3, new Vector2(1, 1));
  710. RecordLocatePoint(pos4, new Vector2(0, 1));
  711. _screenLocate.QuitScreenLocateManual(_locatePointList);
  712. //FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, _texWidth, _texHeight);
  713. setPointsLocation(_locatePointList,pointsParent.gameObject,!bAuto);
  714. if (!doLocateAuto) // 设置手动定位数据
  715. setPointsManual(_locatePointList, GameObject.Find("WebCameraView/CameraImage0/ScreenQuad"));
  716. //同步数据
  717. ScreenLocate.quadUnityVectorList.Clear();
  718. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[0].x, _locatePointList[0].y));
  719. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[1].x, _locatePointList[1].y));
  720. //两个点切换,顺序不一样
  721. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[3].x, _locatePointList[3].y));
  722. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[2].x, _locatePointList[2].y));
  723. ScreenLocate.SaveScreenLocateVectorList();
  724. }
  725. void setPointsLocation(List<Vector2> targetList, GameObject pointsTF2, bool active = true)
  726. {
  727. //GameObject pointsTF2 = GameObject.Find("WebCameraView/CameraImage0/ScreenQuad");
  728. pointsTF2.SetActive(active);
  729. if (pointsTF2.transform.childCount == targetList.Count)
  730. {
  731. for (int i = 0; i < pointsTF2.transform.childCount; i++)
  732. {
  733. Transform pointTF = pointsTF2.transform.GetChild(i);
  734. Vector2 pos = targetList[i];
  735. pointTF.localPosition = pos.pixelToLocalPosition_AnchorCenter(Vector2.one, pointsTF2.GetComponent<RectTransform>().rect);
  736. pointTF.gameObject.SetActive(true);
  737. }
  738. }
  739. }
  740. void setPointsManual(List<Vector2> targetList, GameObject pointsTF2, bool active = true)
  741. {
  742. setPointsLocation(targetList, pointsTF2, active);
  743. var lo = new Vector2(-0.5f, -0.5f);
  744. ScreenLocate.Main.UILineGenerator.Points = new Vector2[4] {
  745. 2 * (targetList[0] + lo),
  746. 2 * (targetList[1] + lo),
  747. 2 * (targetList[2] + lo),
  748. 2 * (targetList[3] + lo) };
  749. // 记录手动数据
  750. //var size = ScreenLocate.Main.getUVCCameraInfoSize;
  751. //var quad = new QuadrilateralInCamera(
  752. // new o0.Geometry2D.Float.Vector(targetList[0].x * size.x, targetList[0].y * size.y),
  753. // new o0.Geometry2D.Float.Vector(targetList[1].x * size.x, targetList[1].y * size.y),
  754. // new o0.Geometry2D.Float.Vector(targetList[3].x * size.x, targetList[3].y * size.y),
  755. // new o0.Geometry2D.Float.Vector(targetList[2].x * size.x, targetList[2].y * size.y),
  756. // size.o0Vector()
  757. // );
  758. //ScreenLocate.Main.ScreenIdentification.QuadManual = quad;
  759. //Debug.Log("<color=aqua>[ScreenLocate] 记录手动数据</color>");
  760. }
  761. void SaveLocalPos()
  762. {
  763. List<Vector3> screenPositions = new List<Vector3>();
  764. screenPositions.Add(pos1.anchoredPosition);
  765. screenPositions.Add(pos2.anchoredPosition);
  766. screenPositions.Add(pos3.anchoredPosition);
  767. screenPositions.Add(pos4.anchoredPosition);
  768. string saveStr = string.Join(';', screenPositions.Select(v => $"{v.x},{v.y}")); //,{v.z}
  769. Debug.Log("Local UI Position: " + saveStr);
  770. PlayerPrefs.SetString("ScreenPositioningView", saveStr);
  771. }
  772. void GetLocalPos()
  773. {
  774. string posListStr = PlayerPrefs.GetString("ScreenPositioningView", "");
  775. if (!string.IsNullOrWhiteSpace(posListStr))
  776. {
  777. List<Vector2> posList = posListStr.Split(';')
  778. .Select(s =>
  779. {
  780. string[] parts = s.Split(',');
  781. return new Vector2(float.Parse(parts[0]), float.Parse(parts[1]));
  782. })
  783. .ToList();
  784. pos1.anchoredPosition = posList[0];
  785. pos2.anchoredPosition = posList[1];
  786. pos3.anchoredPosition = posList[2];
  787. pos4.anchoredPosition = posList[3];
  788. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  789. }
  790. }
  791. #region 按钮颜色切换
  792. private void OnButtonClick(Button button)
  793. {
  794. // 切换按钮颜色
  795. ColorBlock colors = button.colors;
  796. colors.normalColor = highlightedColor;
  797. colors.highlightedColor = highlightedColor;
  798. button.colors = colors;
  799. // 切换字体颜色
  800. Text buttonText = button.GetComponentInChildren<Text>();
  801. buttonText.color = highlightedTextColor;
  802. }
  803. private void ResetButton(Button button)
  804. {
  805. // 重置按钮颜色
  806. ColorBlock colors = button.colors;
  807. colors.normalColor = normalColor;
  808. colors.highlightedColor = normalColor;
  809. button.colors = colors;
  810. // 重置字体颜色
  811. Text buttonText = button.GetComponentInChildren<Text>();
  812. buttonText.color = normalTextColor;
  813. }
  814. #endregion
  815. #region 标定完成之后进入游戏界面
  816. void onEnterInfrared()
  817. {
  818. //添加进入射箭场景
  819. if (PlayerPrefs.GetInt("entry-guider-infrared-" + LoginMgr.myUserInfo.id, 0) == 0)
  820. {
  821. Debug.Log("-----进入射箭场景!");
  822. NewUserGuiderManager newUserGuiderManager = FindObjectOfType<NewUserGuiderManager>();
  823. newUserGuiderManager.curConfigKey = "开始-红外调整";
  824. newUserGuiderManager.isNewModule = AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.HOUYIPRO || AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.Gun || AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.ARTEMISPRO;
  825. //进入射箭场景
  826. GlobalData.pkMatchType = PKMatchType.None;
  827. GameMgr.gameType = 1;
  828. //射一箭回到连接页面,Device.view
  829. GameMgr.bNavBack = true;
  830. GameMgr.bShowDistance = false;
  831. AimHandler.ins.bInitOne = false;//true
  832. //关闭计时器
  833. GameMgr.turnOffTimer = true;
  834. //关闭左边靶子和底部速度栏
  835. GameMgr.HideTargetView = true;
  836. GameMgr.HideBillboard = true;
  837. GameMgr.ButtonCount = 0;
  838. UnityEngine.SceneManagement.SceneManager.LoadScene(
  839. "Game", UnityEngine.SceneManagement.LoadSceneMode.Single);
  840. PlayerPrefs.SetInt("entry-guider-infrared-" + LoginMgr.myUserInfo.id, 1);
  841. }
  842. else
  843. {
  844. Debug.Log("-----跳转回连接界面!");
  845. //如不是第一次,则应该跳转回连接界面
  846. ViewMgr.Instance.DestroyView<SmartArcheryView>();
  847. ViewManager2.HideView(ViewManager2.Path_ConnectGuidanceView);
  848. }
  849. }
  850. #endregion
  851. #region 最后选择算法处理UI
  852. int selected = -1;
  853. void initSelectInfo() {
  854. for (int i = 0; i < 2; i++)
  855. {
  856. int currentIndex = i; // 将 i 赋值给局部变量
  857. ResultImagesButtons[currentIndex].onClick.AddListener(() => SelectImage(currentIndex));
  858. //ResultButtons[currentIndex].onClick.AddListener(() =>
  859. //{
  860. // if (currentIndex == 0)
  861. // {
  862. // OnFirstResult();
  863. // }
  864. // else if (currentIndex == 1)
  865. // {
  866. // OnSecondResult();
  867. // }
  868. //});
  869. }
  870. //默认选择1 自动
  871. SelectImage(0);
  872. }
  873. // 添加一个选择函数
  874. void SelectImage(int selectedIndex)
  875. {
  876. //如果重复选中则跳转
  877. if (selected == selectedIndex) {
  878. if (selected == 0)
  879. {
  880. OnFirstResult();
  881. }
  882. else if (selected == 1)
  883. {
  884. OnSecondResult();
  885. }
  886. return;
  887. }
  888. // 遍历所有图片
  889. for (int i = 0; i < ResultImages.Length; i++)
  890. {
  891. // 如果是选中的 index,赋值为 ResultLines[0],否则赋值为 ResultLines[1]
  892. if (i == selectedIndex)
  893. {
  894. selected = i;
  895. ResultImages[i].sprite = ResultLines[0];
  896. ResultButtons[i].interactable = true;
  897. }
  898. else
  899. {
  900. ResultImages[i].sprite = ResultLines[1];
  901. ResultButtons[i].interactable = false;
  902. }
  903. }
  904. }
  905. //选择全自动结果后进入游戏
  906. void OnFirstResult()
  907. {
  908. ScreenLocate.Main.SelectScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.Auto);
  909. UpdateQuadUnityVectorList();
  910. onCompelete();
  911. }
  912. //选择半自动结果
  913. void OnSecondResult()
  914. {
  915. ScreenLocate.Main.SelectScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.SemiAuto);
  916. UpdateQuadUnityVectorList();
  917. onCompelete();
  918. }
  919. public void onCompelete()
  920. {
  921. if (enterFromZimWebCamera)
  922. {
  923. SaveLocalPos();
  924. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  925. return;
  926. }
  927. if (InfraredDemo.running)
  928. {
  929. //跳转入界面
  930. AudioMgr.ins.PlayBtn();
  931. if (!enterFromInfraredDemo)
  932. {
  933. //每次初始化重置一下引导
  934. InfraredDemo._ins.resetInfraredPlayerPrefs();
  935. //GameObject connectGuidanceView = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_ConnectGuidanceView);
  936. //connectGuidanceView.GetComponent<ConnectGuidanceView>().showTextipInfrared();
  937. if (!PlayerPrefs.HasKey("hideInfraredBowAndArrow"))
  938. {
  939. //如果是红外连接成功,记录一个tag
  940. PlayerPrefs.SetInt("hideInfraredBowAndArrow", 1);
  941. }
  942. onEnterInfrared();
  943. }
  944. else
  945. {
  946. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  947. }
  948. }
  949. //存储一次节点
  950. SaveLocalPos();
  951. }
  952. /// <summary>
  953. /// 选择模式后更新 quadUnityVectorList
  954. /// </summary>
  955. void UpdateQuadUnityVectorList() {
  956. ScreenLocate.Main.UpdateQuadUnityVectorList();
  957. SyncQuadUnityVectorListToPos();
  958. InfraredDemo._ins?.SetLocatePointsToCameraRender(ScreenLocate.quadUnityVectorList, 1, 1);
  959. _locatePointList.Clear();
  960. }
  961. void SyncQuadUnityVectorListToPos() {
  962. Debug.Log("[ScreenLocate] SyncQuadUnityVectorListToPos quadUnityVectorList:" + ScreenLocate.Main.PrintVector2List(ScreenLocate.quadUnityVectorList));
  963. pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  964. pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  965. pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  966. pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  967. }
  968. #endregion
  969. }