public static void Create(string title, string content, DialogBoxType type, Action callback1, Action callback2, string oneButtonName, string twoButtonName) { switch (type) { case DialogBoxType.OneButton: C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI("UI_DialogBox_OneButton", content, callback1, oneButtonName); break; case DialogBoxType.TwoButton: C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI("UI_DialogBox_TwoButton", content, callback1, callback2, oneButtonName, twoButtonName); break; case DialogBoxType.Tile_OneButton: C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI("UI_DialogBox_Title_OneButton", title, content, callback1, oneButtonName); break; case DialogBoxType.Tile_TwoButton: C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI("UI_DialogBox_Title_TwoButton", title, content, callback1, callback2, oneButtonName, twoButtonName); break; } }
private bool ReplaceAllDownloadFile() { for (int i = 0; i < m_DownloadList.Count; i++) { string sourceFile = LocalPath.LocalPackagingResources + GetDownloadName(m_DownloadList[i]); if (!C_ZipUtility.UnzipFile(sourceFile, LocalPath.LocalPackagingResources)) { C_MonoSingleton <C_UIMgr> .GetInstance().CloseUI("UI_StageDownload"); C_MonoSingleton <GameStageHotUpdateMgr> .GetInstance().CloseDownload(); DialogBox.Create("LOACAL_MAIN_DOWNLOAD_STAGE_NO_MEMORY_UNZIP_HINT", "LOACAL_MAIN_DOWNLOAD_STAGE_NO_MEMORY_UNZIP"); return(false); } } for (int i = 0; i < m_DownloadList.Count; i++) { string sourceFile = LocalPath.LocalPackagingResources + GetDownloadName(m_DownloadList[i]); if (File.Exists(sourceFile)) { File.Delete(sourceFile); } } m_DownloadList.Clear(); return(true); }
public static void Create(string description = "", float rate = 0) { c_Description = description; c_Rate = rate; C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI("UI_Loading"); }
public static void Close() { c_Description = ""; c_Rate = 0; C_MonoSingleton <C_UIMgr> .GetInstance().CloseUI("UI_Loading"); }
public T LoadAssetBundle_Cache <T>(string resName, string resPath, string resType, string exResPath = "", bool isInstantiate = false, bool isForever = false) where T : UnityEngine.Object { if (string.IsNullOrEmpty(resName)) { return(null); } if (string.IsNullOrEmpty(resPath) && !string.IsNullOrEmpty(exResPath)) { int index = exResPath.IndexOf('/'); resPath = exResPath.Substring(0, (index == -1 ? exResPath.Length : index)); } UnityEngine.Object tempObject = C_MonoSingleton <C_PoolMgr> .GetInstance().Spawn(resName, resType); if (tempObject != null) { return(tempObject as T); } string assetBundleName = GetAssetBundleName(resName, resPath, resType, exResPath); return(C_ResMgr.LoadAssetBundleCache <T>(resName, GetAssetBundleFilePath(assetBundleName), isInstantiate, isForever)); }
public void UnloadSceneAndLoadNewSceneAsync(string unloadSceneName, string LoadNewSceneName, System.Action callback = null, string uiName = "UI_StoryLoading") { if (_Isloading) { return; } if (C_MonoSingleton <C_SceneMgr> .GetInstance().IsLoading) { return; } if (string.IsNullOrEmpty(uiName) || string.IsNullOrEmpty(uiName)) { return; } if (string.IsNullOrEmpty(unloadSceneName) && string.IsNullOrEmpty(LoadNewSceneName)) { return; } OnCompelete = callback; //打开界面 OpenUI(uiName); AddUnLoadSceneQueue(unloadSceneName, LoadNewSceneName); if (string.IsNullOrEmpty(unloadSceneName)) { _MainSceneName = LoadNewSceneName.Split(',')[0]; StartAddScene(); } else { StartUnLoad(); } m_nLoadingSceneCount = m_SceneQueue.Count; _AutoCloseUI = true; }
/// <summary> /// /// </summary> /// <param name="unloadSceneName">表示所有需要卸载的场景,如果有多个场景需要卸载:"aoe_story,py_scene_2"</param> /// <param name="unloadResConfig">如果需要卸载ab资源,则需要配置一个ab资源配置文件名</param> /// <param name="callback"></param> /// <param name="uiName"></param> public void UnLoadABUnloadAllScene(string unloadResConfig = "", System.Action callback = null, string uiName = "UI_StoryLoading") { if (_LoadingState != LoadingState.load_null) { return; } if (C_MonoSingleton <C_SceneMgr> .GetInstance().IsLoading) { return; } if (string.IsNullOrEmpty(uiName)) { return; } _CurrentPrecent = 0.9f; _UnloadResFile = unloadResConfig; OnCompelete = callback; //打开界面 OpenUI(uiName); //string unloadSceneName = string.Empty; //for (int i = 0; i < SceneManager.sceneCount; i++) //{ // unloadSceneName += SceneManager.GetSceneAt(i).name + ","; //} AddUnLoadSceneQueue(string.Empty, "Loading"); StartUnloadWithLoadingScene(); _AutoCloseUI = false; }
protected virtual void onRealtimeUpdate(float deltaTime) { if (m_CurNetworkData != null) { m_CurNetworkData.Timeout -= deltaTime; if (m_CurNetworkData.Timeout <= 0) { m_CurNetworkData.Callback(""); m_CurNetworkData = null; } } if (m_CurNetworkData == null && m_NetworkDataList.Count > 0) { m_CurNetworkData = m_NetworkDataList[0]; m_NetworkDataList.RemoveAt(0); if (m_CurCoroutine != null) { C_MonoSingleton <C_GameFramework> .GetInstance().StopCoroutine(m_CurCoroutine); } //开始请求数据 m_CurCoroutine = C_MonoSingleton <C_GameFramework> .GetInstance().StartCoroutine(GetResponse(m_CurNetworkData)); } }
public void CacheUnload() { if (--RefCacheCount <= 0 && RefCount <= 0) { C_MonoSingleton <C_AssetBundleMgr> .GetInstance().ForceCacheUnload(this); } }
private void StartLoad() { _Action = null; //_Isloading = true; _Action = delegate { C_MonoSingleton <C_SceneMgr> .GetInstance().LoadScene(m_SceneQueue.Dequeue(), "StageLoading", () => { NextStep(); }); }; if (!string.IsNullOrEmpty(_PreLoadFile)) { // _StartPreloadRes = true; _LoadingState = LoadingState.load_ab; C_MonoSingleton <PreLoadResMgr> .Instance.StartLoadRes(_PreLoadFile); } else { //_StartPreloadRes = false; _LoadingState = LoadingState.load_scene; _Action(); } }
private void StartUnLoad() { // _Isloading = true; _Action = null; _Action = delegate { C_MonoSingleton <C_SceneMgr> .GetInstance().UnloadSceneAsync(m_UnloadSceneQueue.Dequeue(), "StageLoading", () => { UnLoadNextStep(); }); }; // _Action(); // _StartPreloadRes = false; if (!string.IsNullOrEmpty(_UnloadResFile)) { // _StartPreloadRes = true; C_MonoSingleton <PreLoadResMgr> .Instance.ForceUnloadABRes(_UnloadResFile); _LoadingState = LoadingState.unload_ab; } else { //_StartPreloadRes = false; _LoadingState = LoadingState.unload_scene; _Action(); } }
public static T GetAssetBundleFormCache <T>(string resName, string assetBundleFilePath, bool isInstantiate = false, bool isForever = false) where T : UnityEngine.Object { T result = null; try { C_AssetBundleRef bundle = C_MonoSingleton <C_AssetBundleMgr> .GetInstance().GetAssetBundleRefList(assetBundleFilePath); if (bundle != null) { result = bundle.LoadAsset <T>(resName); if (isInstantiate && result != null) { result = GameObject.Instantiate(result); } } } catch (Exception e) { C_DebugHelper.LogError("GetAssetBundleFormCache : " + e); } return(result); }
public void OpenUI(string uiName) { if (!C_MonoSingleton <C_UIMgr> .GetInstance().IsOpenedUI(uiName)) { C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI(uiName); } _UI_StoryLoading = FindObjectOfType <UI_StoryLoading>(); }
private void GamePauseAction() { if (mGamePauseAction != null) { mGamePauseAction(); } C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI(UI_StoryPause, new System.Action(StoryGoMainCityAction), mGameContinueAction); }
public void OpenGameUI(System.Action GoMainCityAction = null, System.Action PauseAction = null, System.Action ContinueAction = null) { C_MonoSingleton <C_UIMgr> .GetInstance().CloseUI(UI_StoryTitle); mGameGoMainCityAction = GoMainCityAction; mGameContinueAction = ContinueAction; mGamePauseAction = PauseAction; C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI(UI_StoryTitle, new System.Action(GamePauseAction)); }
public void OpenStoryUI() { C_MonoSingleton <C_UIMgr> .GetInstance().CloseUI(UI_StoryTitle); mGameGoMainCityAction = null; mGameContinueAction = null; mGamePauseAction = null; C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI(UI_StoryTitle, new System.Action(StoryPauseAction)); }
public static void PlaySoundEffect(string name) { if (string.IsNullOrEmpty(name)) { return; } C_MonoSingleton <C_AudioMgr> .GetInstance().PlayClipOneShot(C_Singleton <GameResMgr> .GetInstance().LoadResource_Audio_Effect(name)); }
void Update() { if (m_StageDownloadList.Count > 0) { if (m_StageDownloadList[0].TotalDownloadLength != 0) { c_FillAmount = m_StageDownloadList[0].CurDownloadLength / (float)m_StageDownloadList[0].TotalDownloadLength; if (c_FillAmount > m_fMark) { c_Percent = "正在安装,请稍后..."; c_Desc = (m_StageDownloadList[0].TotalDownloadLength / 1048576) + "MB / " + (m_StageDownloadList[0].TotalDownloadLength / 1048576) + "MB"; } else { if (c_FillAmount != 0) { c_Percent = (c_FillAmount * 100).ToString("F2") + "%"; } c_Desc = (m_StageDownloadList[0].CurDownloadLength / 1048576) + "MB / " + (m_StageDownloadList[0].TotalDownloadLength / 1048576) + "MB"; } } m_StageDownloadList[0].OnUpdate(); if (m_StageDownloadList[0].DownloadState == 2) { m_bDownloading = false; //一定要这么做,先移除下载列表,再更新UI string stageName = m_StageDownloadList[0].StageName; m_StageDownloadList.RemoveAt(0); if (m_StageDownloadList.Count == 0) { C_MonoSingleton <C_UIMgr> .GetInstance().CloseUI("UI_StageDownload"); } C_Singleton <GameResMgr> .GetInstance().InitMainAssetBundleManifest(); //一定要先处理数据再刷新界面,如果数据没有刷新,会引发BUG // C_Singleton<StageMgr>.GetInstance().RefreshUITag(stageName); } else { if (!m_bDownloading) { m_bDownloading = true; m_StageDownloadList[0].StartDownload(); } } } }
protected void InitCoreSys() { C_Singleton <C_TimerMgr> .CreateInstance(); C_Singleton <C_GameStateCtrl> .CreateInstance(); C_MonoSingleton <C_AudioMgr> .GetInstance(); C_MonoSingleton <C_UIMgr> .GetInstance(); }
public C_AsyncAssetBundleLoader(string resName, string assetBundleFilePath, List <string> dependenciesFilePathList, Action <T> callback, bool isInstantiate, bool isForever) { m_strResName = resName; m_strAssetBundleFilePath = assetBundleFilePath; m_DependenciesFilePathList = dependenciesFilePathList; m_Callback = callback; m_IsInstantiate = isInstantiate; m_IsForever = isForever; C_MonoSingleton <C_GameFramework> .GetInstance().StartCoroutine(ExecuteLoader()); }
public static void Create(string content) { string strContent = C_Localization.GetLocalization(content); if (string.IsNullOrEmpty(strContent)) { return; } C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI("UI_Tips", content); }
private void ExecuteDownloadStageHotUpdate(string stageName) { //临时办法 stageName = c_AnyStage; foreach (GameStageHotUpdate stageHotUpdate in m_StageDownloadList) { if (stageHotUpdate.StageName == stageName) { if (stageHotUpdate.DownloadState == 0) { stageHotUpdate.StartDownload(); C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI("UI_StageDownload"); StartCheckDownload(); } return; } } string serverStageConfig = GetServerStageConfig(stageName); List <HotUpdateItem> serverList = GameHotUpdateMgr.ParseHotUpdateConfig(serverStageConfig); string localStageConfig = GetLocalStageConfig(stageName); List <HotUpdateItem> localList = GameHotUpdateMgr.ParseHotUpdateConfig(localStageConfig); List <HotUpdateItem> list = new List <HotUpdateItem>(); for (int i = 0; i < serverList.Count; i++) { for (int j = 0; j < localList.Count; j++) { if (serverList[i].Name == localList[j].Name) { break; } } list.Add(serverList[i]); } if (list.Count > 0) { m_StageDownloadList.Add(new GameStageHotUpdate(stageName, list)); C_MonoSingleton <C_UIMgr> .GetInstance().OpenUI("UI_StageDownload"); StartCheckDownload(); } }
public C_SceneLoader(string sceneName, LoadSceneMode loadSceneMode, string mainscene = "") { if (!string.IsNullOrEmpty(sceneName)) { int end = sceneName.LastIndexOf('.'); sceneName = sceneName.Substring(0, (end == -1 ? sceneName.Length : end)); _LoadSceneName = sceneName; //SceneManager.sceneLoaded -= OnSceneLoaded; //SceneManager.sceneLoaded += OnSceneLoaded; _LoadOver = false; _MainActiveSceneName = mainscene; C_MonoSingleton <C_GameFramework> .GetInstance().StartCoroutine(Execute(sceneName, loadSceneMode)); } }
private void UnLoadNextStep() { if (m_UnloadSceneQueue.Count > 0) { C_MonoSingleton <C_SceneMgr> .GetInstance().UnloadSceneAsync(m_UnloadSceneQueue.Dequeue(), "", () => { UnLoadNextStep(); }); } else { NextStep(); } }
private void NextStep() { if (m_SceneQueue.Count > 0) { C_MonoSingleton <C_SceneMgr> .GetInstance().LoadScene(m_SceneQueue.Dequeue(), "", () => { NextStep(); }, true, LoadSceneMode.Additive, _MainSceneName); } else { LoadCompelete(); } }
public static void Load() { string strData = C_MonoSingleton <C_DataMgr> .GetInstance().LoadData(Name); if (!string.IsNullOrEmpty(strData)) { AppVersion = C_Json.GetJsonKeyString(strData, "AppVersion"); ResVersion = C_Json.GetJsonKeyString(strData, "ResVersion"); LogState = C_Json.GetJsonKeyInt(strData, "LogState"); LocalResources = C_Json.GetJsonKeyInt(strData, "LocalResources"); AutoTest = C_Json.GetJsonKeyInt(strData, "AutoTest"); HYJJ_Test = C_Json.GetJsonKeyInt(strData, "HYJJ_Test"); } }
private void DoneScore(bool pass, float rate) { AudioManager.Instance.SetPlayerSoundVolume(_AudioVoumle); AudioManager.Instance.StopEffectByKey(_AudioEffectName); ClearUI(); if (_RecordOverCallback != null) { _RecordOverCallback(pass); _RecordOverCallback = null; } #if UNITY_IOS || UNITY_ANDROID C_MonoSingleton <GameHelper> .GetInstance().SetMuteModePlay(); #endif }
void Awake() { if (this.transform.parent == null) { this.transform.SetParent(C_MonoSingleton <C_UIMgr> .GetInstance().transform); } UICanvas = this.transform.Find("Canvas").GetComponent <Canvas>(); UICanvas.renderMode = RenderMode.ScreenSpaceCamera; if (UICameraType == Enum_UICameraType.Low) { UICanvas.worldCamera = C_UIMgr.c_UICameraLow; } else if (UICameraType == Enum_UICameraType.High) { UICanvas.worldCamera = C_UIMgr.c_UICameraHigh; } UICanvas.sortingOrder = Layer; UICanvas.planeDistance = 50; CanvasScaler canvasScaler = UICanvas.transform.GetComponent <CanvasScaler>(); if (canvasScaler != null) { canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; canvasScaler.referenceResolution = new Vector2(C_GameFramework.c_DesignWidth, C_GameFramework.c_DesignHeight); if (UICanvasScaler == Enum_UICanvasScaler.Nomal) { canvasScaler.matchWidthOrHeight = C_UIMgr.c_Match; } else if (UICanvasScaler == Enum_UICanvasScaler.Height) { canvasScaler.matchWidthOrHeight = 1.0f; } else { canvasScaler.matchWidthOrHeight = 0f; } } m_MainLayer = UICanvas.transform.Find("MainLayer"); Localization(); C_MonoSingleton <C_GameFramework> .GetInstance().onRealtimeUpdate += onRealtimeUpdate; onInit(); }
private void StartUnLoad() { _Isloading = true; _Action = delegate { C_MonoSingleton <C_SceneMgr> .GetInstance().UnloadSceneAsync(m_UnloadSceneQueue.Dequeue(), "StageLoading", () => { //NextStep(); UnLoadNextStep(); }); }; _Action(); _StartPreloadRes = false; }
public static void AsyncLoadResource <T>(string resName, string resPath, Action <T> callback) where T : UnityEngine.Object { if (callback == null) { return; } if (string.IsNullOrEmpty(resName) || string.IsNullOrEmpty(resPath)) { callback(null); return; } C_MonoSingleton <C_GameFramework> .GetInstance().StartCoroutine(ExecuteAsyncLoadResource <T>(C_String.DeleteExpandedName(resPath + resName), callback)); }