CMainSystemBase¶
The CMainSystemBase adds to the game object . The game object is not deleted even switched the scene
By adding resident managers in this script , you can download related assetbundles.
By performing a scene loading using this script,it waits to finish assetbundles loading.
When using it , create a CMainSystem class and to inherit it .
-
class CMainSystemBase
¶ -
void
Awake
()¶
By registering various managers in the Awake function using AddComponent and addManager, the Start function automatically performs necessary initialization and loading of necessary asset bundles.
A typical description is as follows:
Note
Start () should not be overwritten . It can not be successfully loading .
-
void
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>(); // Managers that need to be initialized. addManager(new CMessageDataSheetMgr(Utility.getSystemLocale())); }
- void
addManager
(IManager mgr)¶
- Param IManager mgr
It is an interface required for the objects that must be initialized with the loaded asset bundle.
Note
Within Awake, you need to AddComponet.
- virtual void
initialize
()¶As soon as the asset bundle is loaded, the initialization process is called through the interfaces: ILoader, IManager.
- virtual void
OnChangeScene
()¶Called when you switch scenes.
- Boolean
changeScene
(String sScene, Boolean bForceChange=false)¶Switches to the specified scene.
Equivalent to Application.LoadLevel, but differs in the following ways:
Wait for the fade object to finish fading.
While loading the asset bundle, the scene switch is pending.
Automatically closes the created window.
OnChageScene is called just before you switch scenes (Just before Application.LoadLevel is called).
Determines whether a scene is being imported.
Available only when switching scenes via CMainSystemBase.chageScene.
Determines whether initialization is complete.
Returns a random integer.
Returns a random number in the specified range.
Returns a random number in the specified range.
Returns a floating point random number.
-
class ILoader
¶ -
Follow the script that inherits MonoBehaviour.
In a script in the same game object as CMainSystemBase, examine the object that has the ILoader, and wait until ILoader.isLoading () is false.
Note
Within Awake, you need to AddComponet.
-
class IManager
¶ These should be added using the CMainSystemBase.addManager in Awake method.
It is an interface required for the objects that must be initialized with the loaded asset bundle.
addManager(new CMessageDataSheetMgr());
-
Boolean
initialize
(CAssetBundle[] aAssetBundles)¶ - Param CAssetBundle[] aAssetBundles
array of loaded asset bundles
-
void
release
()¶
Release process called when the game object is released
-
UInt32[]
getAssetBundleIds
()¶ - Return uint[]
ID of the asset bundle that needs to be loaded at initialization
This function returns an array of the asset bundle IDs that need to be loaded.
-
Boolean