InfraredScreenPositioningView.cs 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  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. FirstUILineGenerator.Points = new Vector2[4] {
  360. 2 * (new Vector2(screenAuto.Quad[0].x/texSize.x,screenAuto.Quad[0].y/texSize.y) + lo),
  361. 2 * (new Vector2(screenAuto.Quad[1].x/texSize.x,screenAuto.Quad[1].y/texSize.y) + lo),
  362. 2 * (new Vector2(screenAuto.Quad[3].x/texSize.x,screenAuto.Quad[3].y/texSize.y) + lo),
  363. 2 * (new Vector2(screenAuto.Quad[2].x/texSize.x,screenAuto.Quad[2].y/texSize.y) + lo) };
  364. // 打印 Points 的值,合并为一个字符串
  365. string pointsOutput = "1 Points: ";
  366. for (int i = 0; i < FirstUILineGenerator.Points.Length; i++)
  367. {
  368. pointsOutput += "[" + FirstUILineGenerator.Points[i].x + ", " + FirstUILineGenerator.Points[i].y + "]";
  369. if (i < FirstUILineGenerator.Points.Length - 1)
  370. {
  371. pointsOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  372. }
  373. }
  374. Debug.Log(pointsOutput);
  375. // 打印 Quad 的值,合并为一个字符串
  376. int[] customOrder = new int[] { 0, 1, 3, 2 };
  377. string quadOutput = "1 Quad Points: ";
  378. for (int i = 0; i < customOrder.Length; i++)
  379. {
  380. quadOutput += "[" + screenAuto.Quad[customOrder[i]].x + ", " + screenAuto.Quad[customOrder[i]].y + "]";
  381. if (i < customOrder.Length - 1)
  382. {
  383. quadOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  384. }
  385. }
  386. Debug.Log(quadOutput);
  387. }
  388. else {
  389. Debug.LogError("screenAuto 不存在!");
  390. }
  391. if (screenSemiAuto != null)
  392. {
  393. SecondUILineGenerator.Points = new Vector2[4] {
  394. 2 * (new Vector2(screenSemiAuto.Quad[0].x/texSize.x,screenSemiAuto.Quad[0].y/texSize.y) + lo),
  395. 2 * (new Vector2(screenSemiAuto.Quad[1].x/texSize.x,screenSemiAuto.Quad[1].y/texSize.y) + lo),
  396. 2 * (new Vector2(screenSemiAuto.Quad[3].x/texSize.x,screenSemiAuto.Quad[3].y/texSize.y) + lo),
  397. 2 * (new Vector2(screenSemiAuto.Quad[2].x/texSize.x,screenSemiAuto.Quad[2].y/texSize.y) + lo) };
  398. // 打印 Points 的值,合并为一个字符串
  399. string pointsOutput = "2 Points: ";
  400. for (int i = 0; i < SecondUILineGenerator.Points.Length; i++)
  401. {
  402. pointsOutput += "[" + SecondUILineGenerator.Points[i].x + ", " + SecondUILineGenerator.Points[i].y + "]";
  403. if (i < SecondUILineGenerator.Points.Length - 1)
  404. {
  405. pointsOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  406. }
  407. }
  408. Debug.Log(pointsOutput);
  409. // 打印 Quad 的值,合并为一个字符串
  410. int[] customOrder = new int[] { 0, 1, 3, 2 };
  411. string quadOutput = "2 Quad Points: ";
  412. for (int i = 0; i < customOrder.Length; i++)
  413. {
  414. quadOutput += "[" + screenSemiAuto.Quad[customOrder[i]].x + ", " + screenSemiAuto.Quad[customOrder[i]].y + "]";
  415. if (i < customOrder.Length - 1)
  416. {
  417. quadOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
  418. }
  419. }
  420. Debug.Log(quadOutput);
  421. }
  422. else {
  423. Debug.LogError("screenSemiAuto 不存在!");
  424. }
  425. }
  426. #region 绘制线段部分
  427. //点击拖拽的开始位置
  428. public void onBeginPos(int index, Vector3 pos)
  429. {
  430. Debug.Log("pos begin: " + pos);
  431. beginPos = pos;
  432. }
  433. public void onDragPos(int index, Vector3 pos)
  434. {
  435. //设置线段的点
  436. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  437. }
  438. //点击拖拽的结束位置
  439. public void onEndPos(int index, Vector3 pos)
  440. {
  441. Debug.Log("pos end: " + pos);
  442. endPos = pos;
  443. if (beginPos == endPos) return;
  444. //Debug.Log(index+",最后的点:" + pos);
  445. //再记录一次最后的点
  446. SetLinePos();
  447. }
  448. //同步设置图片对应的位置到line
  449. public void SetLinePos()
  450. {
  451. //记录一个操作点的操作位置
  452. AddOldLinePosition();
  453. //设置线段的点
  454. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  455. }
  456. void AddOldLinePosition()
  457. {
  458. Vector3[] v = new Vector3[4];
  459. pos1.GetWorldCorners(v);
  460. Vector3[] v1 = new Vector3[4];
  461. pos1.GetLocalCorners(v1);
  462. //for (int i = 0; i < 4; i++)
  463. //{
  464. // Debug.Log(i + " =1= " + v[i]);
  465. // Debug.Log(i + " =2= " + v1[i]);
  466. //}
  467. //记录一个操作点的操作位置
  468. List<Vector3> screenPositions = new List<Vector3>();
  469. screenPositions.Add(pos1.localPosition);
  470. screenPositions.Add(pos2.localPosition);
  471. screenPositions.Add(pos3.localPosition);
  472. screenPositions.Add(pos4.localPosition);
  473. LinePosition linePosition = new LinePosition();
  474. linePosition.index = oldLinePosition.Count;
  475. linePosition.pos = screenPositions;
  476. oldLinePosition.Add(linePosition);
  477. }
  478. //转换绘制线段的点
  479. List<Vector2> linePosConversion(Vector3 _pos1, Vector3 _pos2, Vector3 _pos3, Vector3 _pos4)
  480. {
  481. List<Vector2> _screenPositions = new List<Vector2>();
  482. //点为负数的增大 offset,正数减少 offset
  483. //Vector2 startPos1 = new Vector2(_pos1.x - pos1.rect.width * 0.5f + offset, _pos1.y - pos1.rect.height * 0.5f + offset);
  484. //Vector2 startPos2 = new Vector2(_pos2.x + pos2.rect.width * 0.5f - offset, _pos2.y - pos2.rect.height * 0.5f + offset);
  485. //Vector2 startPos3 = new Vector2(_pos3.x + pos3.rect.width * 0.5f - offset, _pos3.y + pos3.rect.height * 0.5f - offset);
  486. //Vector2 startPos4 = new Vector2(_pos4.x - pos4.rect.width * 0.5f + offset, _pos4.y + pos4.rect.height * 0.5f - offset);
  487. Vector2 startPos1 = new Vector2(_pos1.x + offset, _pos1.y + offset);
  488. Vector2 startPos2 = new Vector2(_pos2.x - offset, _pos2.y + offset);
  489. Vector2 startPos3 = new Vector2(_pos3.x - offset, _pos3.y - offset);
  490. Vector2 startPos4 = new Vector2(_pos4.x + offset, _pos4.y - offset);
  491. _screenPositions.Add(startPos1);
  492. _screenPositions.Add(startPos2);
  493. _screenPositions.Add(startPos3);
  494. _screenPositions.Add(startPos4);
  495. return _screenPositions;
  496. }
  497. void SetRectanglePoints(List<Vector2> screenPositions)
  498. {
  499. line.SetLine(screenPositions);
  500. }
  501. //撤回上一个元素
  502. public void onRecall()
  503. {
  504. // 获取并删除最后一个元素,并且保留一个元素
  505. if (oldLinePosition.Count > 1) // 确保列表不为空
  506. {
  507. // 获取回退的那个元素点
  508. LinePosition lastElement_second = oldLinePosition[oldLinePosition.Count - 2];
  509. // 获取最后一个元素
  510. //LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  511. //Debug.Log(JsonUtility.ToJson(lastElement) + " = " + oldLinePosition.Count);
  512. oldLinePosition.RemoveAt(oldLinePosition.Count - 1); // 删除最后一个元素
  513. pos1.localPosition = lastElement_second.pos[0];
  514. pos2.localPosition = lastElement_second.pos[1];
  515. pos3.localPosition = lastElement_second.pos[2];
  516. pos4.localPosition = lastElement_second.pos[3];
  517. //设置线段的点
  518. SetRectanglePoints(linePosConversion(lastElement_second.pos[0], lastElement_second.pos[1], lastElement_second.pos[2], lastElement_second.pos[3]));
  519. }
  520. }
  521. //是不是从Demo界面进入该页面的
  522. public bool enterFromInfraredDemo { get; set; } = false;
  523. //是否从测试场景进入
  524. public bool enterFromZimWebCamera { get; set; } = false;
  525. //确认修改
  526. public void onConfirmation()
  527. {
  528. if (enterFromZimWebCamera)
  529. {
  530. ConfirmScreenLocateManualTest();
  531. if (oldLinePosition.Count > 1) // 确保列表不为空
  532. {
  533. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  534. oldLinePosition.Clear();
  535. oldLinePosition.Add(lastElement);
  536. }
  537. SaveLocalPos();
  538. AudioMgr.ins.PlayBtn();
  539. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  540. return;
  541. }
  542. if (!ConfirmScreenLocateManual()) return;
  543. if (oldLinePosition.Count > 1) // 确保列表不为空
  544. {
  545. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  546. oldLinePosition.Clear();
  547. oldLinePosition.Add(lastElement);
  548. }
  549. if (InfraredDemo.running)
  550. {
  551. //跳转入界面
  552. AudioMgr.ins.PlayBtn();
  553. if (!enterFromInfraredDemo)
  554. {
  555. //每次初始化重置一下引导
  556. InfraredDemo._ins.resetInfraredPlayerPrefs();
  557. //GameObject connectGuidanceView = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_ConnectGuidanceView);
  558. //connectGuidanceView.GetComponent<ConnectGuidanceView>().showTextipInfrared();
  559. if (!PlayerPrefs.HasKey("hideInfraredBowAndArrow"))
  560. {
  561. //如果是红外连接成功,记录一个tag
  562. PlayerPrefs.SetInt("hideInfraredBowAndArrow", 1);
  563. }
  564. onEnterInfrared();
  565. }
  566. else {
  567. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  568. }
  569. }
  570. //存储一次节点
  571. SaveLocalPos();
  572. }
  573. //重置位置
  574. public void onReset()
  575. {
  576. oldLinePosition.Clear();
  577. // 获取屏幕的四个角的像素坐标
  578. Vector2 bottomLeft = new Vector2(0, 0);
  579. // 将屏幕像素坐标转换为 Canvas 的局部坐标
  580. Vector2 localBottomLeft;
  581. RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, bottomLeft, null, out localBottomLeft);
  582. // 打印结果
  583. Debug.Log("Local Bottom Left: " + localBottomLeft);
  584. //int _x = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.x) - 120), _y = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.y) - 77);
  585. int _x = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.x)), _y = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.y));
  586. pos1.anchoredPosition = new Vector3(-_x, -_y, 0); //Bottom Left
  587. pos2.anchoredPosition = new Vector3(_x, -_y, 0); //Bottom Right
  588. pos3.anchoredPosition = new Vector3(_x, _y, 0); //Top Right
  589. pos4.anchoredPosition = new Vector3(-_x, _y, 0); //Top Left
  590. //pos1.anchoredPosition = new Vector3(_x, _y, 0);
  591. //pos2.anchoredPosition = new Vector3(-_x, _y, 0);
  592. //pos3.anchoredPosition = new Vector3(-_x, -_y, 0);
  593. //pos4.anchoredPosition = new Vector3(_x, -_y, 0);
  594. //设置一次位置
  595. SetLinePos();
  596. btnRecordInfrared.Reset();
  597. ScreenLocate.Main.ScreenIdentification.ClearQuadCache();
  598. if (enterFromZimWebCamera)
  599. {
  600. ScreenLocate.Main.ScreenQuad.gameObject.SetActive(false);
  601. ScreenLocate.Main.UILineGenerator.Points = new Vector2[0];
  602. }
  603. }
  604. /// <summary>
  605. /// 标准四个点
  606. /// </summary>
  607. /// <param name="index"></param>
  608. /// <param name="pos"></param>
  609. public void onManualNewPos(int index, Vector3 pos)
  610. {
  611. Debug.Log("pos end: " + pos);
  612. if (index == 0)
  613. pos1.localPosition = pos;
  614. else if (index == 1)
  615. pos2.localPosition = pos;
  616. else if (index == 2)
  617. pos3.localPosition = pos;
  618. else if (index == 3)
  619. pos4.localPosition = pos;
  620. //再记录一次最后的点
  621. SetLinePos();
  622. }
  623. /// <summary>
  624. /// 处理新流程,先记录手动,然后到自动识别处理
  625. /// </summary>
  626. public void onManualToAutomatic() {
  627. if (enterFromZimWebCamera)
  628. {
  629. ConfirmScreenLocateManualTest();
  630. if (oldLinePosition.Count > 1) // 确保列表不为空
  631. {
  632. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  633. oldLinePosition.Clear();
  634. oldLinePosition.Add(lastElement);
  635. }
  636. SaveLocalPos();
  637. //到自动
  638. OnClick_Auto();
  639. return;
  640. }
  641. if (!ConfirmScreenLocateManual()) {
  642. Debug.LogError("ConfirmScreenLocateManual is false!");
  643. return;
  644. }
  645. if (oldLinePosition.Count > 1) // 确保列表不为空
  646. {
  647. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  648. oldLinePosition.Clear();
  649. oldLinePosition.Add(lastElement);
  650. }
  651. //存储一次节点
  652. SaveLocalPos();
  653. bAuto = true;
  654. doLocateAuto = true;
  655. //自动校准
  656. InfraredDemo.infraredCameraHelper.EnterScreenLocateManualAuto();
  657. }
  658. #endregion
  659. List<Vector2> _locatePointList = new();
  660. float _texWidth;
  661. float _texHeight;
  662. void RecordLocatePoint(RectTransform p, Vector2 pivot)
  663. {
  664. Vector2 pos = JCUnityLib.RectTransformUtils.GetPositionByPivot(p, pivot);
  665. pos.x = Mathf.Clamp01(pos.x / Screen.width);
  666. pos.y = Mathf.Clamp01(pos.y / Screen.height);
  667. _locatePointList.Add(pos);
  668. }
  669. bool ConfirmScreenLocateManual()
  670. {
  671. if (InfraredDemo.running)
  672. {
  673. //渲染截图
  674. Texture2D texture2D = InfraredDemo.infraredCameraHelper.EnterScreenLocateManual();
  675. if (texture2D == null)
  676. {
  677. Debug.Log("EnterScreenLocateManual = null");
  678. InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(null);
  679. return false;
  680. }
  681. _locatePointList.Clear();
  682. _texWidth = texture2D.width;
  683. _texHeight = texture2D.height;
  684. RecordLocatePoint(pos1, new Vector2(0, 0));
  685. RecordLocatePoint(pos2, new Vector2(1, 0));
  686. RecordLocatePoint(pos3, new Vector2(1, 1));
  687. RecordLocatePoint(pos4, new Vector2(0, 1));
  688. //RecordLocatePoint(pos1, new Vector2(0.5f, 0.5f));
  689. //RecordLocatePoint(pos2, new Vector2(0.5f, 0.5f));
  690. //RecordLocatePoint(pos3, new Vector2(0.5f, 0.5f));
  691. //RecordLocatePoint(pos4, new Vector2(0.5f, 0.5f));
  692. InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(_locatePointList);
  693. FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, 1, 1);
  694. //同步数据
  695. ScreenLocate.quadUnityVectorList.Clear();
  696. ScreenLocate.quadUnityVectorList.Add(_locatePointList[0]);
  697. ScreenLocate.quadUnityVectorList.Add(_locatePointList[1]);
  698. //两个点切换,顺序不一样
  699. ScreenLocate.quadUnityVectorList.Add(_locatePointList[3]);
  700. ScreenLocate.quadUnityVectorList.Add(_locatePointList[2]);
  701. ScreenLocate.SaveScreenLocateVectorList();
  702. return true;
  703. }
  704. return false;
  705. }
  706. void ConfirmScreenLocateManualTest()
  707. {
  708. //渲染截图
  709. ScreenLocate _screenLocate = FindAnyObjectByType<ScreenLocate>();
  710. Texture2D texture2D = _screenLocate.EnterScreenLocateManual();
  711. if (texture2D == null)
  712. {
  713. _screenLocate.QuitScreenLocateManual(null);
  714. return;
  715. }
  716. _locatePointList.Clear();
  717. _texWidth = texture2D.width;
  718. _texHeight = texture2D.height;
  719. RecordLocatePoint(pos1, new Vector2(0, 0));
  720. RecordLocatePoint(pos2, new Vector2(1, 0));
  721. RecordLocatePoint(pos3, new Vector2(1, 1));
  722. RecordLocatePoint(pos4, new Vector2(0, 1));
  723. _screenLocate.QuitScreenLocateManual(_locatePointList);
  724. //FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, _texWidth, _texHeight);
  725. setPointsLocation(_locatePointList,pointsParent.gameObject,!bAuto);
  726. if (!doLocateAuto) // 设置手动定位数据
  727. setPointsManual(_locatePointList, GameObject.Find("WebCameraView/CameraImage0/ScreenQuad"));
  728. //同步数据
  729. ScreenLocate.quadUnityVectorList.Clear();
  730. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[0].x, _locatePointList[0].y));
  731. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[1].x, _locatePointList[1].y));
  732. //两个点切换,顺序不一样
  733. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[3].x, _locatePointList[3].y));
  734. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[2].x, _locatePointList[2].y));
  735. ScreenLocate.SaveScreenLocateVectorList();
  736. }
  737. void setPointsLocation(List<Vector2> targetList, GameObject pointsTF2, bool active = true)
  738. {
  739. //GameObject pointsTF2 = GameObject.Find("WebCameraView/CameraImage0/ScreenQuad");
  740. pointsTF2.SetActive(active);
  741. if (pointsTF2.transform.childCount == targetList.Count)
  742. {
  743. for (int i = 0; i < pointsTF2.transform.childCount; i++)
  744. {
  745. Transform pointTF = pointsTF2.transform.GetChild(i);
  746. Vector2 pos = targetList[i];
  747. pointTF.localPosition = pos.pixelToLocalPosition_AnchorCenter(Vector2.one, pointsTF2.GetComponent<RectTransform>().rect);
  748. pointTF.gameObject.SetActive(true);
  749. }
  750. }
  751. }
  752. void setPointsManual(List<Vector2> targetList, GameObject pointsTF2, bool active = true)
  753. {
  754. setPointsLocation(targetList, pointsTF2, active);
  755. var lo = new Vector2(-0.5f, -0.5f);
  756. ScreenLocate.Main.UILineGenerator.Points = new Vector2[4] {
  757. 2 * (targetList[0] + lo),
  758. 2 * (targetList[1] + lo),
  759. 2 * (targetList[2] + lo),
  760. 2 * (targetList[3] + lo) };
  761. }
  762. void SaveLocalPos()
  763. {
  764. List<Vector3> screenPositions = new List<Vector3>();
  765. screenPositions.Add(pos1.anchoredPosition);
  766. screenPositions.Add(pos2.anchoredPosition);
  767. screenPositions.Add(pos3.anchoredPosition);
  768. screenPositions.Add(pos4.anchoredPosition);
  769. string saveStr = string.Join(';', screenPositions.Select(v => $"{v.x},{v.y}")); //,{v.z}
  770. Debug.Log("Local UI Position: " + saveStr);
  771. PlayerPrefs.SetString("ScreenPositioningView", saveStr);
  772. }
  773. void GetLocalPos()
  774. {
  775. string posListStr = PlayerPrefs.GetString("ScreenPositioningView", "");
  776. if (!string.IsNullOrWhiteSpace(posListStr))
  777. {
  778. List<Vector2> posList = posListStr.Split(';')
  779. .Select(s =>
  780. {
  781. string[] parts = s.Split(',');
  782. return new Vector2(float.Parse(parts[0]), float.Parse(parts[1]));
  783. })
  784. .ToList();
  785. pos1.anchoredPosition = posList[0];
  786. pos2.anchoredPosition = posList[1];
  787. pos3.anchoredPosition = posList[2];
  788. pos4.anchoredPosition = posList[3];
  789. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  790. }
  791. }
  792. #region 按钮颜色切换
  793. private void OnButtonClick(Button button)
  794. {
  795. // 切换按钮颜色
  796. ColorBlock colors = button.colors;
  797. colors.normalColor = highlightedColor;
  798. colors.highlightedColor = highlightedColor;
  799. button.colors = colors;
  800. // 切换字体颜色
  801. Text buttonText = button.GetComponentInChildren<Text>();
  802. buttonText.color = highlightedTextColor;
  803. }
  804. private void ResetButton(Button button)
  805. {
  806. // 重置按钮颜色
  807. ColorBlock colors = button.colors;
  808. colors.normalColor = normalColor;
  809. colors.highlightedColor = normalColor;
  810. button.colors = colors;
  811. // 重置字体颜色
  812. Text buttonText = button.GetComponentInChildren<Text>();
  813. buttonText.color = normalTextColor;
  814. }
  815. #endregion
  816. #region 标定完成之后进入游戏界面
  817. void onEnterInfrared()
  818. {
  819. //添加进入射箭场景
  820. if (PlayerPrefs.GetInt("entry-guider-infrared-" + LoginMgr.myUserInfo.id, 0) == 0)
  821. {
  822. Debug.Log("-----进入射箭场景!");
  823. NewUserGuiderManager newUserGuiderManager = FindObjectOfType<NewUserGuiderManager>();
  824. newUserGuiderManager.curConfigKey = "开始-红外调整";
  825. //b端都是红外设备流程
  826. if (CommonConfig.StandaloneModeOrPlatformB)
  827. {
  828. newUserGuiderManager.isNewModule = true;
  829. }
  830. else {
  831. newUserGuiderManager.isNewModule = AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.HOUYIPRO || AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.Gun || AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.ARTEMISPRO;
  832. }
  833. //进入射箭场景
  834. GlobalData.pkMatchType = PKMatchType.None;
  835. GameMgr.gameType = 1;
  836. //射一箭回到连接页面,Device.view
  837. GameMgr.bNavBack = true;
  838. GameMgr.bShowDistance = false;
  839. AimHandler.ins.bInitOne = false;//true
  840. //关闭计时器
  841. GameMgr.turnOffTimer = true;
  842. //关闭左边靶子和底部速度栏
  843. GameMgr.HideTargetView = true;
  844. GameMgr.HideBillboard = true;
  845. GameMgr.ButtonCount = 0;
  846. UnityEngine.SceneManagement.SceneManager.LoadScene(
  847. "Game", UnityEngine.SceneManagement.LoadSceneMode.Single);
  848. PlayerPrefs.SetInt("entry-guider-infrared-" + LoginMgr.myUserInfo.id, 1);
  849. }
  850. else
  851. {
  852. Debug.Log("-----跳转回连接界面!");
  853. //如不是第一次,则应该跳转回连接界面
  854. ViewMgr.Instance.DestroyView<SmartArcheryView>();
  855. ViewManager2.HideView(ViewManager2.Path_ConnectGuidanceView);
  856. }
  857. }
  858. #endregion
  859. #region 最后选择算法处理UI
  860. int selected = -1;
  861. void initSelectInfo() {
  862. for (int i = 0; i < 2; i++)
  863. {
  864. int currentIndex = i; // 将 i 赋值给局部变量
  865. ResultImagesButtons[currentIndex].onClick.AddListener(() => SelectImage(currentIndex));
  866. //ResultButtons[currentIndex].onClick.AddListener(() =>
  867. //{
  868. // if (currentIndex == 0)
  869. // {
  870. // OnFirstResult();
  871. // }
  872. // else if (currentIndex == 1)
  873. // {
  874. // OnSecondResult();
  875. // }
  876. //});
  877. }
  878. //默认选择1 自动
  879. SelectImage(0);
  880. }
  881. // 添加一个选择函数
  882. void SelectImage(int selectedIndex)
  883. {
  884. //如果重复选中则跳转
  885. if (selected == selectedIndex) {
  886. if (selected == 0)
  887. {
  888. OnFirstResult();
  889. }
  890. else if (selected == 1)
  891. {
  892. OnSecondResult();
  893. }
  894. return;
  895. }
  896. // 遍历所有图片
  897. for (int i = 0; i < ResultImages.Length; i++)
  898. {
  899. // 如果是选中的 index,赋值为 ResultLines[0],否则赋值为 ResultLines[1]
  900. if (i == selectedIndex)
  901. {
  902. selected = i;
  903. ResultImages[i].sprite = ResultLines[0];
  904. ResultButtons[i].interactable = true;
  905. }
  906. else
  907. {
  908. ResultImages[i].sprite = ResultLines[1];
  909. ResultButtons[i].interactable = false;
  910. }
  911. }
  912. }
  913. //选择全自动结果后进入游戏
  914. void OnFirstResult()
  915. {
  916. ScreenLocate.Main.SelectScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.Auto);
  917. UpdateQuadUnityVectorList();
  918. onCompelete();
  919. }
  920. //选择半自动结果
  921. void OnSecondResult()
  922. {
  923. ScreenLocate.Main.SelectScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.SemiAuto);
  924. UpdateQuadUnityVectorList();
  925. onCompelete();
  926. }
  927. public void onCompelete()
  928. {
  929. if (enterFromZimWebCamera)
  930. {
  931. SaveLocalPos();
  932. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  933. return;
  934. }
  935. if (InfraredDemo.running)
  936. {
  937. //跳转入界面
  938. AudioMgr.ins.PlayBtn();
  939. if (!enterFromInfraredDemo)
  940. {
  941. //每次初始化重置一下引导
  942. InfraredDemo._ins.resetInfraredPlayerPrefs();
  943. //GameObject connectGuidanceView = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_ConnectGuidanceView);
  944. //connectGuidanceView.GetComponent<ConnectGuidanceView>().showTextipInfrared();
  945. if (!PlayerPrefs.HasKey("hideInfraredBowAndArrow"))
  946. {
  947. //如果是红外连接成功,记录一个tag
  948. PlayerPrefs.SetInt("hideInfraredBowAndArrow", 1);
  949. }
  950. onEnterInfrared();
  951. }
  952. else
  953. {
  954. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  955. }
  956. }
  957. //存储一次节点
  958. SaveLocalPos();
  959. }
  960. /// <summary>
  961. /// 选择模式后更新 quadUnityVectorList
  962. /// </summary>
  963. void UpdateQuadUnityVectorList() {
  964. ScreenLocate.Main.UpdateQuadUnityVectorList();
  965. SyncQuadUnityVectorListToPos();
  966. InfraredDemo._ins?.SetLocatePointsToCameraRender(ScreenLocate.quadUnityVectorList, 1, 1);
  967. _locatePointList.Clear();
  968. }
  969. void SyncQuadUnityVectorListToPos() {
  970. Debug.Log("[ScreenLocate] SyncQuadUnityVectorListToPos quadUnityVectorList:" + ScreenLocate.Main.PrintVector2List(ScreenLocate.quadUnityVectorList));
  971. pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  972. pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  973. pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  974. pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  975. }
  976. //这个脚本存在时候。任何切换操作都直接处理删除
  977. //void OnSceneUnloaded(Scene scene)
  978. //{
  979. // ViewManager2.HideView(ViewManager2.Path_ConnectGuidanceView);
  980. // ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  981. //}
  982. //void OnEnable()
  983. //{
  984. // SceneManager.sceneUnloaded += OnSceneUnloaded;
  985. //}
  986. //void OnDisable()
  987. //{
  988. // SceneManager.sceneUnloaded -= OnSceneUnloaded;
  989. //}
  990. #endregion
  991. }