|
|
@@ -108,12 +108,12 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
{
|
|
|
Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
|
|
|
Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
|
|
|
-
|
|
|
//自动识别时候四个点
|
|
|
- pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ SyncQuadUnityVectorListToPos();
|
|
|
+ //pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ //pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ //pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ //pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -127,6 +127,12 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
//重置偏移量
|
|
|
InfraredDemo._ins.ResetCenterOffset();
|
|
|
|
|
|
+ //重置识别点
|
|
|
+ ScreenLocate.Main.ScreenIdentification.ClearQuadCache();
|
|
|
+ //清除一下记录的点
|
|
|
+ ScreenLocate.quadUnityVectorList.Clear();
|
|
|
+
|
|
|
+
|
|
|
slider.onValueChanged.AddListener((value) =>
|
|
|
{
|
|
|
InfraredDemo._ins.onSliderEvent(value);
|
|
|
@@ -279,10 +285,11 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
Vector2 texSize = ScreenLocate.Main.getUVCCameraInfoSize;
|
|
|
Debug.Log("texSize:" + texSize + " = " + canvasRectTransform.rect);
|
|
|
//自动识别时候四个点
|
|
|
- pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
- pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ //pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ //pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ //pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ //pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ SyncQuadUnityVectorListToPos();
|
|
|
|
|
|
SetRectanglePoints(linePosConversion(pos1.localPosition, pos2.localPosition, pos3.localPosition, pos4.localPosition));
|
|
|
|
|
|
@@ -298,7 +305,93 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
t.anchoredPosition = screen.Quad[i].pixelToLocalPosition_AnchorCenter(screen.CameraSize, pointsParent.rect);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ //显示最后结果
|
|
|
+ LayoutMarker.SetActive(false);
|
|
|
+ LayoutSuccessful.SetActive(true);
|
|
|
+
|
|
|
+ //设置两个线段
|
|
|
+ QuadrilateralInCamera screenAuto = ScreenLocate.Main.ScreenIdentification.QuadAuto;
|
|
|
+ QuadrilateralInCamera screenSemiAuto = ScreenLocate.Main.ScreenIdentification.QuadSemiAuto;
|
|
|
+
|
|
|
+ var lo = new Vector2(-0.5f, -0.5f);
|
|
|
+ if (screenAuto != null)
|
|
|
+ {
|
|
|
+ FirstUILineGenerator.Points = new Vector2[4] {
|
|
|
+ 2 * (new Vector2(screenAuto.Quad[0].x/texSize.x,screenAuto.Quad[0].y/texSize.y) + lo),
|
|
|
+ 2 * (new Vector2(screenAuto.Quad[1].x/texSize.x,screenAuto.Quad[1].y/texSize.y) + lo),
|
|
|
+ 2 * (new Vector2(screenAuto.Quad[3].x/texSize.x,screenAuto.Quad[3].y/texSize.y) + lo),
|
|
|
+ 2 * (new Vector2(screenAuto.Quad[2].x/texSize.x,screenAuto.Quad[2].y/texSize.y) + lo) };
|
|
|
+
|
|
|
+ // 打印 Points 的值,合并为一个字符串
|
|
|
+ string pointsOutput = "1 Points: ";
|
|
|
+ for (int i = 0; i < FirstUILineGenerator.Points.Length; i++)
|
|
|
+ {
|
|
|
+ pointsOutput += "[" + FirstUILineGenerator.Points[i].x + ", " + FirstUILineGenerator.Points[i].y + "]";
|
|
|
+ if (i < FirstUILineGenerator.Points.Length - 1)
|
|
|
+ {
|
|
|
+ pointsOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Debug.Log(pointsOutput);
|
|
|
+
|
|
|
+ // 打印 Quad 的值,合并为一个字符串
|
|
|
+ int[] customOrder = new int[] { 0, 1, 3, 2 };
|
|
|
+ string quadOutput = "1 Quad Points: ";
|
|
|
+ for (int i = 0; i < customOrder.Length; i++)
|
|
|
+ {
|
|
|
+ quadOutput += "[" + screenAuto.Quad[customOrder[i]].x + ", " + screenAuto.Quad[customOrder[i]].y + "]";
|
|
|
+ if (i < customOrder.Length - 1)
|
|
|
+ {
|
|
|
+ quadOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Debug.Log(quadOutput);
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Debug.LogError("screenAuto 不存在!");
|
|
|
+ }
|
|
|
+ if (screenSemiAuto != null)
|
|
|
+ {
|
|
|
+ SecondUILineGenerator.Points = new Vector2[4] {
|
|
|
+ 2 * (new Vector2(screenSemiAuto.Quad[0].x/texSize.x,screenSemiAuto.Quad[0].y/texSize.y) + lo),
|
|
|
+ 2 * (new Vector2(screenSemiAuto.Quad[1].x/texSize.x,screenSemiAuto.Quad[1].y/texSize.y) + lo),
|
|
|
+ 2 * (new Vector2(screenSemiAuto.Quad[3].x/texSize.x,screenSemiAuto.Quad[3].y/texSize.y) + lo),
|
|
|
+ 2 * (new Vector2(screenSemiAuto.Quad[2].x/texSize.x,screenSemiAuto.Quad[2].y/texSize.y) + lo) };
|
|
|
+
|
|
|
+ // 打印 Points 的值,合并为一个字符串
|
|
|
+ string pointsOutput = "2 Points: ";
|
|
|
+ for (int i = 0; i < SecondUILineGenerator.Points.Length; i++)
|
|
|
+ {
|
|
|
+ pointsOutput += "[" + SecondUILineGenerator.Points[i].x + ", " + SecondUILineGenerator.Points[i].y + "]";
|
|
|
+ if (i < SecondUILineGenerator.Points.Length - 1)
|
|
|
+ {
|
|
|
+ pointsOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Debug.Log(pointsOutput);
|
|
|
+
|
|
|
+ // 打印 Quad 的值,合并为一个字符串
|
|
|
+ int[] customOrder = new int[] { 0, 1, 3, 2 };
|
|
|
+ string quadOutput = "2 Quad Points: ";
|
|
|
+ for (int i = 0; i < customOrder.Length; i++)
|
|
|
+ {
|
|
|
+ quadOutput += "[" + screenSemiAuto.Quad[customOrder[i]].x + ", " + screenSemiAuto.Quad[customOrder[i]].y + "]";
|
|
|
+ if (i < customOrder.Length - 1)
|
|
|
+ {
|
|
|
+ quadOutput += ", "; // 添加逗号分隔符,最后一个元素后不加
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Debug.Log(quadOutput);
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Debug.LogError("screenSemiAuto 不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
#region 绘制线段部分
|
|
|
@@ -752,4 +845,124 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region 最后选择算法处理UI
|
|
|
+ void initSelectInfo() {
|
|
|
+ for (int i = 0; i < 2; i++)
|
|
|
+ {
|
|
|
+ int currentIndex = i; // 将 i 赋值给局部变量
|
|
|
+
|
|
|
+ ResultImagesButtons[currentIndex].onClick.AddListener(() => SelectImage(currentIndex));
|
|
|
+
|
|
|
+ ResultButtons[currentIndex].onClick.AddListener(() =>
|
|
|
+ {
|
|
|
+ if (currentIndex == 0)
|
|
|
+ {
|
|
|
+ OnFirstResult();
|
|
|
+ }
|
|
|
+ else if (currentIndex == 1)
|
|
|
+ {
|
|
|
+ OnSecondResult();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //默认选择1 自动
|
|
|
+ SelectImage(0);
|
|
|
+ }
|
|
|
+ // 添加一个选择函数
|
|
|
+ void SelectImage(int selectedIndex)
|
|
|
+ {
|
|
|
+ // 遍历所有图片
|
|
|
+
|
|
|
+ for (int i = 0; i < ResultImages.Length; i++)
|
|
|
+ {
|
|
|
+ // 如果是选中的 index,赋值为 ResultLines[0],否则赋值为 ResultLines[1]
|
|
|
+ if (i == selectedIndex)
|
|
|
+ {
|
|
|
+ ResultImages[i].sprite = ResultLines[0];
|
|
|
+ ResultButtons[i].interactable = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ResultImages[i].sprite = ResultLines[1];
|
|
|
+ ResultButtons[i].interactable = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //选择全自动结果后进入游戏
|
|
|
+ void OnFirstResult()
|
|
|
+ {
|
|
|
+ ScreenLocate.Main.SelectScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.Auto);
|
|
|
+ UpdateQuadUnityVectorList();
|
|
|
+ onCompelete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //选择半自动结果
|
|
|
+ void OnSecondResult()
|
|
|
+ {
|
|
|
+ ScreenLocate.Main.SelectScreenAfterLocate(ScreenLocate.ScreenIdentificationTag.SemiAuto);
|
|
|
+ UpdateQuadUnityVectorList();
|
|
|
+
|
|
|
+ onCompelete();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void onCompelete()
|
|
|
+ {
|
|
|
+ if (enterFromZimWebCamera)
|
|
|
+ {
|
|
|
+ SaveLocalPos();
|
|
|
+ ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (InfraredDemo.running)
|
|
|
+ {
|
|
|
+ //跳转入界面
|
|
|
+ AudioMgr.ins.PlayBtn();
|
|
|
+
|
|
|
+ if (!enterFromInfraredDemo)
|
|
|
+ {
|
|
|
+ //每次初始化重置一下引导
|
|
|
+ InfraredDemo._ins.resetInfraredPlayerPrefs();
|
|
|
+ //GameObject connectGuidanceView = ViewManager2.getGameObjectAndShowView(ViewManager2.Path_ConnectGuidanceView);
|
|
|
+ //connectGuidanceView.GetComponent<ConnectGuidanceView>().showTextipInfrared();
|
|
|
+
|
|
|
+ if (!PlayerPrefs.HasKey("hideInfraredBowAndArrow"))
|
|
|
+ {
|
|
|
+ //如果是红外连接成功,记录一个tag
|
|
|
+ PlayerPrefs.SetInt("hideInfraredBowAndArrow", 1);
|
|
|
+ }
|
|
|
+ onEnterInfrared();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ViewManager2.HideView(ViewManager2.Path_InfraredScreenPositioningView);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //存储一次节点
|
|
|
+ SaveLocalPos();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 选择模式后更新 quadUnityVectorList
|
|
|
+ /// </summary>
|
|
|
+ void UpdateQuadUnityVectorList() {
|
|
|
+
|
|
|
+ ScreenLocate.Main.UpdateQuadUnityVectorList();
|
|
|
+ SyncQuadUnityVectorListToPos();
|
|
|
+ InfraredDemo._ins?.SetLocatePointsToCameraRender(ScreenLocate.quadUnityVectorList, 1, 1);
|
|
|
+ _locatePointList.Clear();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ void SyncQuadUnityVectorListToPos() {
|
|
|
+ Debug.Log("[ScreenLocate] SyncQuadUnityVectorListToPos quadUnityVectorList:" + ScreenLocate.Main.PrintVector2List(ScreenLocate.quadUnityVectorList));
|
|
|
+ pos1.anchoredPosition = ScreenLocate.quadUnityVectorList[0].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ pos2.anchoredPosition = ScreenLocate.quadUnityVectorList[1].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ pos4.anchoredPosition = ScreenLocate.quadUnityVectorList[2].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ pos3.anchoredPosition = ScreenLocate.quadUnityVectorList[3].pixelToLocalPosition_AnchorCenter(Vector2.one, canvasRectTransform.rect);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|