Quellcode durchsuchen

修改调试代码

slambb vor 11 Monaten
Ursprung
Commit
15f9b40368

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

@@ -2415,7 +2415,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 0
+  m_IsActive: 1
 --- !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: 1}
-  m_AnchorMax: {x: 0, y: 1}
-  m_AnchoredPosition: {x: 120, y: 0}
+  m_AnchorMin: {x: 0, y: 0}
+  m_AnchorMax: {x: 0, y: 0}
+  m_AnchoredPosition: {x: 0, 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: 278.63, y: 30}
+  m_SizeDelta: {x: 390, y: 30}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &6041499702862749651
 MonoBehaviour:
@@ -6819,7 +6819,7 @@ MonoBehaviour:
     m_Top: 0
     m_Bottom: 0
   m_ChildAlignment: 2
-  m_Spacing: 0
+  m_Spacing: 13.4
   m_ChildForceExpandWidth: 1
   m_ChildForceExpandHeight: 1
   m_ChildControlWidth: 0

+ 3 - 3
Assets/BowArrow/Resources/Prefabs/Effects/HitTargetNumberPlatformB.prefab

@@ -79,7 +79,7 @@ MonoBehaviour:
     m_HorizontalOverflow: 0
     m_VerticalOverflow: 0
     m_LineSpacing: 1
-  m_Text: 
+  m_Text: 9.1
 --- !u!1 &3953484096697592415
 GameObject:
   m_ObjectHideFlags: 0
@@ -106,7 +106,7 @@ RectTransform:
   m_GameObject: {fileID: 3953484096697592415}
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
   m_LocalPosition: {x: 0, y: 0, z: 0}
-  m_LocalScale: {x: 1.5, y: 1.5, z: 1.5}
+  m_LocalScale: {x: 1.4, y: 1.4, z: 1.4}
   m_ConstrainProportionsScale: 1
   m_Children:
   - {fileID: 1537881960295453758}
@@ -149,7 +149,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!224 &1537881960295453758
 RectTransform:
   m_ObjectHideFlags: 0

+ 35 - 18
Assets/BowArrow/Scripts/Editor/EditPlay.cs

@@ -1,43 +1,60 @@
-using System.Collections;
-using System.Collections.Generic;
 using UnityEditor;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
-//在编辑器场景使用
+[InitializeOnLoad]
 public class EditPlay : MonoBehaviour
 {
-    static string sceneName = "Entry";
-    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
-    private static void Initialize()
+    static string sceneName;
+
+    static EditPlay()
     {
-        RefreshMenuChecked();
-        if (Menu.GetChecked("播放场景/Entry场景"))
+        // 从 EditorPrefs 读取存储的选项,如果不存在则设置默认值为 "Entry"
+        sceneName = EditorPrefs.GetString("EditPlay_SceneName", "Entry");
+
+        // 使用 delayCall 来在编辑器启动后刷新菜单项状态
+        EditorApplication.delayCall += () =>
         {
-            Debug.Log("Play的Entry场景!");
-            string sceneName = SceneManager.GetActiveScene().name;
-            if (sceneName != "Entry")SceneManager.LoadScene("Entry");
-        }
-        else {
-            Debug.Log("Play的Current场景!");
+            RefreshMenuChecked();
+            Debug.Log("编辑器启动时已刷新菜单项状态");
+        };
+
+        // 自动加载场景(仅在编辑器进入播放模式时有效)
+        EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
+    }
+
+    private static void OnPlayModeStateChanged(PlayModeStateChange state)
+    {
+        if (state == PlayModeStateChange.EnteredPlayMode)
+        {
+            // 在进入播放模式时加载指定场景
+            if (sceneName == "Entry" && SceneManager.GetActiveScene().name != "Entry")
+            {
+                Debug.Log("加载 Entry 场景");
+                SceneManager.LoadScene("Entry");
+            }
+            else if (sceneName == "Current")
+            {
+                Debug.Log("保持当前场景");
+            }
         }
-     
     }
 
     [MenuItem("播放场景/当前场景")]
     static void playCurrentScene()
     {
-        Debug.Log("切换成Current场景!");
+        Debug.Log("切换成 Current 场景!");
         sceneName = "Current";
+        EditorPrefs.SetString("EditPlay_SceneName", sceneName);
         RefreshMenuChecked();
     }
 
-
     [MenuItem("播放场景/Entry场景")]
     static void playEntryScene()
     {
-        Debug.Log("切换成Entry场景!");
+        Debug.Log("切换成 Entry 场景!");
         sceneName = "Entry";
+        EditorPrefs.SetString("EditPlay_SceneName", sceneName);
         RefreshMenuChecked();
     }
 

+ 5 - 0
Assets/InfraredProject/WebCamera/Script/PcWebCamera.cs

@@ -32,6 +32,11 @@ public class PcWebCamera : MonoBehaviour
         yield return new WaitForEndOfFrame();
         OnClick_Open();
     }
