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. RectTransform crosshairSmall;
  55. [SerializeField]
  56. GameObject textTip1;
  57. [SerializeField]
  58. GameObject textTip2;
  59. [SerializeField]
  60. Button btnAuto;
  61. [SerializeField]
  62. Button btnHandMovement;
  63. [SerializeField]
  64. BtnRecordInfrared btnRecordInfrared;
  65. bool bAuto = true;
  66. [SerializeField] Color normalColor = Color.white;
  67. [SerializeField] Color highlightedColor = Color.green;
  68. [SerializeField] Color normalTextColor = Color.black;
  69. [SerializeField] Color highlightedTextColor = Color.white;
  70. [SerializeField] TextAutoLanguage2 markerTextAutoLanguage2;
  71. [SerializeField]
  72. GameObject LayoutStart;
  73. [SerializeField]
  74. GameObject LayoutMarker;
  75. [SerializeField]
  76. GameObject LayoutSuccessful;
  77. [Tooltip("选择框的Line")]
  78. [SerializeField]
  79. Sprite[] ResultLines;// 0: 选中状态, 1: 未选中状态
  80. [Tooltip("选择框图片")]
  81. [SerializeField]
  82. Image[] ResultImages;
  83. [Tooltip("选择框按钮")]
  84. [SerializeField]
  85. Button[] ResultImagesButtons;
  86. [SerializeField]
  87. Button[] ResultButtons; // 结果选择按钮
  88. [SerializeField]
  89. RawImage CameraFirstImage; //第一个结果屏幕
  90. [SerializeField]
  91. RawImage CameraSecondImage; //第二个结果屏幕
  92. [SerializeField] LineGenerator FirstUILineGenerator;//第一个结果屏幕线条
  93. [SerializeField] LineGenerator SecondUILineGenerator;//第二个结果屏幕线条
  94. bool doLocateAuto;
  95. int DefaultResolutionIndex;
  96. private void Awake()
  97. {
  98. offset = line.MyThickness;
  99. }
  100. void Start()
  101. {
  102. doLocateAuto = false;
  103. textTip1.SetActive(true);
  104. //设置btnAuto 高亮
  105. OnButtonClick(btnAuto);
  106. textTip2.SetActive(false);
  107. //动态设置marker的提示语
  108. if (BluetoothAim.ins!=null && markerTextAutoLanguage2 != null)
  109. {
  110. string name = "";
  111. bool switchValue = false;
  112. if (BluetoothAim.ins.isMainConnectToHOUYIPRO())
  113. {
  114. name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-HOUYIPro");
  115. }
  116. else if (BluetoothAim.ins.isMainConnectToARTEMISPRO())
  117. {
  118. name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-ArtemisPro");
  119. }
  120. else if (BluetoothAim.ins.isMainConnectToGun())
  121. {
  122. //name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-M9");
  123. switchValue = true;
  124. }
  125. if (switchValue)
  126. {
  127. markerTextAutoLanguage2.SetTextKey("TitleTipMarker-M9");
  128. }
  129. else {
  130. markerTextAutoLanguage2.textFormatArgs = new object[] { name };
  131. }
  132. }
  133. //手动不高亮
  134. //ResetButton(btnHandMovement);
  135. //quadUnityVectorList.Clear();
  136. //quadUnityVectorList.Add(new Vector2(16.39f, 35.91f));
  137. //quadUnityVectorList.Add(new Vector2(233.35f, 51.08f));
  138. //quadUnityVectorList.Add(new Vector2(94.15f, 219.11f));
  139. //quadUnityVectorList.Add(new Vector2(243.12f, 237.40f));
  140. Debug.Log("quadUnityVectorList count:" + ScreenLocate.quadUnityVectorList.Count);
  141. if (ScreenLocate.quadUnityVectorList.Count == 0)
  142. {
  143. Debug.Log("GetLocalPos");
  144. GetLocalPos();
  145. }
  146. else
  147. {
  148. Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
  149. Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
  150. //自动识别时候四个点
  151. SyncQuadUnityVectorListToPos();
  152. //pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  153. //pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  154. //pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  155. //pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  156. }
  157. //记录操作的位置信息
  158. oldLinePosition = new List<LinePosition>();
  159. SetLinePos();
  160. //相机感光度
  161. if (InfraredDemo._ins)
  162. {
  163. //重置偏移量
  164. InfraredDemo._ins.ResetCenterOffset();
  165. //重置识别点
  166. ScreenLocate.Main.ScreenIdentification.ClearQuadCache();
  167. //清除一下记录的点
  168. ScreenLocate.quadUnityVectorList.Clear();
  169. slider.onValueChanged.AddListener((value) =>
  170. {
  171. InfraredDemo._ins.onSliderEvent(value);
  172. });
  173. InfraredDemo._ins.onSetSliderValue(slider);
  174. offset = line.MyThickness = InfraredDemo._ins.lineWidth.Get();
  175. }
  176. else {
  177. //编辑器使用
  178. if (Application.isEditor || Application.platform == RuntimePlatform.WindowsPlayer) {
  179. slider.onValueChanged.AddListener((value) =>
  180. {
  181. double originalMin = 0.0;
  182. double originalMax = 10.0;
  183. double targetMin = -1;
  184. double targetMax = 1;
  185. // 计算转换后的值
  186. double result = InfraredDemo.MapValue(value, originalMin, originalMax, targetMin, targetMax);
  187. //int _current = (int)(result);
  188. Debug.Log("_current:" + value + " , result:" + result);
  189. ScreenLocate.Main.pcContrast = (float)result;
  190. });
  191. float v = ScreenLocate.Main.pcContrast;
  192. // 目标区间 [0, 10] 的边界值
  193. double targetMin = 0.0;
  194. double targetMax = 10.0;
  195. double originalMin = -1;
  196. double originalMax = 1;
  197. // 计算转换后的值
  198. double v2 = InfraredDemo.MapValue(v, originalMin, originalMax, targetMin, targetMax);
  199. Debug.Log("PC获取相机的感光度:" + v + " = " + v2);
  200. slider.SetValueWithoutNotify((float)v2);
  201. }
  202. }
  203. initSelectInfo();
  204. //if (ScreenLocate.Main.getUVCTexture)
  205. //{
  206. // //渲染相机画面
  207. // rawImage.texture = ScreenLocate.Main.getUVCTexture;
  208. // //Debug.Log("rawImage.texture:" + rawImage.texture.name);
  209. //}
  210. //slider.onValueChanged.AddListener((value) => {
  211. // //onSliderEvent(value);
  212. // InfraredDemo._ins.SetBrightness(value);
  213. //});
  214. //slider.value = InfraredDemo._ins.brightness.Get();
  215. //修改分辨率。是否清晰一点?
  216. //DefaultResolutionIndex = InfraredDemo._ins?.ResolutionIndex ?? 0;
  217. //Debug.Log("[InfraredScreenPositioningView]开始记录进入时候的分辨率:" + DefaultResolutionIndex);
  218. //InfraredDemo._ins?.SetResolutionNew(ScreenLocate.Main.HighScreenLocateResolutionIndex);
  219. //if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked)
  220. //{
  221. // SB_EventSystem.ins.AwakenSimulateMouse();
  222. // // Debug.Log("simulate-mouse-close");
  223. //}
  224. }
  225. private void OnDestroy()
  226. {
  227. //修改回进入手动调节页面时候的分辨率
  228. //InfraredDemo._ins?.SetResolutionNew(DefaultResolutionIndex);
  229. Debug.Log("OnDestroy*********************************AwakenSimulateMouse:" + SB_EventSystem.ins.simulateMouseIsAwaked);
  230. if (SB_EventSystem.ins && !SB_EventSystem.ins.simulateMouseIsAwaked)
  231. {
  232. SB_EventSystem.ins.AwakenSimulateMouse();
  233. }
  234. }
  235. public RawImage Bg => rawImage;
  236. void Update()
  237. {
  238. if (enterFromZimWebCamera && ScreenLocate.Main.DebugOnZIMDemo) {
  239. // ZimWebCamera场景测试
  240. rawImage.texture = ScreenLocate.Main.outputRawImages[7].texture;
  241. if (ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.HasValue)
  242. {
  243. // 检测到光点
  244. var posInCanvas = ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.Value.pixelToLocalPosition_AnchorCenter(ScreenLocate.Main.CameraSize, rawImage.rectTransform.rect);
  245. crosshair.gameObject.SetActive(true);
  246. crosshair.anchoredPosition = posInCanvas;
  247. }
  248. else
  249. crosshair.gameObject.SetActive(false);
  250. //渲染相机画面
  251. CameraSecondImage.texture = rawImage.texture;
  252. CameraFirstImage.texture = rawImage.texture;
  253. }
  254. else if (InfraredDemo.running)
  255. {
  256. //渲染相机画面
  257. Texture texture = InfraredDemo.infraredCameraHelper.GetCameraTexture();
  258. if (rawImage.texture == null || texture.GetNativeTexturePtr() != rawImage.texture.GetNativeTexturePtr())
  259. {
  260. rawImage.texture = texture;
  261. //渲染相机画面
  262. CameraSecondImage.texture = rawImage.texture;
  263. CameraFirstImage.texture = rawImage.texture;
  264. }
  265. if (ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.HasValue)
  266. {
  267. // 检测到光点
  268. var posInCanvas = ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.Value.pixelToLocalPosition_AnchorCenter(ScreenLocate.Main.CameraSize, rawImage.rectTransform.rect);
  269. crosshairSmall.gameObject.SetActive(true);
  270. crosshairSmall.anchoredPosition = posInCanvas;
  271. }
  272. else
  273. crosshairSmall.gameObject.SetActive(false);
  274. //rawImage.material = InfraredDemo.infraredCameraHelper.GetCameraMaterial();
  275. }
  276. }
  277. public void OnClick_Back()
  278. {
  279. AudioMgr.ins.PlayBtn();
  280. ViewMgr.Instance.DestroyView<InfraredScreenPositioningView>();
  281. }
  282. /// <summary>
  283. /// 进入屏幕标记
  284. /// </summary>
  285. public void OnClick_EnterMarker() {
  286. LayoutStart.SetActive(false);
  287. LayoutMarker.SetActive(true);
  288. }
  289. /// <summary>
  290. /// 自动识别
  291. /// </summary>
  292. public void OnClick_Auto()
  293. {
  294. bAuto = true;
  295. doLocateAuto = true;
  296. textTip1.SetActive(false);
  297. textTip2.SetActive(true);
  298. ResetButton(btnAuto);
  299. if (enterFromZimWebCamera)
  300. {
  301. ScreenLocate _screenLocate = FindAnyObjectByType<ScreenLocate>();
  302. _screenLocate.EnterScreenLocateManualAuto();
  303. return;
  304. }
  305. if (InfraredDemo.running)
  306. {
  307. InfraredDemo.infraredCameraHelper.EnterScreenLocateManualAuto();
  308. }
  309. }
  310. /// <summary>
  311. /// 切换成手动方式
  312. /// </summary>
  313. public void onHandMovement()
  314. {
  315. bAuto = false;
  316. doLocateAuto = false;
  317. draggableParent.gameObject.SetActive(true);
  318. pointsParent.gameObject.SetActive(false);
  319. mask.SetActive(false);
  320. cameraLight.SetActive(true);
  321. }
  322. /// <summary>
  323. /// 自动识别后同步
  324. /// </summary>
  325. public void SyncScreenPosition()
  326. {
  327. //Debug.Log("quadUnityVectorList[i]:" + quadUnityVectorList[i]);
  328. Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
  329. Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
  330. //自动识别时候四个点
  331. //pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  332. //pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  333. //pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  334. //pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  335. SyncQuadUnityVectorListToPos();
  336. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  337. //自动识别后隐藏手动按钮
  338. draggableParent.gameObject.SetActive(false);
  339. pointsParent.gameObject.SetActive(true);
  340. if (ScreenLocate.Main) {
  341. ZIM.Unity.QuadrilateralInCamera screen = ScreenLocate.Main.ScreenIdentification.Screen.QuadInCamera;
  342. //设置points点
  343. for (int i = 0; i < 4; i++)
  344. {
  345. RectTransform t = pointsParent.GetChild(i) as RectTransform;
  346. t.anchoredPosition = screen.Quad[i].pixelToLocalPosition_AnchorCenter(screen.CameraSize, pointsParent.rect);
  347. }
  348. }
  349. //显示最后结果
  350. LayoutMarker.SetActive(false);
  351. LayoutSuccessful.SetActive(true);
  352. //设置两个线段
  353. QuadrilateralInCamera screenAuto = ScreenLocate.Main.ScreenIdentification.QuadAuto;
  354. QuadrilateralInCamera screenSemiAuto = ScreenLocate.Main.ScreenIdentification.QuadSemiAuto;
  355. var lo = new Vector2(-0.5f, -0.5f);
  356. if (screenAuto != null)
  357. {
  358. FirstUILineGenerator.Points = new Vector2[4] {
  359. 2 * (new Vector2(screenAuto.Quad[0].x/texSize.x,screenAuto.Quad[0].y/texSize.y) + lo),
  360. 2 * (new Vector2(screenAuto.Quad[1].x/texSize.x,screenAuto.Quad[1].y/texSize.y) + lo),
  361. 2 * (new Vector2(screenAuto.Quad[3].x/texSize.x,screenAuto.Quad[3].y/texSize.y) + lo),
  362. 2 * (new Vector2(screenAuto.Quad[2].x/texSize.x,screenAuto.Quad[2].y/texSize.y) + lo) };
  363. // 打印 Points 的值,合并为一个字符串
  364. string pointsOutput = "1 Points: ";
  365. for (int i = 0; i < FirstUILineGenerator.Points.Length; i++)
  366. {
  367. pointsOutput += "[" + FirstUILineGenerator.Points[i].x + ", " + FirstUILineGenerator.Points[i].y + "]";
  368. if (i < FirstUILineGenerator.Points.Length - 1)
  369. {
  370. pointsOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  371. }
  372. }
  373. Debug.Log(pointsOutput);
  374. // 打印 Quad 的值,合并为一个字符串
  375. int[] customOrder = new int[] { 0, 1, 3, 2 };
  376. string quadOutput = "1 Quad Points: ";
  377. for (int i = 0; i < customOrder.Length; i++)
  378. {
  379. quadOutput += "[" + screenAuto.Quad[customOrder[i]].x + ", " + screenAuto.Quad[customOrder[i]].y + "]";
  380. if (i < customOrder.Length - 1)
  381. {
  382. quadOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  383. }
  384. }
  385. Debug.Log(quadOutput);
  386. }
  387. else {
  388. Debug.LogError("screenAuto 不存在!");
  389. }
  390. if (screenSemiAuto != null)
  391. {
  392. SecondUILineGenerator.Points = new Vector2[4] {
  393. 2 * (new Vector2(screenSemiAuto.Quad[0].x/texSize.x,screenSemiAuto.Quad[0].y/texSize.y) + lo),
  394. 2 * (new Vector2(screenSemiAuto.Quad[1].x/texSize.x,screenSemiAuto.Quad[1].y/texSize.y) + lo),
  395. 2 * (new Vector2(screenSemiAuto.Quad[3].x/texSize.x,screenSemiAuto.Quad[3].y/texSize.y) + lo),
  396. 2 * (new Vector2(screenSemiAuto.Quad[2].x/texSize.x,screenSemiAuto.Quad[2].y/texSize.y) + lo) };
  397. // 打印 Points 的值,合并为一个字符串
  398. string pointsOutput = "2 Points: ";
  399. for (int i = 0; i < SecondUILineGenerator.Points.Length; i++)
  400. {
  401. pointsOutput += "[" + SecondUILineGenerator.Points[i].x + ", " + SecondUILineGenerator.Points[i].y + "]";
  402. if (i < SecondUILineGenerator.Points.Length - 1)
  403. {
  404. pointsOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  405. }
  406. }
  407. Debug.Log(pointsOutput);
  408. // 打印 Quad 的值,合并为一个字符串
  409. int[] customOrder = new int[] { 0, 1, 3, 2 };
  410. string quadOutput = "2 Quad Points: ";
  411. for (int i = 0; i < customOrder.Length; i++)
  412. {
  413. quadOutput += "[" + screenSemiAuto.Quad[customOrder[i]].x + ", " + screenSemiAuto.Quad[customOrder[i]].y + "]";
  414. if (i < customOrder.Length - 1)
  415. {
  416. quadOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  417. }
  418. }
  419. Debug.Log(quadOutput);
  420. }
  421. else {
  422. Debug.LogError("screenSemiAuto 不存在!");
  423. }
  424. }
  425. #region 绘制线段部分
  426. //点击拖拽的开始位置
  427. public void onBeginPos(int index, Vector3 pos)
  428. {
  429. Debug.Log("pos begin: " + pos);
  430. beginPos = pos;
  431. }
  432. public void onDragPos(int index, Vector3 pos)
  433. {
  434. //设置线段的点
  435. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  436. }
  437. //点击拖拽的结束位置
  438. public void onEndPos(int index, Vector3 pos)
  439. {
  440. Debug.Log("pos end: " + pos);
  441. endPos = pos;
  442. if (beginPos == endPos) return;
  443. //Debug.Log(index+",最后的点:" + pos);
  444. //再记录一次最后的点
  445. SetLinePos();
  446. }
  447. //同步设置图片对应的位置到line
  448. public void SetLinePos()
  449. {
  450. //记录一个操作点的操作位置
  451. AddOldLinePosition();
  452. //设置线段的点
  453. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  454. }
  455. void AddOldLinePosition()
  456. {
  457. Vector3[] v = new Vector3[4];
  458. pos1.GetWorldCorners(v);
  459. Vector3[] v1 = new Vector3[4];
  460. pos1.GetLocalCorners(v1);
  461. //for (int i = 0; i < 4; i++)
  462. //{
  463. // Debug.Log(i + " =1= " + v[i]);
  464. // Debug.Log(i + " =2= " + v1[i]);
  465. //}
  466. //记录一个操作点的操作位置
  467. List<Vector3> screenPositions = new List<Vector3>();
  468. screenPositions.Add(pos1.localPosition);
  469. screenPositions.Add(pos2.localPosition);
  470. screenPositions.Add(pos3.localPosition);
  471. screenPositions.Add(pos4.localPosition);
  472. LinePosition linePosition = new LinePosition();
  473. linePosition.index = oldLinePosition.Count;
  474. linePosition.pos = screenPositions;
  475. oldLinePosition.Add(linePosition);
  476. }
  477. //转换绘制线段的点
  478. List<Vector2> linePosConversion(Vector3 _pos1, Vector3 _pos2, Vector3 _pos3, Vector3 _pos4)
  479. {
  480. List<Vector2> _screenPositions = new List<Vector2>();
  481. //点为负数的增大 offset,正数减少 offset
  482. //Vector2 startPos1 = new Vector2(_pos1.x - pos1.rect.width * 0.5f + offset, _pos1.y - pos1.rect.height * 0.5f + offset);
  483. //Vector2 startPos2 = new Vector2(_pos2.x + pos2.rect.width * 0.5f - offset, _pos2.y - pos2.rect.height * 0.5f + offset);
  484. //Vector2 startPos3 = new Vector2(_pos3.x + pos3.rect.width * 0.5f - offset, _pos3.y + pos3.rect.height * 0.5f - offset);
  485. //Vector2 startPos4 = new Vector2(_pos4.x - pos4.rect.width * 0.5f + offset, _pos4.y + pos4.rect.height * 0.5f - offset);
  486. Vector2 startPos1 = new Vector2(_pos1.x + offset, _pos1.y + offset);
  487. Vector2 startPos2 = new Vector2(_pos2.x - offset, _pos2.y + offset);
  488. Vector2 startPos3 = new Vector2(_pos3.x - offset, _pos3.y - offset);
  489. Vector2 startPos4 = new Vector2(_pos4.x + offset, _pos4.y - offset);
  490. _screenPositions.Add(startPos1);
  491. _screenPositions.Add(startPos2);
  492. _screenPositions.Add(startPos3);
  493. _screenPositions.Add(startPos4);
  494. return _screenPositions;
  495. }
  496. void SetRectanglePoints(List<Vector2> screenPositions)
  497. {
  498. line.SetLine(screenPositions);
  499. }
  500. //撤回上一个元素
  501. public void onRecall()
  502. {
  503. // 获取并删除最后一个元素,并且保留一个元素
  504. if (oldLinePosition.Count > 1) // 确保列表不为空
  505. {
  506. // 获取回退的那个元素点
  507. LinePosition lastElement_second = oldLinePosition[oldLinePosition.Count - 2];
  508. // 获取最后一个元素
  509. //LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  510. //Debug.Log(JsonUtility.ToJson(lastElement) + " = " + oldLinePosition.Count);
  511. oldLinePosition.RemoveAt(oldLinePosition.Count - 1); // 删除最后一个元素
  512. pos1.localPosition = lastElement_second.pos[0];
  513. pos2.localPosition = lastElement_second.pos[1];
  514. pos3.localPosition = lastElement_second.pos[2];
  515. pos4.localPosition = lastElement_second.pos[3];
  516. //设置线段的点
  517. SetRectanglePoints(linePosConversion(lastElement_second.pos[0], lastElement_second.pos[1], lastElement_second.pos[2], lastElement_second.pos[3]));
  518. }
  519. }
  520. //是不是从Demo界面进入该页面的
  521. public bool enterFromInfraredDemo { get; set; } = false;
  522. //是否从测试场景进入
  523. public bool enterFromZimWebCamera { get; set; } = false;
  524. //确认修改
  525. public void onConfirmation()
  526. {
  527. if (enterFromZimWebCamera)
  528. {
  529. ConfirmScreenLocateManualTest();
  530. if (oldLinePosition.Count > 1) // 确保列表不为空
  531. {
  532. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  533. oldLinePosition.Clear();
  534. oldLinePosition.Add(lastElement);
  535. }
  536. SaveLocalPos();
  537. AudioMgr.ins.PlayBtn();
  538. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  539. return;
  540. }
  541. if (!ConfirmScreenLocateManual()) return;
  542. if (oldLinePosition.Count > 1) // 确保列表不为空
  543. {
  544. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  545. oldLinePosition.Clear();
  546. oldLinePosition.Add(lastElement);
  547. }
  548. if (InfraredDemo.running)
  549. {
  550. //跳转入界面
  551. AudioMgr.ins.PlayBtn();
  552. if (!enterFromInfraredDemo)
  553. {
  554. //每次初始化重置一下引导
  555. InfraredDemo._ins.resetInfraredPlayerPrefs();
  556. //GameObject connectGuidanceView = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_ConnectGuidanceView);
  557. //connectGuidanceView.GetComponent<ConnectGuidanceView>().showTextipInfrared();
  558. if (!PlayerPrefs.HasKey("hideInfraredBowAndArrow"))
  559. {
  560. //如果是红外连接成功,记录一个tag
  561. PlayerPrefs.SetInt("hideInfraredBowAndArrow", 1);
  562. }
  563. onEnterInfrared();
  564. }
  565. else {
  566. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  567. }
  568. }
  569. //存储一次节点
  570. SaveLocalPos();
  571. }
  572. //重置位置
  573. public void onReset()
  574. {
  575. oldLinePosition.Clear();
  576. // 获取屏幕的四个角的像素坐标
  577. Vector2 bottomLeft = new Vector2(0, 0);
  578. // 将屏幕像素坐标转换为 Canvas 的局部坐标
  579. Vector2 localBottomLeft;
  580. RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, bottomLeft, null, out localBottomLeft);
  581. // 打印结果
  582. Debug.Log("Local Bottom Left: " + localBottomLeft);
  583. //int _x = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.x) - 120), _y = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.y) - 77);
  584. int _x = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.x)), _y = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.y));
  585. pos1.anchoredPosition = new Vector3(-_x, -_y, 0); //Bottom Left
  586. pos2.anchoredPosition = new Vector3(_x, -_y, 0); //Bottom Right
  587. pos3.anchoredPosition = new Vector3(_x, _y, 0); //Top Right
  588. pos4.anchoredPosition = new Vector3(-_x, _y, 0); //Top Left
  589. //pos1.anchoredPosition = new Vector3(_x, _y, 0);
  590. //pos2.anchoredPosition = new Vector3(-_x, _y, 0);
  591. //pos3.anchoredPosition = new Vector3(-_x, -_y, 0);
  592. //pos4.anchoredPosition = new Vector3(_x, -_y, 0);
  593. //设置一次位置
  594. SetLinePos();
  595. btnRecordInfrared.Reset();
  596. ScreenLocate.Main.ScreenIdentification.ClearQuadCache();
  597. if (enterFromZimWebCamera)
  598. {
  599. ScreenLocate.Main.ScreenQuad.gameObject.SetActive(false);
  600. ScreenLocate.Main.UILineGenerator.Points = new Vector2[0];
  601. }
  602. }
  603. /// <summary>
  604. /// 标准四个点
  605. /// </summary>
  606. /// <param name="index"></param>
  607. /// <param name="pos"></param>
  608. public void onManualNewPos(int index, Vector3 pos)
  609. {
  610. Debug.Log("pos end: " + pos);
  611. if (index == 0)
  612. pos1.localPosition = pos;
  613. else if (index == 1)
  614. pos2.localPosition = pos;
  615. else if (index == 2)
  616. pos3.localPosition = pos;
  617. else if (index == 3)
  618. pos4.localPosition = pos;
  619. //再记录一次最后的点
  620. SetLinePos();
  621. }
  622. /// <summary>
  623. /// 处理新流程,先记录手动,然后到自动识别处理
  624. /// </summary>
  625. public void onManualToAutomatic() {
  626. if (enterFromZimWebCamera)
  627. {
  628. ConfirmScreenLocateManualTest();
  629. if (oldLinePosition.Count > 1) // 确保列表不为空
  630. {
  631. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  632. oldLinePosition.Clear();
  633. oldLinePosition.Add(lastElement);
  634. }
  635. SaveLocalPos();
  636. //到自动
  637. OnClick_Auto();
  638. return;
  639. }
  640. if (!ConfirmScreenLocateManual()) {
  641. Debug.LogError("ConfirmScreenLocateManual is false!");
  642. return;
  643. }
  644. if (oldLinePosition.Count > 1) // 确保列表不为空
  645. {
  646. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  647. oldLinePosition.Clear();
  648. oldLinePosition.Add(lastElement);
  649. }
  650. //存储一次节点
  651. SaveLocalPos();
  652. bAuto = true;
  653. doLocateAuto = true;
  654. //自动校准
  655. InfraredDemo.infraredCameraHelper.EnterScreenLocateManualAuto();
  656. }
  657. #endregion
  658. List<Vector2> _locatePointList = new();
  659. float _texWidth;
  660. float _texHeight;
  661. void RecordLocatePoint(RectTransform p, Vector2 pivot)
  662. {
  663. Vector2 pos = JCUnityLib.RectTransformUtils.GetPositionByPivot(p, pivot);
  664. pos.x = Mathf.Clamp01(pos.x / Screen.width);
  665. pos.y = Mathf.Clamp01(pos.y / Screen.height);
  666. _locatePointList.Add(pos);
  667. }
  668. bool ConfirmScreenLocateManual()
  669. {
  670. if (InfraredDemo.running)
  671. {
  672. //渲染截图
  673. Texture2D texture2D = InfraredDemo.infraredCameraHelper.EnterScreenLocateManual();
  674. if (texture2D == null)
  675. {
  676. Debug.Log("EnterScreenLocateManual = null");
  677. InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(null);
  678. return false;
  679. }
  680. _locatePointList.Clear();
  681. _texWidth = texture2D.width;
  682. _texHeight = texture2D.height;
  683. RecordLocatePoint(pos1, new Vector2(0, 0));
  684. RecordLocatePoint(pos2, new Vector2(1, 0));
  685. RecordLocatePoint(pos3, new Vector2(1, 1));
  686. RecordLocatePoint(pos4, new Vector2(0, 1));
  687. //RecordLocatePoint(pos1, new Vector2(0.5f, 0.5f));
  688. //RecordLocatePoint(pos2, new Vector2(0.5f, 0.5f));
  689. //RecordLocatePoint(pos3, new Vector2(0.5f, 0.5f));
  690. //RecordLocatePoint(pos4, new Vector2(0.5f, 0.5f));
  691. InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(_locatePointList);
  692. FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, 1, 1);
  693. //同步数据
  694. ScreenLocate.quadUnityVectorList.Clear();
  695. ScreenLocate.quadUnityVectorList.Add(_locatePointList[0]);
  696. ScreenLocate.quadUnityVectorList.Add(_locatePointList[1]);
  697. //两个点切换,顺序不一样
  698. ScreenLocate.quadUnityVectorList.Add(_locatePointList[3]);
  699. ScreenLocate.quadUnityVectorList.Add(_locatePointList[2]);
  700. ScreenLocate.SaveScreenLocateVectorList();
  701. return true;
  702. }
  703. return false;
  704. }
  705. void ConfirmScreenLocateManualTest()
  706. {
  707. //渲染截图
  708. ScreenLocate _screenLocate = FindAnyObjectByType<ScreenLocate>();
  709. Texture2D texture2D = _screenLocate.EnterScreenLocateManual();
  710. if (texture2D == null)
  711. {
  712. _screenLocate.QuitScreenLocateManual(null);
  713. return;
  714. }
  715. _locatePointList.Clear();
  716. _texWidth = texture2D.width;
  717. _texHeight = texture2D.height;
  718. RecordLocatePoint(pos1, new Vector2(0, 0));
  719. RecordLocatePoint(pos2, new Vector2(1, 0));
  720. RecordLocatePoint(pos3, new Vector2(1, 1));
  721. RecordLocatePoint(pos4, new Vector2(0, 1));
  722. _screenLocate.QuitScreenLocateManual(_locatePointList);
  723. //FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, _texWidth, _texHeight);
  724. setPointsLocation(_locatePointList,pointsParent.gameObject,!bAuto);
  725. if (!doLocateAuto) // 设置手动定位数据
  726. setPointsManual(_locatePointList, GameObject.Find("WebCameraView/CameraImage0/ScreenQuad"));
  727. //同步数据
  728. ScreenLocate.quadUnityVectorList.Clear();
  729. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[0].x, _locatePointList[0].y));
  730. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[1].x, _locatePointList[1].y));
  731. //两个点切换,顺序不一样
  732. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[3].x, _locatePointList[3].y));
  733. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[2].x, _locatePointList[2].y));
  734. ScreenLocate.SaveScreenLocateVectorList();
  735. }
  736. void setPointsLocation(List<Vector2> targetList, GameObject pointsTF2, bool active = true)
  737. {
  738. //GameObject pointsTF2 = GameObject.Find("WebCameraView/CameraImage0/ScreenQuad");
  739. pointsTF2.SetActive(active);
  740. if (pointsTF2.transform.childCount == targetList.Count)
  741. {
  742. for (int i = 0; i < pointsTF2.transform.childCount; i++)
  743. {
  744. Transform pointTF = pointsTF2.transform.GetChild(i);
  745. Vector2 pos = targetList[i];
  746. pointTF.localPosition = pos.pixelToLocalPosition_AnchorCenter(Vector2.one, pointsTF2.GetComponent<RectTransform>().rect);
  747. pointTF.gameObject.SetActive(true);
  748. }
  749. }
  750. }
  751. void setPointsManual(List<Vector2> targetList, GameObject pointsTF2, bool active = true)
  752. {
  753. setPointsLocation(targetList, pointsTF2, active);
  754. var lo = new Vector2(-0.5f, -0.5f);
  755. ScreenLocate.Main.UILineGenerator.Points = new Vector2[4] {
  756. 2 * (targetList[0] + lo),
  757. 2 * (targetList[1] + lo),
  758. 2 * (targetList[2] + lo),
  759. 2 * (targetList[3] + lo) };
  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. }