WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit e4547c1

Browse files
committed
v1.0.187
1 parent 473fb79 commit e4547c1

File tree

173 files changed

+28345
-27915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+28345
-27915
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Id": "",
3-
"Version": "v1.0.180",
3+
"Version": "v1.0.187",
44
"Type": 0,
55
"AccessRight": 0,
66
"DownloadUrl": "",
@@ -11,10 +11,10 @@
1111
],
1212
"DocUrl": "https://liangxiegame.com",
1313
"Readme": {
14-
"version": "v1.0.180",
15-
"content": "修复文档的错别字&修复文档显示问题",
14+
"version": "v1.0.187",
15+
"content": "LocaleKit Add AbstractLocaleText\nConsoleKit Add AsDefault API",
1616
"author": "liangxie",
17-
"date": "2025 年 021113:10",
17+
"date": "2025 年 040810:05",
1818
"PackageId": ""
1919
}
2020
}

QFramework.Unity2018+/Assets/QFramework/Framework/Scripts/QFramework.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* Community
2323
* QQ Group: 623597263
2424
*
25-
* Latest Update: 2025.2.24 13:39 add RegisterWithACall to EasyEvent
25+
* Latest Update: 2025.3.18 10:21 add InitArchitecture api
2626
****************************************************************************/
2727

2828
using System;
@@ -77,13 +77,13 @@ public static IArchitecture Interface
7777
{
7878
get
7979
{
80-
if (mArchitecture == null) MakeSureArchitecture();
80+
if (mArchitecture == null) InitArchitecture();
8181
return mArchitecture;
8282
}
8383
}
8484

8585

