فهرست منبع

5/26更新

2025/5/26 解决bug 领养成功后,会退出到登录界面
将遛狗场景添加到右侧菜单
修改遛狗场景bug
Jees 1 هفته پیش
والد
کامیت
1915c072d0

BIN
Assets/Pictures/menu icons/Walkdogs.png


+ 327 - 0
Assets/Pictures/menu icons/Walkdogs.png.meta

@@ -0,0 +1,327 @@
+fileFormatVersion: 2
+guid: cacf9fa8e8a6b784fb1128fca1f0bd57
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 13
+  mipmaps:
+    mipMapMode: 0
+    enableMipMap: 0
+    sRGBTexture: 1
+    linearTexture: 0
+    fadeOut: 0
+    borderMipMap: 0
+    mipMapsPreserveCoverage: 0
+    alphaTestReferenceValue: 0.5
+    mipMapFadeDistanceStart: 1
+    mipMapFadeDistanceEnd: 3
+  bumpmap:
+    convertToNormalMap: 0
+    externalNormalMap: 0
+    heightScale: 0.25
+    normalMapFilter: 0
+    flipGreenChannel: 0
+  isReadable: 0
+  streamingMipmaps: 0
+  streamingMipmapsPriority: 0
+  vTOnly: 0
+  ignoreMipmapLimit: 0
+  grayScaleToAlpha: 0
+  generateCubemap: 6
+  cubemapConvolution: 0
+  seamlessCubemap: 0
+  textureFormat: 1
+  maxTextureSize: 2048
+  textureSettings:
+    serializedVersion: 2
+    filterMode: 1
+    aniso: 1
+    mipBias: 0
+    wrapU: 1
+    wrapV: 1
+    wrapW: 0
+  nPOTScale: 0
+  lightmap: 0
+  compressionQuality: 50
+  spriteMode: 2
+  spriteExtrude: 1
+  spriteMeshType: 1
+  alignment: 0
+  spritePivot: {x: 0.5, y: 0.5}
+  spritePixelsToUnits: 100
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+  spriteGenerateFallbackPhysicsShape: 1
+  alphaUsage: 1
+  alphaIsTransparency: 1
+  spriteTessellationDetail: -1
+  textureType: 8
+  textureShape: 1
+  singleChannelComponent: 0
+  flipbookRows: 1
+  flipbookColumns: 1
+  maxTextureSizeSet: 0
+  compressionQualitySet: 0
+  textureFormatSet: 0
+  ignorePngGamma: 0
+  applyGammaDecoding: 0
+  swizzle: 50462976
+  cookieLightType: 0
+  platformSettings:
+  - serializedVersion: 4
+    buildTarget: DefaultTexturePlatform
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    ignorePlatformSupport: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 4
+    buildTarget: Standalone
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    ignorePlatformSupport: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 4
+    buildTarget: Android
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    ignorePlatformSupport: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 4
+    buildTarget: iOS
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    ignorePlatformSupport: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  spriteSheet:
+    serializedVersion: 2
+    sprites:
+    - serializedVersion: 2
+      name: Walkdogs_0
+      rect:
+        serializedVersion: 2
+        x: 66
+        y: 1044
+        width: 426
+        height: 426
+      alignment: 0
+      pivot: {x: 0, y: 0}
+      border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
+      outline: []
+      physicsShape: []
+      tessellationDetail: 0
+      bones: []
+      spriteID: 62fbd36bc7fec754dbea50f805149f4c
+      internalID: 185447995
+      vertices: []
+      indices: 
+      edges: []
+      weights: []
+    - serializedVersion: 2
+      name: Walkdogs_1
+      rect:
+        serializedVersion: 2
+        x: 564
+        y: 1050
+        width: 918
+        height: 420
+      alignment: 0
+      pivot: {x: 0, y: 0}
+      border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
+      outline: []
+      physicsShape: []
+      tessellationDetail: 0
+      bones: []
+      spriteID: 637c59edf0f1b074b982573e5428846e
+      internalID: 40115691
+      vertices: []
+      indices: 
+      edges: []
+      weights: []
+    - serializedVersion: 2
+      name: Walkdogs_2
+      rect:
+        serializedVersion: 2
+        x: 70
+        y: 564
+        width: 422
+        height: 426
+      alignment: 0
+      pivot: {x: 0, y: 0}
+      border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
+      outline: []
+      physicsShape: []
+      tessellationDetail: 0
+      bones: []
+      spriteID: 1fe82937d2224e54da059687efe132c0
+      internalID: 1876664999
+      vertices: []
+      indices: 
+      edges: []
+      weights: []
+    - serializedVersion: 2
+      name: Walkdogs_3
+      rect:
+        serializedVersion: 2
+        x: 564
+        y: 564
+        width: 426
+        height: 426
+      alignment: 0
+      pivot: {x: 0, y: 0}
+      border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
+      outline: []
+      physicsShape: []
+      tessellationDetail: 0
+      bones: []
+      spriteID: 6cf686146d5eb344d993a0b65878d6d2
+      internalID: -347189468
+      vertices: []
+      indices: 
+      edges: []
+      weights: []
+    - serializedVersion: 2
+      name: Walkdogs_4
+      rect:
+        serializedVersion: 2
+        x: 1050
+        y: 564
+        width: 432
+        height: 426
+      alignment: 0
+      pivot: {x: 0, y: 0}
+      border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
+      outline: []
+      physicsShape: []
+      tessellationDetail: 0
+      bones: []
+      spriteID: e0f6af4e11324b54cab83e253f5437d0
+      internalID: -63656680
+      vertices: []
+      indices: 
+      edges: []
+      weights: []
+    - serializedVersion: 2
+      name: Walkdogs_5
+      rect:
+        serializedVersion: 2
+        x: 66
+        y: 72
+        width: 426
+        height: 426
+      alignment: 0
+      pivot: {x: 0, y: 0}
+      border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
+      outline: []
+      physicsShape: []
+      tessellationDetail: 0
+      bones: []
+      spriteID: ce252bce3bf387f478066274b65557bd
+      internalID: 1679316319
+      vertices: []
+      indices: 
+      edges: []
+      weights: []
+    - serializedVersion: 2
+      name: Walkdogs_6
+      rect:
+        serializedVersion: 2
+        x: 558
+        y: 72
+        width: 432
+        height: 426
+      alignment: 0
+      pivot: {x: 0, y: 0}
+      border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
+      outline: []
+      physicsShape: []
+      tessellationDetail: 0
+      bones: []
+      spriteID: f00e4d36571af374c9032d901177773f
+      internalID: 374388395
+      vertices: []
+      indices: 
+      edges: []
+      weights: []
+    - serializedVersion: 2
+      name: Walkdogs_7
+      rect:
+        serializedVersion: 2
+        x: 1050
+        y: 72
+        width: 432
+        height: 426
+      alignment: 0
+      pivot: {x: 0, y: 0}
+      border: {x: 0, y: 0, z: 0, w: 0}
+      customData: 
+      outline: []
+      physicsShape: []
+      tessellationDetail: 0
+      bones: []
+      spriteID: 3f4f074a25769bc47922d8f0d09bbd45
+      internalID: -1931782189
+      vertices: []
+      indices: 
+      edges: []
+      weights: []
+    outline: []
+    customData: 
+    physicsShape: []
+    bones: []
+    spriteID: 3a8e9a7c54ff27c4d8d088f253e14b0e
+    internalID: 0
+    vertices: []
+    indices: 
+    edges: []
+    weights: []
+    secondaryTextures: []
+    spriteCustomMetadata:
+      entries: []
+    nameFileIdTable:
+      Walkdogs_0: 185447995
+      Walkdogs_1: 40115691
+      Walkdogs_2: 1876664999
+      Walkdogs_3: -347189468
+      Walkdogs_4: -63656680
+      Walkdogs_5: 1679316319
+      Walkdogs_6: 374388395
+      Walkdogs_7: -1931782189
+  mipmapLimitGroupName: 
+  pSDRemoveMatte: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 3 - 4
Assets/Resources/Shopping/ShoppingController.cs

