// Use this for initialization void Start() { //登入界面改成prefab加载,MainUI,首次进入LoginPanel add by lzp 2015/6/8 if (bLoginPanel) { MainPanelMgr.gotoPanel("LoginPanel"); //MainPanelMgr.gotoPanel("UILogin"); bLoginPanel = false; } if (SceneManager.GetActiveScene().name != MapMgr.mainCityMapName) { // UI Init MainPanelMgr.Instance.Init(); } //add by Alex 20150416 向核心入口传递当前场景的背景音乐源 CoreEntry.g_CurrentSceneMusic = gameObject.GetComponent <AudioSource>(); //控制MainUI的音乐 AudioSource a = gameObject.GetComponent <AudioSource>(); if (a != null) { a.mute = !CoreEntry.cfg_bMusicToggle; if (!a.mute) { a.Play(); } } //StartCoroutine(testAudio()); }
protected virtual void OnDestroy() { if (m_instance == this) { LogMgr.UnityLog("[SingletonMonoBehaviour] destory singleton. type=" + typeof(MainPanelMgr).ToString()); m_instance = null; } }
//注意这里返回值一定是 IEnumerator IEnumerator loadScene() { int displayProgress = 0; int toProgress = 0; int randPro = UnityEngine.Random.Range(40, 70); while (!_realLoad) { while (displayProgress < randPro) //预加载 { ++displayProgress; SetProgressBar(displayProgress); yield return(_wait); } yield return(_wait); } CoreEntry.gSceneMgr.InitPools(MapMgr.Instance.GetCurSceneID()); if (ModuleServer.MS.GSkillCastMgr != null) { ModuleServer.MS.GSkillCastMgr.Disable(); } while (_sceneStep < 0.90f) { toProgress = (int)(_sceneStep * 100); while (displayProgress < toProgress) { ++displayProgress; SetProgressBar(displayProgress); yield return(_wait); } yield return(_wait); } MainPanelMgr.ClearTexture2D(); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue(string.Format("Bg_loading{0}", UnityEngine.Random.Range(0, 4))), "Bg_loading"))); toProgress = 100; while (displayProgress < toProgress) { ++displayProgress; SetProgressBar(displayProgress); yield return(_wait); } if (null != _sceneOperat) { _sceneOperat.allowSceneActivation = true; } CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_LOADSCENE_FINISH, EventParameter.Get(1)); SDKMgr.Instance.addBatchDataEvent(1, SG.Account.Instance.ServerId, "10230", " 加载场景完成" + strNextLevel); loadsceneFinished(); }
public void SendReqChallenge(int rank) { MsgData_cReqArenaChallenge data = new MsgData_cReqArenaChallenge(); data.Rank = rank; CoreEntry.netMgr.send((Int16)NetMsgDef.C_ARENACHALLENGE, data); MainPanelMgr.gotoPanel("UIArenaFight"); }
public override void Awake() { if (m_instance == null) { m_instance = this as MainPanelMgr; } else { UnityEngine.Object.Destroy(gameObject); } }
/// <summary> /// 进入角色选择场景 /// </summary> public void EnterRoleSelectScene() { m_lastMapType = m_curMapType; m_curMapType = MapType.Map_SelectRole; CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_BEGIN_LOADSCENE_CREATE_ROLE, null); MainPanelMgr.gotoPanel("UIRoleSelect"); CoreEntry.gSceneMgr.LoadScene("Scene/allMap/ui/RoleUI"); EnterType = 0; FirstLoad = true; }
/// <summary> /// 进入登录场景 /// </summary> public void EnterLoginScene() { m_lastMapType = m_curMapType; m_curMapType = MapType.Map_Login; CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_BEGIN_LOADSCENE_LOGIN, null); MainPanelMgr.gotoPanel("LoginPanel"); CoreEntry.gSceneMgr.LoadScene("Scene/allMap/ui/LoginUI"); EnterType = 0; FirstLoad = true; }
IEnumerator InitProcess() { WaitForEndOfFrame wait = new WaitForEndOfFrame(); InitUI.SetLoadTip("游戏资源加载中......"); float lastPercent = Random.Range(0.5f, 0.7f); float displayProgress = 0f; CoreEntry.gSceneMgr.PreloadScene("Scene/allMap/ui/RoleUI"); while (CoreEntry.gSceneMgr.SceneLoading) { while (displayProgress < lastPercent) //预加载 { displayProgress += 0.1f; InitUI.SetProgress(displayProgress); yield return(wait); } yield return(wait); } lastPercent = 0.99f; CoreEntry.gSceneMgr.PreloadScene("Scene/allMap/ui/LoginUI"); while (CoreEntry.gSceneMgr.SceneLoading) { while (displayProgress < lastPercent) //预加载 { displayProgress += 0.2f; InitUI.SetProgress(displayProgress); yield return(wait); } yield return(wait); } InitUI.SetProgress(1); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue("BackLogin"), string.Empty))); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue("LoginLogo2"), string.Empty))); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue(string.Format("Bg_loading{0}", UnityEngine.Random.Range(0, 4))), "Bg_loading"))); MapMgr.Instance.EnterLoginScene(); }
public static void SetLoadImage(Component pCompont, string strImage, int nType = 0) { Texture2D texImage = MainPanelMgr.GetTexture2D(strImage); Debug.Log("SetLoadImage ::: Start::" + strImage); if (texImage) { if (nType == 0) { var imageBg = pCompont as RawImage; imageBg.texture = texImage; Debug.Log("SetLoadImage ::: RawImage!!!" + strImage); } else if (nType == 1) { var imageBg = pCompont as UnityEngine.UI.Image; imageBg.sprite = Sprite.Create(texImage, new Rect(0, 0, texImage.width, texImage.height), new Vector2(0, 0)); Debug.Log("SetLoadImage ::: Sprite!!!" + strImage); } } }
public virtual void OnApplicationQuit() { m_instance = null; }
IEnumerator InitProcess() { WaitForEndOfFrame wait = new WaitForEndOfFrame(); float gap = 0.05f; float time = 0.0f; float lastTime = Time.realtimeSinceStartup; float configPercent = Random.Range(0.8f, 0.9f); if (AppConst.UseAssetBundle) { configPercent = Random.Range(0.3f, 0.5f); } while (!m_LuaInitCall()) { time += Time.realtimeSinceStartup - lastTime; if (time > gap) { lastTime = Time.realtimeSinceStartup; time = 0; InitUI.SetProgress(m_LuaGetInitProCall() * configPercent); yield return(wait); } } m_LuaInitCall = null; m_LuaGetInitProCall = null; yield return(wait); InitUI.SetLoadTip("游戏资源加载中......"); float lastPercent = configPercent + (1 - configPercent) * 0.5f; float displayProgress = configPercent; CoreEntry.gSceneMgr.PreloadScene("Scene/allMap/ui/RoleUI"); while (CoreEntry.gSceneMgr.SceneLoading) { while (displayProgress < lastPercent) //预加载 { displayProgress += 0.005f; InitUI.SetProgress(displayProgress); yield return(wait); } yield return(wait); } lastPercent = 0.99f; CoreEntry.gSceneMgr.PreloadScene("Scene/allMap/ui/LoginUI"); while (CoreEntry.gSceneMgr.SceneLoading) { while (displayProgress < lastPercent) //预加载 { displayProgress += 0.01f; InitUI.SetProgress(displayProgress); yield return(wait); } yield return(wait); } InitEnd(); InitUI.SetProgress(1); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue("BackLogin"), string.Empty))); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue("LoginLogo2"), string.Empty))); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue(string.Format("Bg_loading{0}", UnityEngine.Random.Range(0, 4))), "Bg_loading"))); MapMgr.Instance.EnterLoginScene(); }