InfraredScreenPositioningView.cs 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677
  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 enum ScreenPositioningStep {
  16. None, //
  17. Start,//开始界面
  18. AutoEnd,//自动定位结束后界面
  19. Marker,//进行标记界面
  20. Manual,//手动界面
  21. LightCtrl,//灯光调整界面
  22. Successful,//结果选择界面
  23. }
  24. public class LinePosition
  25. {
  26. public int index;
  27. public List<Vector3> pos;
  28. }
  29. public class InfraredScreenPositioningView : JCUnityLib.ViewBase
  30. {
  31. [SerializeField]
  32. RectTransform canvasRectTransform;
  33. [SerializeField]
  34. RectTransform draggableParent;
  35. [SerializeField]
  36. GameObject cameraLight;
  37. [SerializeField]
  38. RectTransform pointsParent;
  39. [SerializeField]
  40. RectTransform pos1;
  41. [SerializeField]
  42. RectTransform pos2;
  43. [SerializeField]
  44. RectTransform pos3;
  45. [SerializeField]
  46. RectTransform pos4;
  47. //画线时候的点偏移量
  48. float offset = 10;
  49. [SerializeField]
  50. Line line;
  51. List<LinePosition> oldLinePosition;
  52. Vector3 beginPos;
  53. Vector3 endPos;
  54. //相机感光部分
  55. [SerializeField]
  56. Slider slider;
  57. [SerializeField]
  58. GameObject textTip1;
  59. [SerializeField]
  60. GameObject textTip2;
  61. [SerializeField]
  62. Button btnAuto;
  63. [SerializeField]
  64. Button btnHandMovement;
  65. [SerializeField]
  66. BtnRecordInfrared btnRecordInfrared;
  67. bool bAuto = true;
  68. [SerializeField] Color normalColor = Color.white;
  69. [SerializeField] Color highlightedColor = Color.green;
  70. [SerializeField] Color normalTextColor = Color.black;
  71. [SerializeField] Color highlightedTextColor = Color.white;
  72. [Header("Common Layout Group")]
  73. [SerializeField]
  74. GameObject mask;
  75. [SerializeField]
  76. Line maskLine;
  77. [SerializeField]
  78. RawImage rawImage;
  79. [Tooltip("Demo测试时候显示")]
  80. [SerializeField]
  81. RectTransform crosshair;
  82. [SerializeField]
  83. RectTransform crosshairRed;
  84. [Tooltip("存在校准数据时候显示")]
  85. [SerializeField] LineGenerator CurrentUILineGenerator;//开始显示屏幕线条
  86. [Header("Start Layout Group")]
  87. [SerializeField]
  88. GameObject LayoutStart;
  89. [SerializeField]
  90. GameObject StartTextTip1;
  91. [SerializeField]
  92. GameObject StartTextTipHasData;
  93. [Tooltip("没有存在校准数据时候显示")]
  94. [SerializeField]
  95. GameObject BottomAutoBtn;
  96. [Tooltip("存在校准数据时候显示")]
  97. [SerializeField]
  98. GameObject BottomConfirmBtn;
  99. [Header("AutoEnd Layout Group")]
  100. [SerializeField]
  101. GameObject LayoutAutoEnd;
  102. [SerializeField] Button AutoEndConfirmBtn;
  103. [Header("LightCtrl Layout Group")]
  104. [SerializeField]
  105. GameObject LayoutLightCtrl;
  106. [SerializeField] Slider sliderContrast;
  107. //亮度
  108. [SerializeField] Slider sliderBrightness;
  109. [Header("Marker Layout Group")]
  110. [SerializeField]
  111. GameObject LayoutMarker;
  112. [SerializeField]
  113. RectTransform crosshairSmall;
  114. [Tooltip("标记页面标题提示")]
  115. [SerializeField] TextAutoLanguage2 markerTextAutoLanguage2;
  116. [SerializeField]
  117. RectTransform markerPointsParent;
  118. [SerializeField]
  119. List<RectTransform> markerPosList;
  120. [SerializeField]
  121. Line markerPointsLine;
  122. [SerializeField]
  123. PointMarker pointMarker;
  124. [Header("Manual Layout Group")]
  125. [SerializeField]
  126. GameObject LayoutManual;
  127. [Header("Successful Layout Group")]
  128. [SerializeField]
  129. GameObject LayoutSuccessful;
  130. [Tooltip("选择框的Line")]
  131. [SerializeField]
  132. Sprite[] ResultLines;// 0: 选中状态, 1: 未选中状态
  133. [Tooltip("选择框图片")]
  134. [SerializeField]
  135. Image[] ResultImages;
  136. [Tooltip("选择框按钮")]
  137. [SerializeField]
  138. Button[] ResultImagesButtons;
  139. [SerializeField]
  140. Button[] ResultButtons; // 结果选择按钮
  141. [SerializeField]
  142. RawImage CameraFirstImage; //第一个结果屏幕
  143. [SerializeField]
  144. RawImage CameraSecondImage; //第二个结果屏幕
  145. [SerializeField] LineGenerator FirstUILineGenerator;//第一个结果屏幕线条
  146. [SerializeField] LineGenerator SecondUILineGenerator;//第二个结果屏幕线条
  147. bool bMarkerFinish = false;
  148. ScreenPositioningStep perStepView = ScreenPositioningStep.None;//最后一次进入LayoutSuccessful的页面
  149. //标记当前页面情况
  150. ScreenPositioningStep curStepView = ScreenPositioningStep.Start;//设置一个开始页面
  151. InfraredDemo infraredDemo;
  152. bool doLocateAuto;
  153. int DefaultResolutionIndex;
  154. private void Awake()
  155. {
  156. //设置一次显示相机的image 的颜色
  157. rawImage.color = Color.white;
  158. offset = line.MyThickness;
  159. }
  160. void Start()
  161. {
  162. //获取InfraredDemo
  163. infraredDemo = InfraredDemo._ins;
  164. doLocateAuto = false;
  165. textTip1.SetActive(true);
  166. //设置btnAuto 高亮
  167. //OnButtonClick(btnAuto);
  168. textTip2.SetActive(false);
  169. //动态设置marker的提示语
  170. //if (BluetoothAim.ins!=null && markerTextAutoLanguage2 != null)
  171. //{
  172. // string name = "";
  173. // bool switchValue = false;
  174. // if (BluetoothAim.ins.isMainConnectToHOUYIPRO())
  175. // {
  176. // name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-HOUYIPro");
  177. // }
  178. // else if (BluetoothAim.ins.isMainConnectToARTEMISPRO())
  179. // {
  180. // name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-ArtemisPro");
  181. // }
  182. // else if (BluetoothAim.ins.isMainConnectToGun())
  183. // {
  184. // //name = TextAutoLanguage2.GetTextByKey("TitleTipMarker-M9");
  185. // switchValue = true;
  186. // }
  187. // if (switchValue)
  188. // {
  189. // markerTextAutoLanguage2.SetTextKey("TitleTipMarker-M9");
  190. // }
  191. // else {
  192. // markerTextAutoLanguage2.textFormatArgs = new object[] { name };
  193. // }
  194. //}
  195. //手动不高亮
  196. //ResetButton(btnHandMovement);
  197. //quadUnityVectorList.Clear();
  198. //quadUnityVectorList.Add(new Vector2(16.39f, 35.91f));
  199. //quadUnityVectorList.Add(new Vector2(233.35f, 51.08f));
  200. //quadUnityVectorList.Add(new Vector2(94.15f, 219.11f));
  201. //quadUnityVectorList.Add(new Vector2(243.12f, 237.40f));
  202. Debug.Log("quadUnityVectorList count:" + ScreenLocate.quadUnityVectorList.Count);
  203. if (ScreenLocate.quadUnityVectorList.Count == 0)
  204. {
  205. Debug.Log("GetLocalPos");
  206. GetLocalPos();
  207. }
  208. else
  209. {
  210. Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
  211. Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
  212. //自动识别时候四个点
  213. SyncQuadUnityVectorListToPos();
  214. //pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  215. //pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  216. //pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  217. //pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  218. }
  219. //更新start相关ui
  220. UpdateStartUI();
  221. //记录操作的位置信息
  222. oldLinePosition = new List<LinePosition>();
  223. SetLinePos();
  224. //相机感光度
  225. if (infraredDemo)
  226. {
  227. ////重置偏移量
  228. //infraredDemo.ResetCenterOffset();
  229. //////重置识别点
  230. ////ScreenLocate.Main.ScreenIdentification.ClearQuadCache();
  231. //////清除一下记录的点
  232. ////ScreenLocate.quadUnityVectorList.Clear();
  233. //infraredDemo.ResetPositioningData();
  234. slider.onValueChanged.AddListener((value) =>
  235. {
  236. infraredDemo.onSliderEvent(value);
  237. });
  238. infraredDemo.onSetSliderValue(slider);
  239. //对比度
  240. sliderContrast.onValueChanged.AddListener((value) =>
  241. {
  242. infraredDemo.onSliderCustomEvent(value, -20.0f, 20.0f);
  243. });
  244. infraredDemo.onSetSliderCustomValue(sliderContrast, -20.0f, 20.0f);
  245. //亮度
  246. sliderBrightness.onValueChanged.AddListener((value) =>
  247. {
  248. infraredDemo.onSliderCustomBrightnessEvent(value, -20.0f, 20.0f);
  249. });
  250. infraredDemo.onSetSliderCustomBrightnessValue(sliderBrightness, -20.0f, 20.0f);
  251. offset = line.MyThickness = markerPointsLine.MyThickness = infraredDemo.lineWidth.Get();
  252. //LineGenerator 比 line 宽少了大概2倍
  253. CurrentUILineGenerator.LineThickness = infraredDemo.lineWidth.Get() * 2;
  254. //扇形宽
  255. markerPointsLine.MyFanWidth = line.MyFanWidth = infraredDemo.fanWidth.Get();
  256. ZIM.Unity.QuadrilateralInCamera screen = ScreenLocate.Main.ScreenIdentification.Screen.QuadInCamera;
  257. CurrentUILineGenerator.Points = infraredDemo.ConvertQuadToPoints(screen, ScreenLocate.Main.getUVCCameraInfoSize);
  258. }
  259. else {
  260. //编辑器使用
  261. if (Application.isEditor || Application.platform == RuntimePlatform.WindowsPlayer) {
  262. slider.onValueChanged.AddListener((value) =>
  263. {
  264. double originalMin = 0.0;
  265. double originalMax = 10.0;
  266. double targetMin = -1;
  267. double targetMax = 1;
  268. // 计算转换后的值
  269. double result = InfraredDemo.MapValue(value, originalMin, originalMax, targetMin, targetMax);
  270. //int _current = (int)(result);
  271. Debug.Log("_current:" + value + " , result:" + result);
  272. ScreenLocate.Main.pcContrast = (float)result;
  273. });
  274. float v = ScreenLocate.Main.pcContrast;
  275. // 目标区间 [0, 10] 的边界值
  276. double targetMin = 0.0;
  277. double targetMax = 10.0;
  278. double originalMin = -1;
  279. double originalMax = 1;
  280. // 计算转换后的值
  281. double v2 = InfraredDemo.MapValue(v, originalMin, originalMax, targetMin, targetMax);
  282. Debug.Log("PC获取相机的感光度:" + v + " = " + v2);
  283. slider.SetValueWithoutNotify((float)v2);
  284. // 对 sliderContrast 和 sliderBrightness 调用统一的处理函数
  285. HandleSliderValueChanged(sliderContrast, value => ScreenLocate.Main.pcContrast = value, ScreenLocate.Main.pcContrast);
  286. HandleSliderValueChanged(sliderBrightness, value => ScreenLocate.Main.pcBrightness = value, ScreenLocate.Main.pcBrightness);
  287. }
  288. }
  289. initSelectInfo();
  290. //if (ScreenLocate.Main.getUVCTexture)
  291. //{
  292. // //渲染相机画面
  293. // rawImage.texture = ScreenLocate.Main.getUVCTexture;
  294. // //Debug.Log("rawImage.texture:" + rawImage.texture.name);
  295. //}
  296. //slider.onValueChanged.AddListener((value) => {
  297. // //onSliderEvent(value);
  298. // infraredDemo.SetBrightness(value);
  299. //});
  300. //slider.value = infraredDemo.brightness.Get();
  301. //修改分辨率。是否清晰一点?
  302. //DefaultResolutionIndex = infraredDemo?.ResolutionIndex ?? 0;
  303. //Debug.Log("[InfraredScreenPositioningView]开始记录进入时候的分辨率:" + DefaultResolutionIndex);
  304. //infraredDemo?.SetResolutionNew(ScreenLocate.Main.HighScreenLocateResolutionIndex);
  305. //if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked)
  306. //{
  307. // SB_EventSystem.ins.AwakenSimulateMouse();
  308. // // Debug.Log("simulate-mouse-close");
  309. //}
  310. }
  311. // 两个滑块值处理
  312. void HandleSliderValueChanged(UnityEngine.UI.Slider slider, System.Action<float> setValue, float pcValue)
  313. {
  314. double targetMin2 = -20.0;
  315. double targetMax2 = 20.0;
  316. double originalMin2 = -1;
  317. double originalMax2 = 1;
  318. slider.onValueChanged.AddListener((value) =>
  319. {
  320. double result = InfraredDemo.MapValue(value, targetMin2, targetMax2, originalMin2, originalMax2);
  321. Debug.Log($"{slider.name}_current: {value}, result: {result}");
  322. setValue((float)result);
  323. });
  324. double mappedValue = InfraredDemo.MapValue(pcValue, originalMin2, originalMax2, targetMin2, targetMax2);
  325. Debug.Log($"{slider.name} PC获取相机的感光度: {pcValue} = {mappedValue}");
  326. slider.SetValueWithoutNotify((float)mappedValue);
  327. }
  328. private void OnDestroy()
  329. {
  330. //修改回进入手动调节页面时候的分辨率
  331. //infraredDemo?.SetResolutionNew(DefaultResolutionIndex);
  332. Debug.Log("OnDestroy*********************************AwakenSimulateMouse:" + SB_EventSystem.ins.simulateMouseIsAwaked);
  333. if (SB_EventSystem.ins && !SB_EventSystem.ins.simulateMouseIsAwaked)
  334. {
  335. SB_EventSystem.ins.AwakenSimulateMouse();
  336. }
  337. }
  338. public RawImage Bg => rawImage;
  339. void Update()
  340. {
  341. if (enterFromZimWebCamera && ScreenLocate.Main.DebugOnZIMDemo) {
  342. // ZimWebCamera场景测试
  343. rawImage.texture = ScreenLocate.Main.outputRawImages[7].texture;
  344. if (ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.HasValue)
  345. {
  346. // 检测到光点
  347. var posInCanvas = ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.Value.pixelToLocalPosition_AnchorCenter(ScreenLocate.Main.CameraSize, rawImage.rectTransform.rect);
  348. crosshair.gameObject.SetActive(true);
  349. crosshair.anchoredPosition = posInCanvas;
  350. }
  351. else
  352. crosshair.gameObject.SetActive(false);
  353. //渲染相机画面
  354. CameraSecondImage.texture = rawImage.texture;
  355. CameraFirstImage.texture = rawImage.texture;
  356. }
  357. else if (InfraredDemo.running)
  358. {
  359. //渲染相机画面
  360. Texture texture = InfraredDemo.infraredCameraHelper.GetCameraTexture();
  361. if (rawImage.texture == null || texture.GetNativeTexturePtr() != rawImage.texture.GetNativeTexturePtr())
  362. {
  363. rawImage.texture = texture;
  364. //渲染相机画面
  365. CameraSecondImage.texture = rawImage.texture;
  366. CameraFirstImage.texture = rawImage.texture;
  367. }
  368. if (ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.HasValue)
  369. {
  370. // 检测到光点
  371. var posInCanvas = ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.Value.pixelToLocalPosition_AnchorCenter(ScreenLocate.Main.CameraSize, rawImage.rectTransform.rect);
  372. crosshairSmall.gameObject.SetActive(true);
  373. crosshairSmall.anchoredPosition = posInCanvas;
  374. }
  375. else
  376. crosshairSmall.gameObject.SetActive(false);
  377. //rawImage.material = InfraredDemo.infraredCameraHelper.GetCameraMaterial();
  378. //可见光调节页面出现红十字光标
  379. if (curStepView == ScreenPositioningStep.LightCtrl)
  380. {
  381. if (ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.HasValue)
  382. {
  383. // 检测到光点
  384. var posInCanvas = ScreenLocate.Main.infraredSpotBuffer[0].CameraLocation.Value.pixelToLocalPosition_AnchorCenter(ScreenLocate.Main.CameraSize, rawImage.rectTransform.rect);
  385. crosshairRed.gameObject.SetActive(true);
  386. crosshairRed.anchoredPosition = posInCanvas;
  387. }
  388. else
  389. crosshairRed.gameObject.SetActive(false);
  390. }
  391. else if (crosshairRed.gameObject.activeSelf) {
  392. crosshairRed.gameObject.SetActive(false);
  393. }
  394. }
  395. }
  396. /// <summary>
  397. /// 根据enum操作ui
  398. /// </summary>
  399. /// <param name="step"></param>
  400. public void SetScreenPositioningStepState(ScreenPositioningStep step = ScreenPositioningStep.None)
  401. {
  402. curStepView = step;
  403. AllScreenPositioningStepFalse();
  404. switch (step)
  405. {
  406. case ScreenPositioningStep.Start:
  407. maskLine.SetDrawMask(true);
  408. LayoutStart.SetActive(true);
  409. UpdateStartUI();
  410. break;
  411. case ScreenPositioningStep.AutoEnd:
  412. maskLine.SetDrawMask(true);
  413. LayoutAutoEnd.SetActive(true);
  414. pointsParent.gameObject.SetActive(false);
  415. CurrentUILineGenerator.enabled = true;
  416. if (ScreenLocate.quadUnityVectorList.Count == 0)
  417. {
  418. AutoEndConfirmBtn.interactable = false;
  419. }
  420. else
  421. {
  422. //存在数据,显示确认按钮
  423. AutoEndConfirmBtn.interactable = true;
  424. }
  425. break;
  426. case ScreenPositioningStep.LightCtrl:
  427. maskLine.SetDrawMask(false);
  428. LayoutLightCtrl.SetActive(true);
  429. CurrentUILineGenerator.enabled = true;
  430. pointsParent.gameObject.SetActive(false);
  431. //setPointsLocation(ScreenLocate.quadUnityVectorList, pointsParent.gameObject, true);
  432. break;
  433. case ScreenPositioningStep.Marker:
  434. //显示提示
  435. pointMarker.ShowHintImageParent(true);
  436. perStepView = ScreenPositioningStep.Marker;
  437. bMarkerFinish = false;
  438. maskLine.SetDrawMask(true);
  439. LayoutMarker.SetActive(true);
  440. CurrentUILineGenerator.enabled = false;
  441. pointsParent.gameObject.SetActive(false);
  442. SyncQuadUnityVectorListToMarkerPointesPos();
  443. //setPointsLocation(ScreenLocate.quadUnityVectorList, pointsParent.gameObject, true);
  444. break;
  445. case ScreenPositioningStep.Manual:
  446. SaveStartOldLinePosition();
  447. perStepView = ScreenPositioningStep.Manual;
  448. bMarkerFinish = false;
  449. LayoutManual.SetActive(true);
  450. bAuto = false;
  451. doLocateAuto = false;
  452. draggableParent.gameObject.SetActive(true);
  453. pointsParent.gameObject.SetActive(false);
  454. break;
  455. case ScreenPositioningStep.Successful:
  456. LayoutSuccessful.SetActive(true);
  457. pointsParent.gameObject.SetActive(false);
  458. CurrentUILineGenerator.enabled = false;
  459. break;
  460. }
  461. }
  462. void AllScreenPositioningStepFalse()
  463. {
  464. LayoutStart.SetActive(false);
  465. LayoutMarker.SetActive(false);
  466. LayoutManual.SetActive(false);
  467. LayoutAutoEnd.SetActive(false);
  468. LayoutLightCtrl.SetActive(false);
  469. LayoutSuccessful.SetActive(false);
  470. }
  471. /// <summary>
  472. /// 开始页面时候ui
  473. /// </summary>
  474. void UpdateStartUI() {
  475. pointsParent.gameObject.SetActive(false);
  476. CurrentUILineGenerator.enabled = true;
  477. if (ScreenLocate.quadUnityVectorList.Count == 0)
  478. {
  479. BottomConfirmBtn.SetActive(false);
  480. StartTextTip1.SetActive(true);
  481. StartTextTipHasData.SetActive(false);
  482. }
  483. else
  484. {
  485. //存在数据,显示确认按钮,确认按钮直接跳转到游戏
  486. BottomConfirmBtn.SetActive(true);
  487. StartTextTip1.SetActive(false);
  488. StartTextTipHasData.SetActive(true);
  489. }
  490. }
  491. public void OnClick_Back()
  492. {
  493. AudioMgr.ins.PlayBtn();
  494. ViewMgr.Instance.DestroyView<InfraredScreenPositioningView>();
  495. }
  496. /// <summary>
  497. /// 返回最开始页面
  498. /// </summary>
  499. public void OnClick_BackLayoutStart()
  500. {
  501. ClearPointsData();
  502. SetScreenPositioningStepState(ScreenPositioningStep.Start);
  503. }
  504. void ClearPointsData() {
  505. //重置中心点0
  506. infraredDemo.ResetCenterOffset();
  507. //清除白线数据
  508. infraredDemo.ResetPositioningData();
  509. //上面应该清空了 ScreenLocate.Main.ScreenIdentification.QuadAuto
  510. onClearCurrentUILineGenerator();
  511. }
  512. /// <summary>
  513. /// 进入环境光测试
  514. /// </summary>
  515. public void OnClick_EnterLightCtrl() {
  516. SetScreenPositioningStepState(ScreenPositioningStep.LightCtrl);
  517. }
  518. /// <summary>
  519. /// 进入屏幕标记
  520. /// </summary>
  521. public void OnClick_EnterMarker() {
  522. SetScreenPositioningStepState(ScreenPositioningStep.Marker);
  523. }
  524. /// <summary>
  525. /// successful 返回页面时候,根据ScreenPositioningStep区分
  526. /// </summary>
  527. public void OnClick_BackByScreenPositioningStep()
  528. {
  529. SetScreenPositioningStepState(ScreenPositioningStep.LightCtrl);
  530. //清空两个绘制线
  531. onClearSuccessfullLineGenerator();
  532. //if(perStepView == ScreenPositioningStep.Manual)
  533. // SetScreenPositioningStepState(ScreenPositioningStep.Manual);
  534. //else
  535. // SetScreenPositioningStepState(ScreenPositioningStep.Marker);
  536. }
  537. /// <summary>
  538. /// 直接进入游戏流程
  539. /// </summary>
  540. public void OnClick_EnterGame()
  541. {
  542. //对比确认效果。直接进入游戏引导页面
  543. EnterGame();
  544. }
  545. /// <summary>
  546. /// 进入自动流程校准操作
  547. /// </summary>
  548. public void OnClick_EnterAuto()
  549. {
  550. Debug.Log("*********** OnClick_EnterAuto ************");
  551. //自动按钮时候进入之前的校准流程
  552. ClearPointsData();
  553. OnClick_Auto();
  554. }
  555. /// <summary>
  556. /// 进入标记页面自动流程校准操作
  557. /// </summary>
  558. public void OnClick_EnterAutoByMarker()
  559. {
  560. Debug.Log("*********** OnClick_EnterAutoByMarker ************");
  561. //自动按钮时候进入之前的校准流程
  562. ClearPointsData();
  563. markerPointsLine.SetLine(new List<Vector2>());
  564. //隐藏提示
  565. pointMarker.ShowHintImageParent(false);
  566. OnClick_Auto();
  567. }
  568. /// <summary>
  569. /// 自动识别
  570. /// </summary>
  571. public void OnClick_Auto()
  572. {
  573. bAuto = true;
  574. doLocateAuto = true;
  575. //textTip1.SetActive(false);
  576. //textTip2.SetActive(true);
  577. //ResetButton(btnAuto);
  578. if (enterFromZimWebCamera)
  579. {
  580. ScreenLocate _screenLocate = FindAnyObjectByType<ScreenLocate>();
  581. _screenLocate.EnterScreenLocateManualAuto();
  582. return;
  583. }
  584. if (InfraredDemo.running)
  585. {
  586. InfraredDemo.infraredCameraHelper.EnterScreenLocateManualAuto();
  587. }
  588. }
  589. /// <summary>
  590. /// 进入手动界面
  591. /// </summary>
  592. public void OnClick_EnterManual()
  593. {
  594. SetScreenPositioningStepState(ScreenPositioningStep.Manual);
  595. }
  596. /// <summary>
  597. /// 切换成手动方式
  598. /// </summary>
  599. public void onHandMovement()
  600. {
  601. bAuto = false;
  602. doLocateAuto = false;
  603. draggableParent.gameObject.SetActive(true);
  604. pointsParent.gameObject.SetActive(false);
  605. mask.SetActive(false);
  606. cameraLight.SetActive(true);
  607. }
  608. /// <summary>
  609. /// 自动识别后同步
  610. /// </summary>
  611. public void SyncScreenPosition()
  612. {
  613. Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
  614. Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
  615. SyncQuadUnityVectorListToPos();
  616. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  617. SyncQuadUnityVectorListToMarkerPointesPos();
  618. //显示提示
  619. pointMarker.ShowHintImageParent(true);
  620. if (curStepView == ScreenPositioningStep.Start || curStepView == ScreenPositioningStep.AutoEnd) {
  621. //如果是开始页面进行自动定位的
  622. if (curStepView != ScreenPositioningStep.AutoEnd) {
  623. SetScreenPositioningStepState(ScreenPositioningStep.AutoEnd);
  624. AutoEndConfirmBtn.interactable = true;
  625. }
  626. }
  627. else if (curStepView == ScreenPositioningStep.Marker || curStepView == ScreenPositioningStep.Manual) {
  628. //显示最后结果
  629. if(bMarkerFinish) SetScreenPositioningStepState(ScreenPositioningStep.Successful);
  630. }
  631. //屏幕变化情况下。同步修改对应的line
  632. //设置两个线段
  633. QuadrilateralInCamera screenAuto = ScreenLocate.Main.ScreenIdentification.QuadAuto;
  634. QuadrilateralInCamera screenSemiAuto = ScreenLocate.Main.ScreenIdentification.QuadSemiAuto;
  635. if (screenAuto != null)
  636. {
  637. Debug.Log("[校准流程]Successful自动识别screenAuto信息 ------------ ");
  638. CurrentUILineGenerator.Points = infraredDemo.ConvertQuadToPoints(screenAuto, texSize);
  639. FirstUILineGenerator.Points = infraredDemo.ConvertQuadToPoints(screenAuto, texSize);
  640. }
  641. else
  642. {
  643. Debug.LogError("screenAuto 不存在!");
  644. }
  645. if (screenSemiAuto != null)
  646. {
  647. Debug.Log("[校准流程]Successful半自动识别screenSemiAuto信息 ------------ ");
  648. SecondUILineGenerator.Points = infraredDemo.ConvertQuadToPoints(screenSemiAuto, texSize);
  649. }
  650. else
  651. {
  652. Debug.LogError("screenSemiAuto 不存在!");
  653. }
  654. }
  655. /// <summary>
  656. /// 清空白线数据
  657. /// </summary>
  658. void onClearCurrentUILineGenerator() {
  659. if (CurrentUILineGenerator.Points.Length != 0) CurrentUILineGenerator.Points = new Vector2[0];//System.Array.Clear(CurrentUILineGenerator.Points, 0, CurrentUILineGenerator.Points.Length);
  660. }
  661. /// <summary>
  662. /// 清空最后识别的两个自动和半自动数据线
  663. /// </summary>
  664. void onClearSuccessfullLineGenerator()
  665. {
  666. if(FirstUILineGenerator.Points.Length !=0) FirstUILineGenerator.Points = new Vector2[0]; //System.Array.Clear(FirstUILineGenerator.Points, 0, FirstUILineGenerator.Points.Length);
  667. if (SecondUILineGenerator.Points.Length !=0) SecondUILineGenerator.Points = new Vector2[0]; //System.Array.Clear(SecondUILineGenerator.Points, 0, SecondUILineGenerator.Points.Length);
  668. }
  669. #region 绘制线段部分
  670. //点击拖拽的开始位置
  671. public void onBeginPos(int index, Vector3 pos)
  672. {
  673. Debug.Log("pos begin: " + pos);
  674. beginPos = pos;
  675. }
  676. public void onDragPos(int index, Vector3 pos)
  677. {
  678. //设置线段的点
  679. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  680. }
  681. //点击拖拽的结束位置
  682. public void onEndPos(int index, Vector3 pos)
  683. {
  684. Debug.Log("pos end: " + pos);
  685. endPos = pos;
  686. if (beginPos == endPos) return;
  687. //Debug.Log(index+",最后的点:" + pos);
  688. //再记录一次最后的点
  689. SetLinePos();
  690. }
  691. //同步设置图片对应的位置到line
  692. public void SetLinePos()
  693. {
  694. //记录一个操作点的操作位置
  695. AddOldLinePosition();
  696. //设置线段的点
  697. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  698. }
  699. void AddOldLinePosition()
  700. {
  701. Vector3[] v = new Vector3[4];
  702. pos1.GetWorldCorners(v);
  703. Vector3[] v1 = new Vector3[4];
  704. pos1.GetLocalCorners(v1);
  705. //for (int i = 0; i < 4; i++)
  706. //{
  707. // Debug.Log(i + " =1= " + v[i]);
  708. // Debug.Log(i + " =2= " + v1[i]);
  709. //}
  710. //记录一个操作点的操作位置
  711. List<Vector3> screenPositions = new List<Vector3>();
  712. screenPositions.Add(pos1.localPosition);
  713. screenPositions.Add(pos2.localPosition);
  714. screenPositions.Add(pos3.localPosition);
  715. screenPositions.Add(pos4.localPosition);
  716. LinePosition linePosition = new LinePosition();
  717. linePosition.index = oldLinePosition.Count;
  718. linePosition.pos = screenPositions;
  719. oldLinePosition.Add(linePosition);
  720. }
  721. /// <summary>
  722. /// 记录一个开始位置
  723. /// </summary>
  724. void SaveStartOldLinePosition() {
  725. oldLinePosition.Clear();
  726. //记录一个操作点的操作位置
  727. List<Vector3> screenPositions = new List<Vector3>();
  728. screenPositions.Add(pos1.localPosition);
  729. screenPositions.Add(pos2.localPosition);
  730. screenPositions.Add(pos3.localPosition);
  731. screenPositions.Add(pos4.localPosition);
  732. LinePosition linePosition = new LinePosition();
  733. linePosition.index = 1;
  734. linePosition.pos = screenPositions;
  735. oldLinePosition.Add(linePosition);
  736. }
  737. //转换绘制线段的点
  738. List<Vector2> linePosConversion(Vector3 _pos1, Vector3 _pos2, Vector3 _pos3, Vector3 _pos4)
  739. {
  740. List<Vector2> _screenPositions = new List<Vector2>();
  741. //点为负数的增大 offset,正数减少 offset
  742. //Vector2 startPos1 = new Vector2(_pos1.x - pos1.rect.width * 0.5f + offset, _pos1.y - pos1.rect.height * 0.5f + offset);
  743. //Vector2 startPos2 = new Vector2(_pos2.x + pos2.rect.width * 0.5f - offset, _pos2.y - pos2.rect.height * 0.5f + offset);
  744. //Vector2 startPos3 = new Vector2(_pos3.x + pos3.rect.width * 0.5f - offset, _pos3.y + pos3.rect.height * 0.5f - offset);
  745. //Vector2 startPos4 = new Vector2(_pos4.x - pos4.rect.width * 0.5f + offset, _pos4.y + pos4.rect.height * 0.5f - offset);
  746. Vector2 startPos1 = new Vector2(_pos1.x + offset, _pos1.y + offset);
  747. Vector2 startPos2 = new Vector2(_pos2.x - offset, _pos2.y + offset);
  748. Vector2 startPos3 = new Vector2(_pos3.x - offset, _pos3.y - offset);
  749. Vector2 startPos4 = new Vector2(_pos4.x + offset, _pos4.y - offset);
  750. _screenPositions.Add(startPos1);
  751. _screenPositions.Add(startPos2);
  752. _screenPositions.Add(startPos3);
  753. _screenPositions.Add(startPos4);
  754. return _screenPositions;
  755. }
  756. void SetRectanglePoints(List<Vector2> screenPositions)
  757. {
  758. line.SetLine(screenPositions);
  759. }
  760. //撤回上一个元素
  761. public void onRecall()
  762. {
  763. // 获取并删除最后一个元素,并且保留一个元素
  764. if (oldLinePosition.Count > 1) // 确保列表不为空
  765. {
  766. // 获取回退的那个元素点
  767. LinePosition lastElement_second = oldLinePosition[oldLinePosition.Count - 2];
  768. // 获取最后一个元素
  769. //LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  770. //Debug.Log(JsonUtility.ToJson(lastElement) + " = " + oldLinePosition.Count);
  771. oldLinePosition.RemoveAt(oldLinePosition.Count - 1); // 删除最后一个元素
  772. pos1.localPosition = lastElement_second.pos[0];
  773. pos2.localPosition = lastElement_second.pos[1];
  774. pos3.localPosition = lastElement_second.pos[2];
  775. pos4.localPosition = lastElement_second.pos[3];
  776. //设置线段的点
  777. SetRectanglePoints(linePosConversion(lastElement_second.pos[0], lastElement_second.pos[1], lastElement_second.pos[2], lastElement_second.pos[3]));
  778. }
  779. }
  780. //是不是从Demo界面进入该页面的
  781. public bool enterFromInfraredDemo { get; set; } = false;
  782. //是否从测试场景进入
  783. public bool enterFromZimWebCamera { get; set; } = false;
  784. //确认修改
  785. public void onConfirmation()
  786. {
  787. if (enterFromZimWebCamera)
  788. {
  789. ConfirmScreenLocateManualTest();
  790. if (oldLinePosition.Count > 1) // 确保列表不为空
  791. {
  792. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  793. oldLinePosition.Clear();
  794. oldLinePosition.Add(lastElement);
  795. }
  796. SaveLocalPos();
  797. AudioMgr.ins.PlayBtn();
  798. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  799. return;
  800. }
  801. if (!ConfirmScreenLocateManual()) return;
  802. if (oldLinePosition.Count > 1) // 确保列表不为空
  803. {
  804. //LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  805. oldLinePosition.Clear();
  806. //oldLinePosition.Add(lastElement);
  807. }
  808. if (InfraredDemo.running)
  809. {
  810. //跳转入界面
  811. AudioMgr.ins.PlayBtn();
  812. if (!enterFromInfraredDemo)
  813. {
  814. //每次初始化重置一下引导
  815. infraredDemo.resetInfraredPlayerPrefs();
  816. //GameObject connectGuidanceView = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_ConnectGuidanceView);
  817. //connectGuidanceView.GetComponent<ConnectGuidanceView>().showTextipInfrared();
  818. if (!PlayerPrefs.HasKey("hideInfraredBowAndArrow"))
  819. {
  820. //如果是红外连接成功,记录一个tag
  821. PlayerPrefs.SetInt("hideInfraredBowAndArrow", 1);
  822. }
  823. onEnterInfrared();
  824. }
  825. else {
  826. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  827. }
  828. }
  829. //存储一次节点
  830. SaveLocalPos();
  831. }
  832. //重置位置
  833. public void onReset()
  834. {
  835. oldLinePosition.Clear();
  836. // 获取屏幕的四个角的像素坐标
  837. Vector2 bottomLeft = new Vector2(0, 0);
  838. // 将屏幕像素坐标转换为 Canvas 的局部坐标
  839. Vector2 localBottomLeft;
  840. RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRectTransform, bottomLeft, null, out localBottomLeft);
  841. // 打印结果
  842. Debug.Log("Local Bottom Left: " + localBottomLeft);
  843. //int _x = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.x) - 120), _y = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.y) - 77);
  844. int _x = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.x)), _y = Mathf.FloorToInt(Mathf.Abs(localBottomLeft.y));
  845. pos1.anchoredPosition = new Vector3(-_x, -_y, 0); //Bottom Left
  846. pos2.anchoredPosition = new Vector3(_x, -_y, 0); //Bottom Right
  847. pos3.anchoredPosition = new Vector3(_x, _y, 0); //Top Right
  848. pos4.anchoredPosition = new Vector3(-_x, _y, 0); //Top Left
  849. //pos1.anchoredPosition = new Vector3(_x, _y, 0);
  850. //pos2.anchoredPosition = new Vector3(-_x, _y, 0);
  851. //pos3.anchoredPosition = new Vector3(-_x, -_y, 0);
  852. //pos4.anchoredPosition = new Vector3(_x, -_y, 0);
  853. //设置一次位置
  854. SetLinePos();
  855. btnRecordInfrared.Reset();
  856. ScreenLocate.Main.ScreenIdentification.ClearQuadCache();
  857. if (enterFromZimWebCamera)
  858. {
  859. ScreenLocate.Main.ScreenQuad.gameObject.SetActive(false);
  860. ScreenLocate.Main.UILineGenerator.Points = new Vector2[0];
  861. }
  862. if (curStepView == ScreenPositioningStep.Start || curStepView == ScreenPositioningStep.AutoEnd)
  863. {
  864. //如果是开始页面进行自动定位的失败的
  865. if (curStepView != ScreenPositioningStep.AutoEnd) {
  866. SetScreenPositioningStepState(ScreenPositioningStep.AutoEnd);
  867. AutoEndConfirmBtn.interactable = false;
  868. }
  869. }
  870. }
  871. /// <summary>
  872. /// 标准四个点
  873. /// </summary>
  874. /// <param name="index"></param>
  875. /// <param name="pos"></param>
  876. public void onManualNewPos(int index, Vector3 pos)
  877. {
  878. Debug.Log("pos end: " + pos);
  879. if (index == 0)
  880. pos1.localPosition = pos;
  881. else if (index == 1)
  882. pos2.localPosition = pos;
  883. else if (index == 2)
  884. pos3.localPosition = pos;
  885. else if (index == 3)
  886. pos4.localPosition = pos;
  887. //再记录一次最后的点
  888. SetLinePos();
  889. }
  890. /// <summary>
  891. /// 处理新流程,先记录手动,然后到自动识别处理
  892. /// </summary>
  893. public void onManualToAutomatic() {
  894. if (enterFromZimWebCamera)
  895. {
  896. ConfirmScreenLocateManualTest();
  897. if (oldLinePosition.Count > 1) // 确保列表不为空
  898. {
  899. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  900. oldLinePosition.Clear();
  901. oldLinePosition.Add(lastElement);
  902. }
  903. SaveLocalPos();
  904. //到自动
  905. OnClick_Auto();
  906. return;
  907. }
  908. if (!ConfirmScreenLocateManual()) {
  909. Debug.LogError("ConfirmScreenLocateManual is false!");
  910. return;
  911. }
  912. if (oldLinePosition.Count > 1) // 确保列表不为空
  913. {
  914. LinePosition lastElement = oldLinePosition[oldLinePosition.Count - 1];
  915. oldLinePosition.Clear();
  916. oldLinePosition.Add(lastElement);
  917. }
  918. //存储一次节点
  919. SaveLocalPos();
  920. Debug.Log("[校准流程]进入自动校准数据,调用EnterScreenLocateManualAuto");
  921. bAuto = true;
  922. doLocateAuto = true;
  923. //自动校准
  924. InfraredDemo.infraredCameraHelper.EnterScreenLocateManualAuto();
  925. }
  926. /// <summary>
  927. /// PointMarker 调用
  928. /// </summary>
  929. public void onFinishManualToAutomatic() {
  930. bMarkerFinish = true;
  931. onManualToAutomatic();
  932. }
  933. #endregion
  934. List<Vector2> _locatePointList = new();
  935. float _texWidth;
  936. float _texHeight;
  937. void RecordLocatePoint(RectTransform p, Vector2 pivot)
  938. {
  939. Vector2 pos = JCUnityLib.RectTransformUtils.GetPositionByPivot(p, pivot);
  940. pos.x = Mathf.Clamp01(pos.x / Screen.width);
  941. pos.y = Mathf.Clamp01(pos.y / Screen.height);
  942. _locatePointList.Add(pos);
  943. }
  944. bool ConfirmScreenLocateManual()
  945. {
  946. if (InfraredDemo.running)
  947. {
  948. //渲染截图
  949. Texture2D texture2D = InfraredDemo.infraredCameraHelper.EnterScreenLocateManual();
  950. if (texture2D == null)
  951. {
  952. Debug.Log("EnterScreenLocateManual = null");
  953. InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(null);
  954. return false;
  955. }
  956. _locatePointList.Clear();
  957. _texWidth = texture2D.width;
  958. _texHeight = texture2D.height;
  959. RecordLocatePoint(pos1, new Vector2(0, 0));
  960. RecordLocatePoint(pos2, new Vector2(1, 0));
  961. RecordLocatePoint(pos3, new Vector2(1, 1));
  962. RecordLocatePoint(pos4, new Vector2(0, 1));
  963. //RecordLocatePoint(pos1, new Vector2(0.5f, 0.5f));
  964. //RecordLocatePoint(pos2, new Vector2(0.5f, 0.5f));
  965. //RecordLocatePoint(pos3, new Vector2(0.5f, 0.5f));
  966. //RecordLocatePoint(pos4, new Vector2(0.5f, 0.5f));
  967. InfraredDemo.infraredCameraHelper.QuitScreenLocateManual(_locatePointList);
  968. FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, 1, 1);
  969. //同步数据
  970. ScreenLocate.quadUnityVectorList.Clear();
  971. ScreenLocate.quadUnityVectorList.Add(_locatePointList[0]);
  972. ScreenLocate.quadUnityVectorList.Add(_locatePointList[1]);
  973. //两个点切换,顺序不一样
  974. ScreenLocate.quadUnityVectorList.Add(_locatePointList[3]);
  975. ScreenLocate.quadUnityVectorList.Add(_locatePointList[2]);
  976. ScreenLocate.SaveScreenLocateVectorList();
  977. Debug.Log("[校准流程]设置QuitScreenLocateManual()手动数据,保存quadUnityVectorList");
  978. return true;
  979. }
  980. return false;
  981. }
  982. void ConfirmScreenLocateManualTest()
  983. {
  984. //渲染截图
  985. ScreenLocate _screenLocate = FindAnyObjectByType<ScreenLocate>();
  986. Texture2D texture2D = _screenLocate.EnterScreenLocateManual();
  987. if (texture2D == null)
  988. {
  989. _screenLocate.QuitScreenLocateManual(null);
  990. return;
  991. }
  992. _locatePointList.Clear();
  993. _texWidth = texture2D.width;
  994. _texHeight = texture2D.height;
  995. RecordLocatePoint(pos1, new Vector2(0, 0));
  996. RecordLocatePoint(pos2, new Vector2(1, 0));
  997. RecordLocatePoint(pos3, new Vector2(1, 1));
  998. RecordLocatePoint(pos4, new Vector2(0, 1));
  999. _screenLocate.QuitScreenLocateManual(_locatePointList);
  1000. //FindObjectOfType<InfraredDemo>().SetLocatePointsToCameraRender(_locatePointList, _texWidth, _texHeight);
  1001. setPointsLocation(_locatePointList,pointsParent.gameObject,!bAuto);
  1002. if (!doLocateAuto) // 设置手动定位数据
  1003. setPointsManual(_locatePointList, GameObject.Find("WebCameraView/CameraImage0/ScreenQuad"));
  1004. //同步数据
  1005. ScreenLocate.quadUnityVectorList.Clear();
  1006. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[0].x, _locatePointList[0].y));
  1007. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[1].x, _locatePointList[1].y));
  1008. //两个点切换,顺序不一样
  1009. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[3].x, _locatePointList[3].y));
  1010. ScreenLocate.quadUnityVectorList.Add(new Vector2(_locatePointList[2].x, _locatePointList[2].y));
  1011. ScreenLocate.SaveScreenLocateVectorList();
  1012. }
  1013. void setPointsLocation(List<Vector2> targetList, GameObject pointsTF2, bool active = true)
  1014. {
  1015. //GameObject pointsTF2 = GameObject.Find("WebCameraView/CameraImage0/ScreenQuad");
  1016. pointsTF2.SetActive(active);
  1017. if (pointsTF2.transform.childCount == targetList.Count)
  1018. {
  1019. for (int i = 0; i < pointsTF2.transform.childCount; i++)
  1020. {
  1021. Transform pointTF = pointsTF2.transform.GetChild(i);
  1022. Vector2 pos = targetList[i];
  1023. pointTF.localPosition = pos.pixelToLocalPosition_AnchorCenter(Vector2.one, pointsTF2.GetComponent<RectTransform>().rect);
  1024. pointTF.gameObject.SetActive(true);
  1025. }
  1026. }
  1027. }
  1028. void setPointsManual(List<Vector2> targetList, GameObject pointsTF2, bool active = true)
  1029. {
  1030. setPointsLocation(targetList, pointsTF2, active);
  1031. var lo = new Vector2(-0.5f, -0.5f);
  1032. ScreenLocate.Main.UILineGenerator.Points = new Vector2[4] {
  1033. 2 * (targetList[0] + lo),
  1034. 2 * (targetList[1] + lo),
  1035. 2 * (targetList[2] + lo),
  1036. 2 * (targetList[3] + lo) };
  1037. }
  1038. void SaveLocalPos()
  1039. {
  1040. List<Vector3> screenPositions = new List<Vector3>();
  1041. screenPositions.Add(pos1.anchoredPosition);
  1042. screenPositions.Add(pos2.anchoredPosition);
  1043. screenPositions.Add(pos3.anchoredPosition);
  1044. screenPositions.Add(pos4.anchoredPosition);
  1045. string saveStr = string.Join(';', screenPositions.Select(v => $"{v.x},{v.y}")); //,{v.z}
  1046. Debug.Log("Local UI Position: " + saveStr);
  1047. PlayerPrefs.SetString("ScreenPositioningView", saveStr);
  1048. }
  1049. void GetLocalPos()
  1050. {
  1051. string posListStr = PlayerPrefs.GetString("ScreenPositioningView", "");
  1052. if (!string.IsNullOrWhiteSpace(posListStr))
  1053. {
  1054. List<Vector2> posList = posListStr.Split(';')
  1055. .Select(s =>
  1056. {
  1057. string[] parts = s.Split(',');
  1058. return new Vector2(float.Parse(parts[0]), float.Parse(parts[1]));
  1059. })
  1060. .ToList();
  1061. pos1.anchoredPosition = posList[0];
  1062. pos2.anchoredPosition = posList[1];
  1063. pos3.anchoredPosition = posList[2];
  1064. pos4.anchoredPosition = posList[3];
  1065. SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
  1066. }
  1067. }
  1068. #region 按钮颜色切换
  1069. private void OnButtonClick(Button button)
  1070. {
  1071. // 切换按钮颜色
  1072. ColorBlock colors = button.colors;
  1073. colors.normalColor = highlightedColor;
  1074. colors.highlightedColor = highlightedColor;
  1075. button.colors = colors;
  1076. // 切换字体颜色
  1077. Text buttonText = button.GetComponentInChildren<Text>();
  1078. buttonText.color = highlightedTextColor;
  1079. }
  1080. private void ResetButton(Button button)
  1081. {
  1082. // 重置按钮颜色
  1083. ColorBlock colors = button.colors;
  1084. colors.normalColor = normalColor;
  1085. colors.highlightedColor = normalColor;
  1086. button.colors = colors;
  1087. // 重置字体颜色
  1088. Text buttonText = button.GetComponentInChildren<Text>();
  1089. buttonText.color = normalTextColor;
  1090. }
  1091. #endregion
  1092. #region 标定完成之后进入游戏界面
  1093. void onEnterInfrared()
  1094. {
  1095. //添加进入射箭场景
  1096. if (PlayerPrefs.GetInt("entry-guider-infrared-" + LoginMgr.myUserInfo.id, 0) == 0)
  1097. {
  1098. Debug.Log("-----进入射箭场景!");
  1099. NewUserGuiderManager newUserGuiderManager = FindObjectOfType<NewUserGuiderManager>();
  1100. newUserGuiderManager.curConfigKey = "开始-红外调整";
  1101. //b端都是红外设备流程
  1102. if (CommonConfig.StandaloneModeOrPlatformB)
  1103. {
  1104. newUserGuiderManager.isNewModule = true;
  1105. }
  1106. else {
  1107. newUserGuiderManager.isNewModule = AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.HOUYIPRO || AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.Gun || AimHandler.ins.aimDeviceInfo.type == (int)AimDeviceType.ARTEMISPRO;
  1108. }
  1109. //进入射箭场景
  1110. GlobalData.pkMatchType = PKMatchType.None;
  1111. GameMgr.gameType = 1;
  1112. //射一箭回到连接页面,Device.view
  1113. GameMgr.bNavBack = true;
  1114. GameMgr.bShowDistance = false;
  1115. if (!CommonConfig.StandaloneModeOrPlatformB)
  1116. {
  1117. AimHandler.ins.bInitOne = false;//true
  1118. }
  1119. //关闭计时器
  1120. GameMgr.turnOffTimer = true;
  1121. //关闭左边靶子和底部速度栏
  1122. GameMgr.HideTargetView = true;
  1123. GameMgr.HideBillboard = true;
  1124. GameMgr.ButtonCount = 0;
  1125. UnityEngine.SceneManagement.SceneManager.LoadScene(
  1126. "Game", UnityEngine.SceneManagement.LoadSceneMode.Single);
  1127. PlayerPrefs.SetInt("entry-guider-infrared-" + LoginMgr.myUserInfo.id, 1);
  1128. }
  1129. else
  1130. {
  1131. Debug.Log("-----跳转回连接界面!");
  1132. //如不是第一次,则应该跳转回连接界面
  1133. ViewMgr.Instance.DestroyView<SmartArcheryView>();
  1134. ViewManager2.HideView(ViewManager2.Path_ConnectGuidanceView);
  1135. }
  1136. }
  1137. #endregion
  1138. #region 最后选择算法处理UI
  1139. int selected = -1;
  1140. void initSelectInfo() {
  1141. for (int i = 0; i < 2; i++)
  1142. {
  1143. int currentIndex = i; // 将 i 赋值给局部变量
  1144. ResultImagesButtons[currentIndex].onClick.AddListener(() => SelectImage(currentIndex));
  1145. //ResultButtons[currentIndex].onClick.AddListener(() =>
  1146. //{
  1147. // if (currentIndex == 0)
  1148. // {
  1149. // OnFirstResult();
  1150. // }
  1151. // else if (currentIndex == 1)
  1152. // {
  1153. // OnSecondResult();
  1154. // }
  1155. //});
  1156. }
  1157. //默认选择1 自动
  1158. SelectImage(0);
  1159. }
  1160. // 添加一个选择函数
  1161. void SelectImage(int selectedIndex)
  1162. {
  1163. //如果重复选中则跳转
  1164. if (selected == selectedIndex) {
  1165. if (selected == 0)
  1166. {
  1167. OnFirstResult();
  1168. }
  1169. else if (selected == 1)
  1170. {
  1171. OnSecondResult();
  1172. }
  1173. return;
  1174. }
  1175. // 遍历所有图片
  1176. selected = selectedIndex;
  1177. //for (int i = 0; i < ResultImages.Length; i++)
  1178. //{
  1179. // // 如果是选中的 index,赋值为 ResultLines[0],否则赋值为 ResultLines[1]
  1180. // if (i == selectedIndex)
  1181. // {
  1182. // selected = i;
  1183. // ResultImages[i].sprite = ResultLines[0];
  1184. // ResultButtons[i].interactable = true;
  1185. // }
  1186. // else
  1187. // {
  1188. // ResultImages[i].sprite = ResultLines[1];
  1189. // ResultButtons[i].interactable = false;
  1190. // }
  1191. //}
  1192. }
  1193. //选择全自动结果后进入游戏
  1194. void OnFirstResult()
  1195. {
  1196. ScreenLocate.Main.SelectScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.Auto);
  1197. UpdateQuadUnityVectorList();
  1198. onCompelete();
  1199. }
  1200. //选择半自动结果
  1201. void OnSecondResult()
  1202. {
  1203. ScreenLocate.Main.SelectScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.SemiAuto);
  1204. UpdateQuadUnityVectorList();
  1205. onCompelete();
  1206. }
  1207. public void onCompelete()
  1208. {
  1209. if (enterFromZimWebCamera)
  1210. {
  1211. SaveLocalPos();
  1212. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  1213. return;
  1214. }
  1215. EnterGame();
  1216. //存储一次节点
  1217. SaveLocalPos();
  1218. }
  1219. void EnterGame() {
  1220. if (InfraredDemo.running)
  1221. {
  1222. //跳转入界面
  1223. AudioMgr.ins.PlayBtn();
  1224. if (!enterFromInfraredDemo)
  1225. {
  1226. //每次初始化重置一下引导
  1227. infraredDemo.resetInfraredPlayerPrefs();
  1228. //GameObject connectGuidanceView = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_ConnectGuidanceView);
  1229. //connectGuidanceView.GetComponent<ConnectGuidanceView>().showTextipInfrared();
  1230. if (!PlayerPrefs.HasKey("hideInfraredBowAndArrow"))
  1231. {
  1232. //如果是红外连接成功,记录一个tag
  1233. PlayerPrefs.SetInt("hideInfraredBowAndArrow", 1);
  1234. }
  1235. onEnterInfrared();
  1236. }
  1237. else
  1238. {
  1239. ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  1240. }
  1241. }
  1242. }
  1243. /// <summary>
  1244. /// 选择模式后更新 quadUnityVectorList
  1245. /// </summary>
  1246. void UpdateQuadUnityVectorList() {
  1247. ScreenLocate.Main.UpdateQuadUnityVectorList();
  1248. SyncQuadUnityVectorListToPos();
  1249. infraredDemo?.SetLocatePointsToCameraRender(ScreenLocate.quadUnityVectorList, 1, 1);
  1250. _locatePointList.Clear();
  1251. }
  1252. void SyncQuadUnityVectorListToPos() {
  1253. Debug.Log("[ScreenLocate] SyncQuadUnityVectorListToPos quadUnityVectorList:" + ScreenLocate.Main.PrintVector2List(ScreenLocate.quadUnityVectorList));
  1254. pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  1255. pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  1256. pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  1257. pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  1258. }
  1259. //这个脚本存在时候。任何切换操作都直接处理删除
  1260. //void OnSceneUnloaded(Scene scene)
  1261. //{
  1262. // ViewManager2.HideView(ViewManager2.Path_ConnectGuidanceView);
  1263. // ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
  1264. //}
  1265. //void OnEnable()
  1266. //{
  1267. // SceneManager.sceneUnloaded += OnSceneUnloaded;
  1268. //}
  1269. //void OnDisable()
  1270. //{
  1271. // SceneManager.sceneUnloaded -= OnSceneUnloaded;
  1272. //}
  1273. #endregion
  1274. #region 判断点是否在 quad 内部
  1275. //判断maskline
  1276. public bool IsPointInMaskLine(Vector2 point) {
  1277. return IsPointInQuad(point, maskLine.ScreenPositions);
  1278. }
  1279. //实现基于射线法,通过数交点的奇偶性来判断点是否在多边形内
  1280. bool IsPointInQuad(Vector2 point, List<Vector2> quadVertices)
  1281. {
  1282. if (quadVertices.Count != 4)
  1283. {
  1284. Debug.LogError("Quad must have exactly 4 vertices.");
  1285. return false;
  1286. }
  1287. bool isInside = false;
  1288. int vertexCount = quadVertices.Count;
  1289. for (int i = 0, j = vertexCount - 1; i < vertexCount; j = i++)
  1290. {
  1291. Vector2 vi = quadVertices[i];
  1292. Vector2 vj = quadVertices[j];
  1293. // 检查射线是否与边相交
  1294. if (((vi.y > point.y) != (vj.y > point.y)) &&
  1295. (point.x < (vj.x - vi.x) * (point.y - vi.y) / (vj.y - vi.y) + vi.x))
  1296. {
  1297. isInside = !isInside;
  1298. }
  1299. }
  1300. return isInside;
  1301. }
  1302. /// <summary>
  1303. /// 判断四个点是否能够形成有效的四边形,并根据面积阈值过滤小四边形
  1304. /// </summary>
  1305. /// <param name="points">四个点</param>
  1306. /// <param name="minArea">面积阈值,用于过滤面积太小的四边形</param>
  1307. /// <returns>是否是有效的四边形</returns>
  1308. public bool IsValidQuadrilateral(Vector2[] points, float minArea = 100000.0f)
  1309. {
  1310. if (points.Length != 4)
  1311. {
  1312. Debug.Log("四个点数不足,无法形成四边形。");
  1313. return false; // 如果点数不是4,直接返回false
  1314. }
  1315. // 计算四边形的面积
  1316. float area = CalculateArea(points);
  1317. Debug.Log($"四边形面积: {area}");
  1318. if (area < minArea)
  1319. {
  1320. Debug.Log($"面积小于阈值: {minArea},返回 false。");
  1321. return false; // 面积太小,返回 false
  1322. }
  1323. // 检查是否有三点共线
  1324. for (int i = 0; i < points.Length; i++)
  1325. {
  1326. Vector2 a = points[i];
  1327. Vector2 b = points[(i + 1) % points.Length];
  1328. Vector2 c = points[(i + 2) % points.Length];
  1329. if (ArePointsCollinear(a, b, c))
  1330. {
  1331. Debug.Log($"点 {a}, {b}, {c} 共线,返回 false。");
  1332. return false; // 存在共线点,返回 false
  1333. }
  1334. }
  1335. // 检查是否为矩形或接近矩形
  1336. if (!IsRectangle(points))
  1337. {
  1338. // 如果不是矩形,检查是否是梯形
  1339. if (!IsTrapezoid(points))
  1340. {
  1341. Debug.Log("既不是矩形,也不是梯形,返回 false。");
  1342. return false; // 不是矩形也不是梯形,返回 false
  1343. }
  1344. else
  1345. {
  1346. Debug.Log("是梯形。");
  1347. }
  1348. }
  1349. else
  1350. {
  1351. Debug.Log("是矩形。");
  1352. }
  1353. // 检查对角线是否相交
  1354. if (DoLinesIntersect(points[0], points[1], points[2], points[3]) ||
  1355. DoLinesIntersect(points[1], points[2], points[3], points[0]))
  1356. {
  1357. Debug.Log("对角线相交,返回 false。");
  1358. return false; // 对角线相交,返回 false
  1359. }
  1360. // 检查点的排列顺序,确保是顺时针或逆时针
  1361. if (!ArePointsClockwise(points) && !ArePointsClockwise(points.Reverse().ToArray()))
  1362. {
  1363. Debug.Log("点的排列顺序不正确,返回 false。");
  1364. return false; // 点的排列顺序不正确
  1365. }
  1366. Debug.Log("四边形有效,返回 true。");
  1367. return true; // 通过所有检查,返回 true
  1368. }
  1369. /// <summary>
  1370. /// 判断是否是矩形(近似90度角)
  1371. /// </summary>
  1372. private bool IsRectangle(Vector2[] points)
  1373. {
  1374. // 角度容差范围,允许夹角有小的偏差
  1375. const float dotProductThreshold = 0.1f;
  1376. for (int i = 0; i < points.Length; i++)
  1377. {
  1378. Vector2 a = points[i];
  1379. Vector2 b = points[(i + 1) % points.Length];
  1380. Vector2 c = points[(i + 2) % points.Length];
  1381. // 计算向量 AB 和 BC 的内积
  1382. Vector2 ab = b - a;
  1383. Vector2 bc = c - b;
  1384. float dotProduct = Vector2.Dot(ab.normalized, bc.normalized);
  1385. // 如果内积接近 0,表示夹角接近 90 度
  1386. if (Mathf.Abs(dotProduct) > dotProductThreshold)
  1387. {
  1388. Debug.Log($"点 {a}, {b}, {c} 的夹角不接近 90 度,返回 false。");
  1389. return false; // 角度不接近 90 度
  1390. }
  1391. }
  1392. return true;
  1393. }
  1394. /// <summary>
  1395. /// 判断是否是梯形
  1396. /// </summary>
  1397. private bool IsTrapezoid(Vector2[] points)
  1398. {
  1399. // 斜率容差范围,允许斜率差异较小
  1400. const float slopeThreshold = 0.2f;
  1401. // 计算对角线的斜率
  1402. float slope1 = (points[1].y - points[0].y) / (points[1].x - points[0].x);
  1403. float slope2 = (points[3].y - points[2].y) / (points[3].x - points[2].x);
  1404. // 如果对角线斜率差异小于容差范围,则认为是梯形
  1405. if (Mathf.Abs(slope1 - slope2) < slopeThreshold)
  1406. {
  1407. Debug.Log("对角线平行,判断为梯形。");
  1408. return true; // 对角线平行,返回 true
  1409. }
  1410. else
  1411. {
  1412. Debug.Log($"对角线斜率差异过大: {slope1} vs {slope2},不是梯形,返回 false。");
  1413. return false; // 斜率差异过大,不是梯形
  1414. }
  1415. }
  1416. //计算四边形面积
  1417. float CalculateArea(Vector2[] points)
  1418. {
  1419. float area = 0f;
  1420. int n = points.Length;
  1421. for (int i = 0; i < n; i++)
  1422. {
  1423. Vector2 current = points[i];
  1424. Vector2 next = points[(i + 1) % n];
  1425. area += current.x * next.y - current.y * next.x;
  1426. }
  1427. return Mathf.Abs(area) / 2f;
  1428. }
  1429. //确保点不共线
  1430. //判断点是否在同一条直线上(即共线),如果共线则无法形成四边形。可以通过计算任意三点的面积是否为 0 来验证是否共线:
  1431. bool ArePointsCollinear(Vector2 a, Vector2 b, Vector2 c)
  1432. {
  1433. float area = Mathf.Abs(a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y)) / 2.0f;
  1434. return Mathf.Approximately(area, 0f);
  1435. }
  1436. //确保边不相交
  1437. bool DoLinesIntersect(Vector2 a, Vector2 b, Vector2 c, Vector2 d)
  1438. {
  1439. float cross(Vector2 p1, Vector2 p2, Vector2 p3)
  1440. {
  1441. return (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x);
  1442. }
  1443. float d1 = cross(a, b, c);
  1444. float d2 = cross(a, b, d);
  1445. float d3 = cross(c, d, a);
  1446. float d4 = cross(c, d, b);
  1447. return d1 * d2 < 0 && d3 * d4 < 0;
  1448. }
  1449. //顺时针或逆时针排列顶点
  1450. bool ArePointsClockwise(Vector2[] points)
  1451. {
  1452. float sum = 0;
  1453. for (int i = 0; i < points.Length; i++)
  1454. {
  1455. Vector2 current = points[i];
  1456. Vector2 next = points[(i + 1) % points.Length];
  1457. sum += (next.x - current.x) * (next.y + current.y);
  1458. }
  1459. return sum < 0; // 小于0为顺时针,大于0为逆时针
  1460. }
  1461. #endregion
  1462. #region marker line 部分渲染
  1463. /// <summary>
  1464. /// maker 界面渲染
  1465. /// </summary>
  1466. void SyncQuadUnityVectorListToMarkerPointesPos()
  1467. {
  1468. if (ScreenLocate.quadUnityVectorList.Count == 4)
  1469. {
  1470. Debug.Log("[ScreenLocate] SyncQuadUnityVectorListToMarkerPointesPos quadUnityVectorList:" + ScreenLocate.Main.PrintVector2List(ScreenLocate.quadUnityVectorList));
  1471. markerPosList[0].anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  1472. markerPosList[1].anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  1473. markerPosList[2].anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  1474. markerPosList[3].anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
  1475. SetMarkerRectanglePoints(linePosConversion(markerPosList[0].localPosition, markerPosList[1].localPosition, markerPosList[2].localPosition, markerPosList[3].localPosition));
  1476. }
  1477. }
  1478. void SetMarkerRectanglePoints(List<Vector2> screenPositions)
  1479. {
  1480. markerPointsLine.SetLine(screenPositions);
  1481. }
  1482. #endregion
  1483. }