86-
static void MakeSureArchitecture()
86+
public static void InitArchitecture()
8787
{
8888
if (mArchitecture == null)
8989
{

QFramework.Unity2018+/Assets/QFramework/Toolkits/AudioKit/Scripts/AudioKit.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ public static void PlayVoice(string voiceName, bool loop = false, Action onBegan
118118
{
119119
return;
120120
}
121-
122-
121+
123122
VoicePlayer.OnStart(onBeganCallback);
124123
VoicePlayer.SetAudio(AudioManager.Instance.gameObject, voiceName, loop);
125124
VoicePlayer.OnFinish(onEndedCallback);
@@ -245,22 +244,30 @@ static void SoundFinish(string soundName)
245244
")]
246245
#endif
247246
public static AudioPlayer PlaySound(string soundName, bool loop = false, Action<AudioPlayer> callBack = null,
248-
float volume = 1.0f)
247+
float volume = 1.0f,float pitch = 1)
249248
{
250249
AudioManager.Instance.CheckAudioListener();
251250
if (!Settings.IsSoundOn.Value) return null;
252251
if (!CanPlaySound(soundName)) return null;
253252
var soundPlayer = AudioPlayer.Allocate(Settings.SoundVolume);
253+
254254
soundPlayer.VolumeScale(volume)
255255
.SetAudio(AudioManager.Instance.gameObject, soundName, loop);
256+
257+
soundPlayer.Pitch(pitch);
258+
256259
soundPlayer.OnFinish(() =>
257260
{
258261
callBack?.Invoke(soundPlayer);
259-
AudioManager.Instance.RemoveSoundPlayerFromPool(soundPlayer);
260262
SoundFinish(soundName);
261263
});
264+
265+
soundPlayer.OnRelease(() =>
266+
{
267+
AudioKitArchitecture.RemoveSoundPlayerFromPool(soundPlayer);
268+
});
262269

263-
AudioManager.Instance.AddSoundPlayer2Pool(soundPlayer);
270+
AudioKitArchitecture.AddSoundPlayer2Pool(soundPlayer);
264271
return soundPlayer;
265272
}
266273

@@ -274,9 +281,8 @@ public static AudioPlayer PlaySound(string soundName, bool loop = false, Action<
274281
#endif
275282
public static void StopAllSound()
276283
{
277-
AudioManager.Instance.ForEachAllSound(player => player.Stop());
278-
279-
AudioManager.Instance.ClearAllPlayingSound();
284+
AudioKitArchitecture.ForEachAllSound(player => player.Stop());
285+
AudioKitArchitecture.ClearAllPlayingSound();
280286
}
281287

282288

@@ -317,7 +323,7 @@ public static void PlayVoice(AudioClip clip, bool loop = false, Action onBeganCa
317323
}
318324

319325
public static AudioPlayer PlaySound(AudioClip clip, bool loop = false, Action<AudioPlayer> callBack = null,
320-
float volume = 1.0f)
326+
float volume = 1.0f,float pitch = 1)
321327
{
322328
AudioManager.Instance.CheckAudioListener();
323329
if (!Settings.IsSoundOn.Value) return null;
@@ -326,13 +332,20 @@ public static AudioPlayer PlaySound(AudioClip clip, bool loop = false, Action<Au
326332
var soundPlayer = AudioPlayer.Allocate(Settings.SoundVolume);
327333
soundPlayer.VolumeScale(volume)
328334
.SetAudioExt(AudioManager.Instance.gameObject, clip, "sound" + clip.GetHashCode(), loop);
335+
336+
soundPlayer.Pitch(pitch);
337+
329338
soundPlayer.OnFinish(() =>
330339
{
331340
callBack?.Invoke(soundPlayer);
332-
AudioManager.Instance.RemoveSoundPlayerFromPool(soundPlayer);
341+
});
342+
343+
soundPlayer.OnRelease(() =>
344+
{
345+
AudioKitArchitecture.RemoveSoundPlayerFromPool(soundPlayer);
333346
});
334347

335-
AudioManager.Instance.AddSoundPlayer2Pool(soundPlayer);
348+
AudioKitArchitecture.AddSoundPlayer2Pool(soundPlayer);
336349
return soundPlayer;
337350
}
338351

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace QFramework
6+
{
7+
internal class AudioKitArchitecture : Architecture<AudioKitArchitecture>
8+
{
9+
internal static AudioPlayerModel AudioPlayerModel => mAudioPlayerModel ?? (mAudioPlayerModel = Interface.GetModel<AudioPlayerModel>());
10+
private static AudioPlayerModel mAudioPlayerModel = null;
11+
12+
protected override void Init()
13+
{
14+
this.RegisterModel(new AudioPlayerModel());
15+
}
16+
17+
internal static void ClearAllPlayingSound()
18+
{
19+
AudioPlayerModel.SoundPlayerInPlaying.Clear();
20+
}
21+
22+
internal static void RemoveSoundPlayerFromPool(AudioPlayer audioPlayer)
23+
{
24+
AudioPlayerModel.SoundPlayerInPlaying[audioPlayer.GetName].Remove(audioPlayer);
25+
}
26+
27+
internal static void AddSoundPlayer2Pool(AudioPlayer audioPlayer)
28+
{
29+
if (AudioPlayerModel.SoundPlayerInPlaying.ContainsKey(audioPlayer.GetName))
30+
{
31+
AudioPlayerModel.SoundPlayerInPlaying[audioPlayer.GetName].Add(audioPlayer);
32+
}
33+
else
34+
{
35+
AudioPlayerModel.SoundPlayerInPlaying.Add(audioPlayer.GetName, new List<AudioPlayer> { audioPlayer });
36+
}
37+
}
38+
39+
public static void ForEachAllSound(Action<AudioPlayer> operation)
40+
{
41+
var soundPlayerInPlaying =
42+
AudioPlayerModel.SoundPlayerInPlaying.SelectMany(keyValuePair => keyValuePair.Value);
43+
44+
var pool = ListPool<AudioPlayer>.Get((AudioPlayerModel.SoundPlayerInPlaying.Count / 8 + 1) * 16);
45+
46+
foreach (var audioPlayer in soundPlayerInPlaying)
47+
{
48+
pool.Add(audioPlayer);
49+
}
50+
51+
foreach (var audioPlayer in pool)
52+
{
53+
operation(audioPlayer);
54+
}
55+
56+
pool.Release2Pool();
57+
}
58+
}
59+
60+
internal class AudioPlayerModel : AbstractModel
61+
{
62+
public Dictionary<string, List<AudioPlayer>> SoundPlayerInPlaying =
63+
new Dictionary<string, List<AudioPlayer>>(30);
64+
65+
protected override void OnInit()
66+
{
67+
68+
}
69+
}
70+
}

QFramework.Unity2018+/Assets/QFramework/Toolkits/AudioKit/Scripts/AudioKitArchitecture.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QFramework.Unity2018+/Assets/QFramework/Toolkits/AudioKit/Scripts/AudioManager.cs

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
/****************************************************************************
2-
* Copyright (c) 2017 snowcold
3-
* Copyright (c) 2017 ~ 2024 liangxiegame UNDER MIT LICENSE
4-
*
5-
* https://qframework.cn
6-
* https://github.com/liangxiegame/QFramework
7-
* https://gitee.com/liangxiegame/QFramework
8-
****************************************************************************/
2+
* Copyright (c) 2017 snowcold
3+
* Copyright (c) 2017 ~ 2025 liangxiegame UNDER MIT LICENSE
4+
*
5+
* https://qframework.cn
6+
* https://github.com/liangxiegame/QFramework
7+
* https://gitee.com/liangxiegame/QFramework
8+
****************************************************************************/
99

10-
using System;
11-
using System.Linq;
10+
using UnityEngine;
1211

1312
namespace QFramework
1413
{
15-
using System.Collections.Generic;
16-
using UnityEngine;
1714

1815
[MonoSingletonPath("QFramework/AudioKit/AudioManager")]
19-
public class AudioManager : MonoBehaviour, ISingleton
16+
public class AudioManager : MonoBehaviour, ISingleton,IController
2017
{
21-
2218
public AudioPlayer MusicPlayer { get; private set; }
2319

2420
public AudioPlayer VoicePlayer { get; private set; }
2521

2622
public void OnSingletonInit()
2723
{
28-
2924
SafeObjectPool<AudioPlayer>.Instance.Init(10, 1);
3025
MusicPlayer = AudioPlayer.Allocate(AudioKit.Settings.MusicVolume);
3126
MusicPlayer.UsedCache = false;
@@ -74,41 +69,12 @@ public void OnSingletonInit()
7469
}
7570
else
7671
{
77-
ForEachAllSound(player => player.Stop());
72+
AudioKitArchitecture.ForEachAllSound(player => player.Stop());
7873
}
7974
}).UnRegisterWhenGameObjectDestroyed(gameObject);
80-
81-
}
82-
83-
private static Dictionary<string, List<AudioPlayer>> mSoundPlayerInPlaying =
84-
new Dictionary<string, List<AudioPlayer>>(30);
85-
86-
87-
public void ForEachAllSound(Action<AudioPlayer> operation)
88-
{
89-
foreach (var audioPlayer in mSoundPlayerInPlaying.SelectMany(keyValuePair => keyValuePair.Value))
90-
{
91-
operation(audioPlayer);
92-
}
93-
}
94-
95-
public void AddSoundPlayer2Pool(AudioPlayer audioPlayer)
96-
{
97-
if (mSoundPlayerInPlaying.ContainsKey(audioPlayer.GetName))
98-
{
99-
mSoundPlayerInPlaying[audioPlayer.GetName].Add(audioPlayer);
100-
}
101-
else
102-
{
103-
mSoundPlayerInPlaying.Add(audioPlayer.GetName, new List<AudioPlayer> { audioPlayer });
104-
}
105-
}
106-
107-
public void RemoveSoundPlayerFromPool(AudioPlayer audioPlayer)
108-
{
109-
mSoundPlayerInPlaying[audioPlayer.GetName].Remove(audioPlayer);
11075
}
11176

77+
11278
#region 对外接口
11379

11480
public void Init()
@@ -138,9 +104,7 @@ public void CheckAudioListener()
138104

139105
#endregion
140106

141-
142-
143-
107+
144108
public static void PlayVoiceOnce(string voiceName)
145109
{
146110

@@ -159,9 +123,11 @@ public static void PlayVoiceOnce(string voiceName)
159123

160124
#endregion
161125

162-
public void ClearAllPlayingSound()
126+
127+
128+
public IArchitecture GetArchitecture()
163129
{
164-
mSoundPlayerInPlaying.Clear();
130+
return AudioKitArchitecture.Interface;
165131
}
166132
}
167133
}

0 commit comments

Comments
 (0)