@@ -282,7 +282,7 @@ public class ShoppingController : MonoBehaviour
     {
         Debug.Log("Purchase item request");
 
-        string url = "/api/item/puchase/";
+        string url = "/api/item/purchase/";
         WWWForm form = new();
         form.AddField("user_id", UserProperty.userId);
         form.AddField("item_id", itemId);
@@ -302,9 +302,8 @@ public class ShoppingController : MonoBehaviour
             UserProperty.FreshUserInfo(userInfo);
 
             // TODO 然后重新写入道具数据
-            UserProperty.food.Clear();
-            UserProperty.toy.Clear();
-            UserProperty.other.Clear();
+            string props = data["props"].ToString();
+            UserProperty.FreshUserItems(props);
 
             // 弹出窗户提示购买成功
             string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "shoppingUI", "message", "purchase_success", EnviromentSetting.languageCode });

+ 6 - 5
Assets/Resources/VoiceAndManu/MenuController.cs

@@ -50,8 +50,8 @@ public class MenuController : MonoBehaviour
         subMenu.Add(warehouse);
         var status = menuArea.Q<VisualElement>("status");       // 宠物状态
         subMenu.Add(status);
-        var cameraBtn = menuArea.Q<VisualElement>("camera");        // AR摄像头
-        subMenu.Add(cameraBtn);
+        var walkdogsBtn = menuArea.Q<VisualElement>("walkdogs");        // AR摄像头
+        subMenu.Add(walkdogsBtn);
 
 
         mainMenu.RegisterCallback<ClickEvent>(e => MainMenuClick(e));
