/// <summary> /// 切换到目标场景 /// </summary> public void changeToTargetScene() { if (!string.IsNullOrEmpty(TargetScene)) { GameSceneManager.getInstance().ChangeToSceneImpl(TargetScene); } }
/// <summary> /// 添加场景基础组件 /// </summary> private void addBaseComponent() { Transform curScene = GameSceneManager.getInstance().CurSceneTransform; //创建目录结构 foreach (KeyValuePair <stringSceneName, boolPersistent> kvp in SceneStructureData.s_BaseSceneStructure) { Transform pTransform = curScene.FindChild(kvp.Key); if (pTransform == null) { GameObject pObj = new GameObject(kvp.Key); pObj.transform.position = default(Vector3); pObj.transform.parent = curScene; if (kvp.Value) { DontDestroyOnLoad(pObj); } } else { if (kvp.Value) { DontDestroyOnLoad(pTransform.gameObject); } } } }
/// <summary> /// 在版本更新完成后,才调用该函数,开启游戏初始化。 /// step1:开始加载配置文件 /// </summary> public void StartUp() { SDKManager.getInstance().sendNewbieguideDeviceUniqueIdentifier("2"); _bStartUp = true; GameObject pMgrObj = GameObject.Find("ApplicationMgr"); if (pMgrObj == null) { pMgrObj = new GameObject("ApplicationMgr"); pMgrObj.transform.position = default(Vector3); _applicationMgr = pMgrObj.AddComponent <ApplicationMgr>(); } else { _applicationMgr = pMgrObj.GetComponent <ApplicationMgr>(); } DontDestroyOnLoad(pMgrObj); BaseScene pSceneMono = GameSceneManager.getInstance().SceneMono; bool isStartUp = pSceneMono is StartUpScene; if (pSceneMono == null || !isStartUp) { //SceneConfig config = GameSceneManager.getInstance().GetSceneConfig(SceneName.s_StartupScene); GameSceneManager.getInstance().sceneLoadCompleteAndInit(SceneName.s_StartupScene, new SceneConfig()); } base.Start(); _startUpStep = 1; UtilTools.SetServerListTip(""); }
//加载 private void Awake() { bCanClick = true; Caching.CleanCache(); FollowToSceneCamera follower = null; GameObject pListener = GameObject.Find("Listener");//声音接收者 if (pListener == null) { pListener = new GameObject("Listener"); pListener.AddComponent <AudioListener>(); follower = pListener.AddComponent <FollowToSceneCamera>(); DontDestroyOnLoad(pListener); } else { follower = pListener.GetComponent <FollowToSceneCamera>(); } GameObject pSingletonObj = GameObject.Find("Singleton"); if (pSingletonObj == null) { pSingletonObj = new GameObject("Singleton"); pSingletonObj.transform.position = default(Vector3); } DontDestroyOnLoad(pSingletonObj); if (SDKManager.isAppStoreVersion()) { if (pSingletonObj.GetComponent <ObjectCCallback>() == null) { pSingletonObj.AddComponent <ObjectCCallback>(); Utils.LogSys.Log("XXXXXXXXXXXXXXXX--Add ObjectCCallback--XXXXXXXXXXXXXXXX"); } } DestroyUnUsedUIRoot(); GameObject camObj1 = GameObject.Find("Scene/Cameras/SceneCamera"); if (camObj1 && !camObj1.GetComponent <CameraAjustor>()) { camObj1.AddComponent <CameraAjustor>(); follower.camera_tf = camObj1.transform; } GameObject camObj2 = GameObject.Find("UIRoot/UICamera"); if (camObj2 && !camObj2.GetComponent <CameraAjustor>()) { camObj2.SetActive(true); camObj2.AddComponent <CameraAjustor>(); } GameSceneManager.uiCameraObj = camObj2; GameObject versionUpdate = GameObject.Find("VersionUpdate"); //versionUpdate.transform.parent = GameObject.Find("UIRoot").transform; //DontDestroyOnLoad(versionUpdate.gameObject); CheckGameHead(); versionUpdate.gameObject.SetActive(true); //uiBattlePauseController.GetPreState();//获取声音设置 GameSceneManager.getInstance().SceneMono = this; bCanClick = true; }