Selaa lähdekoodia

1.调整InfraredDemo 层级问题
2.增加右键标点

slambb 1 vuosi sitten
vanhempi
sitoutus
cdc3ea8b2b

+ 4 - 2
Assets/BowArrow/InfraredCamera/InfraredDemo.cs

@@ -10,7 +10,7 @@ using System;
 using SmartBowSDK;
 using ZIM.Unity;
 
-public class InfraredDemo : MonoBehaviour
+public class InfraredDemo  : JCUnityLib.ViewBase
 {
     public static bool DebugInEditor = true;
     public static InfraredDemo _ins;
@@ -27,7 +27,9 @@ public class InfraredDemo : MonoBehaviour
         GameObject o = Instantiate(Resources.Load<GameObject>("InfraredDemo"));
         DontDestroyOnLoad(o);
         _ins = o.GetComponent<InfraredDemo>();
-
+        //添加一个父物体
+        o.transform.SetParent(ViewMgr.Instance.transform.Find("1").transform);
+        
         //直接初始化一次
         _ins.InitInfraredCamera();
     }

+ 8 - 8
Assets/BowArrow/InfraredCamera/Resources/InfraredDemo.prefab

@@ -2415,7 +2415,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!224 &5148638679184586783
 RectTransform:
   m_ObjectHideFlags: 0
@@ -2432,9 +2432,9 @@ RectTransform:
   m_Father: {fileID: 2081588674167073364}
   m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
-  m_AnchorMin: {x: 0, y: 0}
-  m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 0, y: 0}
+  m_AnchorMin: {x: 0, y: 1}
+  m_AnchorMax: {x: 0, y: 1}
+  m_AnchoredPosition: {x: 120, y: 0}
   m_SizeDelta: {x: 120, y: 30}
   m_Pivot: {x: 0, y: 1}
 --- !u!222 &2909431913411680158
@@ -6799,7 +6799,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
   m_AnchoredPosition: {x: 0, y: 0}
-  m_SizeDelta: {x: 356.67, y: 30}
+  m_SizeDelta: {x: 278.63, y: 30}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &6041499702862749651
 MonoBehaviour:
@@ -6818,7 +6818,7 @@ MonoBehaviour:
     m_Right: 0
     m_Top: 0
     m_Bottom: 0
-  m_ChildAlignment: 0
+  m_ChildAlignment: 2
   m_Spacing: 0
   m_ChildForceExpandWidth: 1
   m_ChildForceExpandHeight: 1
@@ -9888,8 +9888,8 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 200, y: 30}
-  m_SizeDelta: {x: 160, y: 50}
+  m_AnchoredPosition: {x: 215.4, y: 30}
+  m_SizeDelta: {x: 150, y: 40}
   m_Pivot: {x: 0, y: 0}
 --- !u!222 &3418442180573849833
 CanvasRenderer:

+ 26 - 0
Assets/BowArrow/Scripts/Manager/HomeMgr.cs

@@ -32,6 +32,32 @@ public class HomeMgr : MonoBehaviour
         ViewMgr.Instance.ResumeView<RoleSelectView>();
         //ViewMgr.Instance.ResumeView<PKGameOptionView>();
         ViewMgr.Instance.ResumeView<PKMatchView>();
+        //创建节点1
+        if (ViewMgr.Instance.transform.Find("1") == null)
+        {
+            // 获取模板对象(假设名称为 "0")
+            Transform template = ViewMgr.Instance.transform.Find("0");
+
+            // 创建一个新的 GameObject,使用模板的 Transform 属性但不复制子物体
+            GameObject newObj = new GameObject("1");
+            newObj.transform.SetParent(ViewMgr.Instance.transform);
+            newObj.transform.localPosition = template.localPosition;
+            newObj.transform.localRotation = template.localRotation;
+            newObj.transform.localScale = template.localScale;
+
+            // 如果需要 RectTransform 组件,添加并设置它
+            RectTransform rectTransform = newObj.AddComponent<RectTransform>();
+            RectTransform templateRect = template.GetComponent<RectTransform>();
+
+            if (templateRect != null)
+            {
+                rectTransform.anchorMin = templateRect.anchorMin;
+                rectTransform.anchorMax = templateRect.anchorMax;
+                rectTransform.offsetMin = templateRect.offsetMin;
+                rectTransform.offsetMax = templateRect.offsetMax;
+            }
+            // newObj.transform.SetParent(ViewMgr.Instance.transform);
+        }
         //红外界面
         InfraredDemo.Create();
     }

+ 3 - 3
Assets/SmartBow/Scripts/Views/InfraredViewParts/PointMarker.cs

@@ -44,8 +44,8 @@ public class PointMarker : MonoBehaviour
 
     void Update()
     {
-#if UNITY_EDITOR
-        if (Input.GetKeyDown(KeyCode.Alpha6))
+//#if UNITY_EDITOR
+        if (Input.GetKeyDown(KeyCode.Alpha6) || Input.GetMouseButtonDown(1))
         {
             //Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
             //MarkPoint(mousePosition);
@@ -61,7 +61,7 @@ public class PointMarker : MonoBehaviour
             // 设置标记的位置
             MarkPoint(new Vector2(u, v).pixelToLocalPosition_AnchorCenter(new Vector2(1, 1), markerParent.GetComponent<RectTransform>().rect));
         }
-#endif
+//#endif
     }
     /// <summary>
     /// 记录红外点

+ 7 - 3
Assets/SmartBow/Scripts/Views/ViewManager2.cs

@@ -27,11 +27,15 @@ public class ViewManager2
 
     static GameObject InstantiateView(string path)
     {
-        //查找创造的ViewMgr 第一个层级作为ViewManager2的父节点
-        if (currentViewParent == null)
+        int groupIndex = 0;
+        //根据条件设置group
+        if (path == Path_InfraredScreenPositioningView)
         {
-            currentViewParent = ViewMgr.Instance.transform.Find("0").gameObject;
+            groupIndex = 1;
         }
+        //查找创造的ViewMgr 第一个层级作为ViewManager2的父节点
+        currentViewParent = ViewMgr.Instance.transform.Find(groupIndex.ToString()).gameObject;
+
         string fullPath = "SmartBow/Prefabs/Views/" + path;
         _DestroyExistViews(fullPath);
         GameObject o = Object.Instantiate(Resources.Load<GameObject>(fullPath), currentViewParent.transform);