@@ -63,7 +63,7 @@ public class MenuController : MonoBehaviour
         shop.RegisterCallback<ClickEvent>(e => ShopClick(e));
         warehouse.RegisterCallback<ClickEvent>(e => WarehouseClick(e));
         status.RegisterCallback<ClickEvent>(e => StatusClick(e));
-        cameraBtn.RegisterCallback<ClickEvent>(e => CameraClick(e));
+        walkdogsBtn.RegisterCallback<ClickEvent>(e => WalkdogsClick(e));
         home.RegisterCallback<ClickEvent>(e => HomeClick(e));
 
         //var root = GetComponent<UIDocument>().rootVisualElement;
@@ -200,9 +200,10 @@ public class MenuController : MonoBehaviour
         userInfoUI.SetActive(true);
     }
 
-    void CameraClick(ClickEvent evt)
+    void WalkdogsClick(ClickEvent evt)
     {
-        MaskTransitions.TransitionManager.Instance.LoadLevel("ARScene");
+        MaskTransitions.TransitionManager.Instance.LoadLevel("WalkDogs");
+        // SceneManager.LoadScene("WalkDogs", LoadSceneMode.Single);
     }
 
     // 菜单打开后收回菜单

+ 1 - 1
Assets/Resources/VoiceAndManu/VoiceAndMenu.uxml

@@ -8,7 +8,7 @@
             <ui:VisualElement name="status" class="subMenu" style="top: 111px; left: 86px; background-image: url(&quot;project://database/Assets/Pictures/menu%20icons/status.png?fileID=2800000&amp;guid=2a30515557e15584089b7100924be084&amp;type=3#status&quot;);" />
             <ui:VisualElement name="home" class="subMenu" style="background-image: url(&quot;project://database/Assets/Pictures/menu%20icons/Home.png?fileID=2800000&amp;guid=06f80d83d75e2db4bb5e1e4f6b2b98e0&amp;type=3#Home&quot;); top: 5px; left: 99px;" />
             <ui:VisualElement name="playground" class="subMenu" style="background-image: url(&quot;project://database/Assets/Pictures/menu%20icons/playground2.png?fileID=2800000&amp;guid=e4fcd1fcd94d0b44b80ee061a4ffc4df&amp;type=3#playground2&quot;); top: 13px; left: 58px;" />
-            <ui:VisualElement name="camera" class="subMenu" style="top: 41px; left: 33px; display: flex; background-image: url(&quot;project://database/Assets/Pictures/menu%20icons/camera.png?fileID=2800000&amp;guid=7ff80acc97c14eb439900fed207f566b&amp;type=3#camera&quot;);" />
+            <ui:VisualElement name="walkdogs" class="subMenu" style="top: 41px; left: 33px; display: flex; background-image: url(&quot;project://database/Assets/Pictures/menu%20icons/Walkdogs.png?fileID=1679316319&amp;guid=cacf9fa8e8a6b784fb1128fca1f0bd57&amp;type=3#Walkdogs_5&quot;);" />
             <ui:VisualElement name="mainMenu" class="subMenu" style="background-image: url(&quot;project://database/Assets/Packages/2D%20Casual%20UI/Sprite/GUI.png?fileID=21300072&amp;guid=1eaee135ce037439d925cee5e41ce026&amp;type=3#GUI_36&quot;); width: 25%; height: 25%; position: absolute; top: 52px; left: 85px; bottom: auto; visibility: visible;" />
         </ui:VisualElement>
         <ui:VisualElement name="voiceArea" style="flex-grow: 1; position: absolute; bottom: 2%; flex-direction: column; justify-content: space-around; align-items: center; align-content: flex-start; width: 100%; visibility: visible;">

