CSoundEffectMgr¶
t has multiple AudioSources to group, prioritize, and limit the number of simultaneous sound effects.
This is the default concurrency limit.
2D Audio: 4
3D Audio: 8
You can also set individual limits for the number of simultaneous sounds per group.
Find out how to configure these settings for SE here .
This manages AudioSources, eliminating the need for programmers to create their own AudioSources.
How to incorporate the manager¶
To use CSoundEffectMgr, it is necessary to add managers to the game object as follows.
public class CMainSystem : CMainSystemBase { //========================================================================== /*!Awake * @brief Unity Callback */ new void Awake() { base.Awake(); if (m_instance != null) { Debug.LogError("already exist CMainSystem"); return; } m_instance = this; // Add Component gameObject.AddComponent<CInput>(); if (KsSoftConfig.UseAssetBundle) { gameObject.AddComponent<CAssetBundleMgr>(); } gameObject.AddComponent<CSpriteFontMgr>(); gameObject.AddComponent<CTextureResourceMgr>(); gameObject.AddComponent<CWindowMgr>(); gameObject.AddComponent<CBgmResourceMgr>(); gameObject.AddComponent<CSeResourceMgr>(); gameObject.AddComponent<CSoundEffectMgr>(); addManager(new CMessageDataSheetMgr(Utility.getSystemLocale())); }
-
class CSoundEffectMgr
¶ -
void
playBgm
(CBgmResource cBgmResource)¶ - Param CBgmResource
Imported BGM Resource
-
void
playBgm
(UInt32 id) - Param uint id
Asset Bundle ID
Plays the specified BGM. If the specified asset bundle is not loaded, playback will start automatically after loading.If you want to explicitly wait for loading, wait until cBgmResource.isLoaded () returns true before playing.
To get the CBgmResource directly , you can write as follows.
IEnumerator load(uint id) { CBgmResource cBgmResource = CBgmResourceMgr.Instance.reference(id); if (cBgmResource == null) { // error!! yield break; } while (!cBgmResource.isLoaded()) { yield return 0; } CSoundEffectMgr.Instance.playBgm(cBgmResource); };
-
void
play
(CSoundEffect cSE)¶ - Param CSoundEffect cSE
The SE object available from CSeResource.
Plays the specified SE as 2D audio. You can get a CSoundEffect in the following ways:.
CSeResource m_cSR; : CSoundEffect cSE = m_cSR.find(id);
-
void
play
(UInt32 mAssetBundle, UInt32 id) - Param uint mAssetBundle
Asset Bundle ID
- Param uint id
SE ID
Plays the specified SE as 2D audio.
-
void
play
(CSoundEffect cSE, IEffectEmitter emitter) -
void
play
(CSoundEffect cSE, Transform trans) -
void
play
(CSoundEffect cSE, Vector3 position) - Param CSoundEffect cSE
The SE object available from CSeResource.
- Param IEffectEmitter emitter
Emitters that produce the effect.
- Param Transform trans
Where the sound is coming from
- Param Vector3 position
Where the sound is coming from
Plays the specified SE as 3D audio.
It has an instance of a manager
-
void
-
class CSeResourceMgr
¶ It is the container that manages the CSeResource.
After downloading asset bundles via CassetBundleMgr, it manages the imported audio data.
-
CSeResource
refenrece
(UInt32 mAssetBundle)¶ - Param uint mAssetBundle
Specifies the SE Resource ID(Asset Bundle ID).
- Return
The SE resource is returned.
Get SE resources. The assets you can get are converted here .
-
CSoundEffect
find
(UInt32 mAssetBundle, UInt32 mId)¶ - Param uint mAssetBundle
Specify the SE resource.
- Param uint id
Specify the SE ID.
- Return
SE will be returned. If the asset bundle that the specified SE is packed in is still being loaded or does not exist, null is returned.
Gets a CSoundEffect.
-
static CSeResourceMgr
Instance
{ get; }¶
It has an instance of a manager
-
CSeResource
-
class CSeResource
¶ It keeps the asset-bundled SE available.
There are multiple SEs in one CSeResource.
It has an IWinSoundEffect interface and can be registered with CWindowMgr.
you can play the SE through the CSoundEffectMgr.
-
CSoundEffect
find
(UInt32 id)¶ - Param uint id
Specifies the SE ID you want to retrieve.
- Return
Return the SE.
SE will be returned.
Play SE.
Check to see if the asset bundle has finished loading.
When true, the load is complete and ready for use.
-
CSoundEffect
-
class CBgmResourceMgr
¶ This is the container that manages the CBgmResource.
It manages the BGM resources that have downloaded the asset bundles through CAssetBundleMgr.
To sound the BGM, use CSoundEffectMgr.
-
CBgmResource
refenrece
(UInt32 mAssetBundle)¶ - Param uint mAssetBundle
Specifies the BGM resource ID (Asset Bundle ID).
- Return
BGM resource will be returned.
Gets the BGM resource. The assets you can get are converted here .
-
CBgmResource
load
(UInt32 mResource)¶ - Param uint mResource
Specifies the resource ID.
- Return
BGM resource will be returned.
You can import a file by placing it under the Resources folder as follows:
Assets/Resources/001_000_000000.mp3 Assets/Resources/001_000_000000.intro.mp3
-
static CBgmResourceMgr
Instance
{ get; }¶
It has an instance of a manager
-
CBgmResource
-
class CBgmResource
¶ The asset-bundled BGM is kept available.
Within the CBgmResource, there is audio data for the intro and loop.
To sound the BGM, use CSoundEffectMgr.
-
AudioClip
loopClip
{ get; }¶
Clip in the loop
-
AudioClip
introClip
{ get; }¶
Clip in the intro
Check to see if the asset bundle has finished loading.
When true, the load is complete and ready for use.
-
AudioClip