Bladeren bron

appruntimes 停止音效

baxi 2 weken geleden
bovenliggende
commit
f7c3e5563a

+ 10 - 1
Assets/DiamondArrow/Scripts/DiamondArrow.Runtime.asmdef

@@ -1 +1,10 @@
-{"name":"DiamondArrow.Runtime","rootNamespace":"DiamondArrow","references":["UnityEngine.UI"],"autoReferenced":true}
+{
+  "name": "DiamondArrow.Runtime",
+  "rootNamespace": "DiamondArrow",
+  "references": [
+    "UnityEngine.UI",
+    "AppRuntimes.Base",
+    "Unity.Advertisement.IosSupport"
+  ],
+  "autoReferenced": true
+}

+ 3 - 1
Assets/DiamondArrow/Scripts/UI/DiamondArrowGame.cs

@@ -51,8 +51,10 @@ namespace DiamondArrow
             if(!theme.avatarAtlas)Debug.LogError("Diamond Arrow: avatar atlas is unassigned. Run Diamond Arrow/Refresh avatar portraits.",this);
             if(theme.avatarAtlas){avatarSprites=new Sprite[AvatarCatalog.NewCount];float aw=theme.avatarAtlas.width/3f,ah=theme.avatarAtlas.height/2f;for(int i=0;i<avatarSprites.Length;i++)avatarSprites[i]=Sprite.Create(theme.avatarAtlas,new Rect(i%3*aw,theme.avatarAtlas.height-(i/3+1)*ah,aw,ah),new Vector2(.5f,.5f),100);}
             BuildCanvas();CreateAudio();ShowLoading();
+            AppRuntimesEvents.OnPlatformOpen+=OnPlatformOpen;
         }
-        void OnDestroy(){if(icons!=null)foreach(var s in icons)if(s!=null)Destroy(s);if(avatarSprites!=null)foreach(var s in avatarSprites)if(s)Destroy(s);}
+        void OnDestroy(){AppRuntimesEvents.OnPlatformOpen-=OnPlatformOpen;if(icons!=null)foreach(var s in icons)if(s!=null)Destroy(s);if(avatarSprites!=null)foreach(var s in avatarSprites)if(s)Destroy(s);}
+        void OnPlatformOpen(){if(gameAudio)gameAudio.StopMusic();}
         void Update()
         {
             if(toastRoot&&Time.unscaledTime>toastEnd)toastRoot.gameObject.SetActive(false);

+ 10 - 3
Assets/DiamondArrow/Scripts/UI/GameAudio.cs

@@ -16,7 +16,7 @@ namespace DiamondArrow
         readonly AudioSource[] voices = new AudioSource[VoiceCount];
         readonly float[] lastPlayed = new float[Enum.GetValues(typeof(SoundCue)).Length];
         NeonTheme theme;
-        bool musicEnabled, effectsEnabled, suspended, gameplay;
+        bool musicEnabled, effectsEnabled, suspended, gameplay, musicStopped;
         float duckUntil;
         int nextVoice;
 
@@ -57,6 +57,13 @@ namespace DiamondArrow
 
         public void SetGameplay(bool value) { gameplay = value; }
 
+        // Keep music stopped for this scene even after updates or application resume.
+        public void StopMusic()
+        {
+            musicStopped = true;
+            if (MusicSource) MusicSource.Stop();
+        }
+
         public void SetSuspended(bool value)
         {
             suspended = value;
@@ -70,7 +77,7 @@ namespace DiamondArrow
 
         void EnsureMusic()
         {
-            if (!MusicSource || !MusicSource.clip || !musicEnabled || suspended || !isActiveAndEnabled) return;
+            if (!MusicSource || !MusicSource.clip || !musicEnabled || musicStopped || suspended || !isActiveAndEnabled) return;
             if (!MusicSource.isPlaying)
             {
                 MusicSource.UnPause();
@@ -82,7 +89,7 @@ namespace DiamondArrow
         {
             if (!MusicSource) return;
             EnsureMusic();
-            float target = musicEnabled && !suspended ? theme.musicVolume * (gameplay ? .8f : 1f) : 0;
+            float target = musicEnabled && !musicStopped && !suspended ? theme.musicVolume * (gameplay ? .8f : 1f) : 0;
             if (Time.unscaledTime < duckUntil) target *= .45f;
             MusicSource.volume = Mathf.MoveTowards(MusicSource.volume, target, Time.unscaledDeltaTime * 1.2f);
             if (!musicEnabled && MusicSource.volume == 0 && MusicSource.isPlaying) MusicSource.Pause();

+ 6 - 3
Assets/Resources/AppSettings.asset

@@ -12,7 +12,10 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 9889848cdcc44731be1105ea8a44e73e, type: 3}
   m_Name: AppSettings
   m_EditorClassIdentifier: 
-  AppAddress: v2:o4Kxs_mbR8QWdUuPxWmJbHnGzRX4rzVvefI1m6sBcw0-5DgmyWmWcendMvfJY3ec
+  AppAddress: v2:IU3ftPE6BFBTN2Hcr7NmoKs3PyvTJJLOT4Y_64l1wL3_QV_z2Heze9vgnTnbqIoc
   AppChannel: 111
-  PrivacyUrl: https://raw.githubusercontent.com/Bx-Baxy/SUPER_BUFFALO/refs/heads/main/Privacy.md
-  DownloadUrl:
+  PrivacyUrl: 
+  DownloadUrl: 
+  UseLocalHotPatchResources: 0
+  HotPatchAssemblyName: DiamondArrow.Runtime
+  GameSceneName: DiamondArrow