+ 1 - 2
Assets/Resources/Warehouse/WarehouseController.cs

@@ -195,8 +195,7 @@ public class WarehouseController : MonoBehaviour
     {
         msgRoot.visible = false;
     }
-    // msg yes button 点击
-    // todo 以后在这里添加调出确认页面,确认后将道具使用请求给服务器
+
     void MsgYesClick()
     {
         //Debug.Log("msg yes clicked");

+ 1 - 0
Assets/Scenes/Login/CreateOrAdopt.uxml

@@ -9,4 +9,5 @@
             <engine:Button text="Adopt" name="adopt" class="button" style="display: flex;" />
         </engine:VisualElement>
     </engine:VisualElement>
+    <engine:VisualElement name="backHome" style="flex-grow: 1; background-image: url(&quot;project://database/Assets/Packages/2D%20Casual%20UI/Sprite/GUI.png?fileID=21300070&amp;guid=1eaee135ce037439d925cee5e41ce026&amp;type=3#GUI_35&quot;); position: absolute; width: 25px; height: 25px; right: 15px; top: 15px; display: none;" />
 </engine:UXML>

+ 1 - 0
Assets/Scripts/GameControllers/GameData.cs

@@ -18,5 +18,6 @@ public static class GameData
     public static string subScene;      // 用于指定子场景用
     public static string playedToy = string.Empty;        // 用于暂存游戏中使用的玩具
     public static string bathItemId = string.Empty;        // 用于暂存洗澡场景中使用的道具
+    public static bool hasRemindedRegister = false;      // 用于暂存是否已经提醒用户注册
     #endregion
 }

+ 33 - 6
Assets/Scripts/Login/CreateOrAdopt.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using Newtonsoft.Json;
 using UnityEngine;
+using UnityEngine.SceneManagement;
 using UnityEngine.UI;
 using UnityEngine.UIElements;
 using ZXing;
@@ -14,6 +15,7 @@ public class CreateOrAdopt : MonoBehaviour
     private Label messageLabel;
     private Button createBtn, adoptBtn, cancelBtn;
     GameObject canvasPlaceholder, initDogCanvas, createAdoptCanvas, cameraContent;
+    private VisualElement backHome;
 
     public RawImage cameraTexture; // 摄像头画面显示区域
     private WebCamTexture webCamTexture; // 摄像头纹理
@@ -28,6 +30,7 @@ public class CreateOrAdopt : MonoBehaviour
         createBtn = root.Q<Button>("create");
         adoptBtn = root.Q<Button>("adopt");
         cancelBtn = root.Q<Button>("cancel");
+        backHome = root.Q<VisualElement>("backHome");
 
         canvasPlaceholder = GameObject.Find("Canvas Placeholder");
         initDogCanvas = canvasPlaceholder.transform.Find("Init Dog Canvas").gameObject;
@@ -36,6 +39,7 @@ public class CreateOrAdopt : MonoBehaviour
         createBtn.RegisterCallback<ClickEvent>(e => CreateClick(e));
         adoptBtn.RegisterCallback<ClickEvent>(e => AdoptClick(e));
         cancelBtn.RegisterCallback<ClickEvent>(e => CancelClick(e));
+        backHome.RegisterCallback<ClickEvent>(e => BackHomeClick(e));
 
         string textValue = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "InitDogUI", "button", "create", EnviromentSetting.languageCode });
         createBtn.text = textValue;
@@ -49,10 +53,16 @@ public class CreateOrAdopt : MonoBehaviour
         cameraContent = createAdoptCanvas.transform.Find("Camera Content").gameObject;
         cameraContent.SetActive(false);
 
-        // if (UserProperty.dogs.Count > 0)
-        // {
-        //     SwitchToCreate();
-        // }
+        if (UserProperty.dogs.Count > 0)
+        {
+            // backHome按键显示
+            backHome.style.display = DisplayStyle.Flex;
+        }
+        else
+        {
+            // backHome按键隐藏
+            backHome.style.display = DisplayStyle.None;
+        }
     }
 
     // Update is called once per frame
