InfraredScreenPositioningView.cs 42 KB

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