+
+    private void OnDestroy()
+    {
+        OnClick_Close();
+    }
     void OnSceneLoaded(Scene scene, LoadSceneMode mode)
     {
         Debug.Log("Scene Loaded: " + scene.name);

+ 2 - 3
Assets/InfraredProject/WebCamera/Script/ZIM/ZIMUnity/ZIMWebCamera.cs

@@ -155,10 +155,9 @@ public class ZIMWebCamera : MonoBehaviour
 
     public void OnClick_ScreenLocateManual()
     {
-        ViewManager2.ShowView(ViewManager2.Path_InfraredScreenPositioningView);
-        InfraredScreenPositioningView _infraredScreenPositioningView = FindObjectOfType<InfraredScreenPositioningView>();
+        GameObject o = ViewManager2.ShowTestInfraredScreenPositioningView(mParent);
+        InfraredScreenPositioningView _infraredScreenPositioningView = o.GetComponent<InfraredScreenPositioningView>();//FindObjectOfType<InfraredScreenPositioningView>();
         _infraredScreenPositioningView.enterFromZimWebCamera = true;
-        _infraredScreenPositioningView.transform.SetParent(mParent);
         ScreenLocate.Main.ResetScreenIdentification();
     }
 

+ 6 - 0
Assets/SmartBow/Scripts/Views/InfraredViewParts/InfraredScreenPositioningView.cs

@@ -412,6 +412,7 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
         var lo = new Vector2(-0.5f, -0.5f);
         if (screenAuto != null)
         {
+            Debug.Log("[校准流程]自动识别screenAuto信息  ------------ ");
             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),
@@ -449,6 +450,7 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
         }
         if (screenSemiAuto != null)
         {
+            Debug.Log("[校准流程]半自动识别screenSemiAuto信息 ------------ ");
             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),
@@ -755,6 +757,9 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
         //存储一次节点
         SaveLocalPos();
 
+
+        Debug.Log("[校准流程]进入自动校准数据,调用EnterScreenLocateManualAuto");
+
         bAuto = true;
         doLocateAuto = true;
         //自动校准
@@ -812,6 +817,7 @@ public class InfraredScreenPositioningView : JCUnityLib.ViewBase
             ScreenLocate.quadUnityVectorList.Add(_locatePointList[2]);
             ScreenLocate.SaveScreenLocateVectorList();
 
+            Debug.Log("[校准流程]设置QuitScreenLocateManual()手动数据,保存quadUnityVectorList");
             return true;
         }
         return false;

+ 27 - 0
Assets/SmartBow/Scripts/Views/ViewManager2.cs

@@ -115,6 +115,33 @@ public class ViewManager2
 
         return null; // 如果没有找到,则返回 null
     }
+    /// <summary>
+    /// 测试使用
+    /// </summary>
+    /// <param name="mParent"></param>
+    /// <returns></returns>
+    public static GameObject ShowTestInfraredScreenPositioningView(Transform mParent)
+    {
+        string fullPath = "SmartBow/Prefabs/Views/" + Path_InfraredScreenPositioningView;
+        GameObject o = Object.Instantiate(Resources.Load<GameObject>(fullPath), mParent);
+        Transform children = o.transform.Find("ScreenPositioningView");
+        UnityEngine.UI.CanvasScaler canvasScaler = children.GetComponent<UnityEngine.UI.CanvasScaler>();
+        if (canvasScaler != null)
+        {
+            Object.Destroy(canvasScaler);
+        }
+        RectTransform rectTransform = children.GetComponent<RectTransform>();
+        rectTransform.pivot = new Vector2(0.5f, 0.5f);
+        rectTransform.localScale = Vector3.one;      // 确保缩放为 1
+        rectTransform.sizeDelta = ((RectTransform)mParent.parent.transform).rect.size; // 设置大小
+        rectTransform.anchoredPosition = Vector2.zero; // 重置位置
+        ViewCacheInfo viewCacheInfo = new ViewCacheInfo();
+        viewCacheInfo.fullPath = fullPath;
+        viewCacheInfo.gameObject = o;
+        _ViewCacheInfos.Add(viewCacheInfo);
+        return o;
+    }
+
     /**
      * 跳转场景时候,所有UI视图
      */