@@ -113,6 +123,12 @@ public class CreateOrAdopt : MonoBehaviour
         cancelBtn.style.display = DisplayStyle.None;
     }
 
+    void BackHomeClick(ClickEvent e)
+    {
+        // 返回Home场景
+        SceneManager.LoadScene("Home");
+    }
+
     private void InitCamera()
     {
         WebCamDevice[] devices = WebCamTexture.devices;
@@ -187,15 +203,26 @@ public class CreateOrAdopt : MonoBehaviour
             // 成功处理逻辑
             string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "InitDogUI", "message", "receive_success", EnviromentSetting.languageCode });
             msg = msg.Replace("<<dog_name>>", data["dog_name"].ToString());
-            MessageBoxController.ShowMessage(msg, () => GameTool.ReloadCurrentScene());
+            MessageBoxController.ShowMessage(msg, () => AdoptionSuccessHandler());
         }
         else
         {
             // 失败处理逻辑
             string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "InitDogUI", "message", "receive_fail", EnviromentSetting.languageCode });
-            MessageBoxController.ShowMessage(msg, () => GameTool.ReloadCurrentScene());
+            MessageBoxController.ShowMessage(msg);
             ClickEvent e = new ClickEvent();
             CancelClick(e);
         }
     }
+
+    private void AdoptionSuccessHandler()
+    {
+        // 领养成功后的处理逻辑
+        // 以下三行代码不知道为什么要加,但是不加会报错
+        var canvasPlaceholder = GameObject.Find("Canvas Placeholder");
+        var loginCanvas = canvasPlaceholder.transform.Find("Login Canvas").gameObject;
+        loginCanvas.SetActive(true);
+        LoginController.instance.GetUserData();
+    }
+
 }

+ 29 - 10
Assets/Scripts/Login/LoginController.cs

@@ -19,6 +19,16 @@ public class LoginController : MonoBehaviour
     // Start is called once before the first execution of Update after the MonoBehaviour is created
     private GameObject canvasPlaceholder, regCanvas, createAdoptCanvas, loginCanvas;
 
+    public static LoginController instance; // 用于在其他脚本中调用LoginController的函数
+    private void Awake()
+    {
+        // 确保loginController在Awake阶段被正确赋值
+        if (instance == null)
+        {
+            instance = this;
+        }
+    }
+
     void Start()
     {
         canvasPlaceholder = GameObject.Find("Canvas Placeholder");
@@ -86,7 +96,7 @@ public class LoginController : MonoBehaviour
         if (UserProperty.userId != null && EnviromentSetting.accessToken != null)
         {
             // 启动获取用户信息请求
-            StartCoroutine(GetUserData());
+            GetUserData();
         }
         else
         {
@@ -156,10 +166,9 @@ public class LoginController : MonoBehaviour
         Application.Quit();
     }
 
-    IEnumerator GetUserData()
+    public void GetUserData()
     {
         Debug.Log("GetUserData request");
-        yield return null;      // 跳过第一帧
         // 提交POST
         string url = "/api/user/info/";
         WWWForm form = new();
@@ -187,15 +196,25 @@ public class LoginController : MonoBehaviour
             {
                 SwitchToInitDogScene();
             }
+            // 如果非注册用户,提示用户注册
             else if (!UserProperty.isRegUser)
             {
+                // 如果没有提醒过
+                if (!GameData.hasRemindedRegister)
+                {
+                    GameData.hasRemindedRegister = true;
+                    var canvasPlaceholder = GameObject.Find("Canvas Placeholder");
+                    var loginCanvas = canvasPlaceholder.transform.Find("Login Canvas").gameObject;
+                    loginCanvas.SetActive(false);
+                    string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "reg_reminder", EnviromentSetting.languageCode });
+                    //MessageBoxController.YorN_Message(msg, ()=> regCanvas.SetActive(true), ()=> SceneManager.LoadScene("Home"));
+                    MessageBoxController.YorN_Message(msg, () => regCanvas.SetActive(true), () => MaskTransitions.TransitionManager.Instance.LoadLevel("Home"));
+                }
+                else
+                {
+                    MaskTransitions.TransitionManager.Instance.LoadLevel("Home");
+                }
 
-                // 如果非注册用户,提示用户注册
-                var loginCanvas = GameObject.Find("Login Canvas");
-                loginCanvas.SetActive(false);
-                string msg = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "game_message", "reg_reminder", EnviromentSetting.languageCode });
-                //MessageBoxController.YorN_Message(msg, ()=> regCanvas.SetActive(true), ()=> SceneManager.LoadScene("Home"));
-                MessageBoxController.YorN_Message(msg, () => regCanvas.SetActive(true), () => MaskTransitions.TransitionManager.Instance.LoadLevel("Home"));
 
             }
             else
