From dc7922d80c1d133b6261b8af1d521567d2c0a35d Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 30 十月 2025 16:51:39 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts

---
 Main/System/Sound/SoundPlayer.cs |   57 +++++++++++++++++++++++++++++++++------------------------
 1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/Main/System/Sound/SoundPlayer.cs b/Main/System/Sound/SoundPlayer.cs
index e9f3d84..ad7e910 100644
--- a/Main/System/Sound/SoundPlayer.cs
+++ b/Main/System/Sound/SoundPlayer.cs
@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using UnityEngine;
 
-using vnxbqy.UI;
 using System;
 
 public class SoundPlayer : MonoBehaviour
@@ -12,8 +11,18 @@
 
     static readonly List<int> commonUseAudioSet = new List<int>() { defaultClickPositiveAudio, defaultClickNegativeAudio, 3, 4 };
 
-    public static SoundPlayer Instance {
-        get; set;
+    static SoundPlayer m_Instance = null;
+    public static SoundPlayer Instance
+    {
+        get
+        {
+            if (m_Instance == null)
+            {
+                CreateSoundPlayer();
+            }
+            return m_Instance;
+        }
+
     }
 
     [SerializeField] AudioSource m_MusicAudioSource;
@@ -46,9 +55,9 @@
     public static void CreateSoundPlayer()
     {
         var gameObject = GameObject.Instantiate(BuiltInLoader.LoadPrefab("SoundPlayer"));
-        Instance = gameObject.GetComponent<SoundPlayer>();
-        Instance.name = "SoundPlayer";
-        Instance.SetActive(true);
+        m_Instance = gameObject.GetComponent<SoundPlayer>();
+        m_Instance.name = "SoundPlayer";
+        m_Instance.SetActive(true);
         DontDestroyOnLoad(gameObject);
     }
 
@@ -125,14 +134,14 @@
 
     public void UnLoadMusic(int _exclude)
     {
-        if (!AssetSource.audioFromEditor && DeviceUtility.IsLowMemory())
+        if (AssetSource.isUseAssetBundle && DeviceUtility.IsLowMemory())
         {
             foreach (var key in musicAudioClipDict.Keys)
             {
                 if (key != _exclude)
                 {
                     var config = AudioConfig.Get(key);
-                    AssetBundleUtility.Instance.UnloadAsset("audio/music", config.Audio);
+                    ResManager.Instance.UnloadAsset("Audio/" + config.Folder, config.Audio);
                 }
             }
 
@@ -303,23 +312,23 @@
         }
     }
 
-    public void PlayLoginMusic()
-    {
-        var loginMusic = BuiltInLoader.LoadMusic("Music_Login");
-        if (!m_MusicAudioSource.isPlaying || m_MusicAudioSource.clip != loginMusic)
-        {
-            StartCoroutine(Co_BackGroundMusicFadeOutIn(loginMusic, false));
-        }
-    }
+    //public void PlayLoginMusic()
+    //{
+    //    var loginMusic = BuiltInLoader.LoadMusic("Music_Login");
+    //    if (!m_MusicAudioSource.isPlaying || m_MusicAudioSource.clip != loginMusic)
+    //    {
+    //        StartCoroutine(Co_BackGroundMusicFadeOutIn(loginMusic, false));
+    //    }
+    //}
 
-    private void LateUpdate()
-    {
-        // if (CameraController.Instance != null && CameraController.Instance.CameraObject != null)
-        // {
-        //     this.transform.position = CameraController.Instance.transform.position + new Vector3(0, 5, 0);
-        //     this.transform.rotation = CameraController.Instance.CameraObject.transform.rotation;
-        // }
-    }
+    //private void LateUpdate()
+    //{
+    //    if (CameraController.Instance != null && CameraController.Instance.CameraObject != null)
+    //    {
+    //        this.transform.position = CameraController.Instance.transform.position + new Vector3(0, 5, 0);
+    //        this.transform.rotation = CameraController.Instance.CameraObject.transform.rotation;
+    //    }
+    //}
 
     IEnumerator Co_BackGroundMusicFadeOutIn(AudioClip _clip, bool _oneShot)
     {

--
Gitblit v1.8.0