@@ -305,7 +324,7 @@ public class LoginController : MonoBehaviour
             if (UserProperty.userId != null && EnviromentSetting.accessToken != null)
             {
                 // 启动获取用户信息请求
-                StartCoroutine(GetUserData());
+                GetUserData();
             }
             else
             {

+ 1 - 1
Assets/Scripts/WalkDogs/NoteController.cs

@@ -22,7 +22,7 @@ public class NoteController : MonoBehaviour
         hitLeadTime = GameData.noteStartLeadTime; // 获取音符提前创建的时间
         transform.position = new Vector3(-1 * hitLeadTime * speed, -2, 5); // 初始化音符位置
         transform.localScale = NoteSize(); // 设置音符大小
-        endTime = hitTime + hitLeadTime; // 设置音符消失时间
+        endTime = Time.time + hitTime + hitLeadTime/2; // 设置音符消失时间
         if (action == "left")
         {
             transform.rotation = Quaternion.Euler(0, 0, -90); // 设置音符旋转角度

+ 1 - 1
Assets/Scripts/WalkDogs/SoundGame/SoundTrackManager.cs

@@ -84,7 +84,7 @@ public class SoundTrackManager
             }
             else if (randomInt == 6)
             {
-                time += timeGap * combo / 4;
+                time += timeGap * combo / 6;
             }
             
         }

+ 8 - 1
Assets/Scripts/WalkDogs/SoundGameController.cs

@@ -54,6 +54,7 @@ public class SoundGameController : MonoBehaviour
         AudioClip audioClip = Resources.Load<AudioClip>(soundTrackManager.soundTrack);
         AudioSource audioSource = gameObject.AddComponent<AudioSource>();
         audioSource.clip = audioClip;
+        yield return new WaitForSeconds(2f); // 等待音频加载完成
         audioSource.Play();
 
         gameStartTime = Time.time;
@@ -64,7 +65,7 @@ public class SoundGameController : MonoBehaviour
             // 用于提前n秒创建音符
             foreach (var note in soundTrackManager.soundAction)
             {
-                if (!note.isActive && Time.time >= (note.time - GameData.noteStartLeadTime))
+                if (!note.isActive && Time.time >= (gameStartTime + note.time - GameData.noteStartLeadTime))
                 {
                     note.isActive = true;
                     CreateNote(note.time, note.action, soundTrackManager.soundAction.IndexOf(note).ToString());
@@ -120,10 +121,16 @@ public class SoundGameController : MonoBehaviour
         if (action == "tap")
         {
             note = Instantiate(notePrefabTap);
+            Debug.Log("Create Tap Note: " + noteName);
+            Debug.Log("Hit Time: " + hitTime + ", Action: " + action);
+            Debug.Log("Create Time: " + Time.time);
         }
         else
         {
             note = Instantiate(notePrefabSwipe);
+            Debug.Log("Create Tap Note: " + noteName);
+            Debug.Log("Hit Time: " + hitTime + ", Action: " + action);
+            Debug.Log("Create Time: " + Time.time);
         }
         note.gameObject.name = "note_" + noteName;
         NoteController noteController = note.GetComponent<NoteController>();

+ 3 - 0
ProjectSettings/EditorBuildSettings.asset

@@ -20,5 +20,8 @@ EditorBuildSettings:
   - enabled: 1
     path: Assets/Scenes/Bathroom.unity
     guid: 928c5be61ebde2b4ea4268318553ad79
+  - enabled: 1
+    path: Assets/Scenes/WalkDogs.unity
+    guid: f762b727b9f9c6443a6f821ac6000c19
   m_configObjects: {}
   m_UseUCBPForAssetBundles: 0