public void PotongRockwool() { RKUtuh.SetActive(false); PotonganRK.SetActive(true); ButtonUI.SetActive(true); AlertUI.SetActive(true); }
public static AlertUI Show(string content, System.Action OnConfirm, EnumAlertStyle style = EnumAlertStyle.CONFIRM_ONLY, System.Action OnCancel = null, string confirmBtnName = "", string cancelBtnName = "") { GameObject _ui; if (_cacheList.Count > 0) { _ui = _cacheList.Dequeue(); } else { _ui = Instantiate(_prefab); _ui.SetActive(true); _ui.AddComponent <AlertUI>(); } RectTransform tranf = _ui.GetComponent <RectTransform>(); tranf.localScale = new Vector2(0.3f, 0.3f); tranf.DOScale(1f, 0.3f).SetEase(Ease.OutBack); AlertUI _script = _ui.GetComponent <AlertUI>(); _script.SetStyle(style); _script.SetContent(content); _script.SetCallBack(OnConfirm, OnCancel); _script.SetBtnName(confirmBtnName, cancelBtnName); tranf.SetParent(_root, false); _ui.SetActive(true); return(_script); }
public void Awake() { _instance = this; Debuger.EnableLog = false; Application.targetFrameRate = 50; isOpenMicrophone = true; Screen.sleepTimeout = SleepTimeout.NeverSleep; //保留主程序 GameObject.DontDestroyOnLoad(gameObject); VersionManager.localVersion = Application.version; //Bugly、友盟等对接 SDKManager.SetupBugly(); // LayerManager.Setup(); AssetPathUtil.Setup(); LoaderManager.Setup(); AlertUI.Setup(); PopManager.Setup(); /** * _loadingView = GameObject.Find("UI_Loading").AddComponent<SceneLoadingPanel>(); * m_NOTICEUI = LayerManager.topUILayer.Find("NoticeUI").gameObject.AddComponent<NoticeUI>(); * m_NOTICEUI.Online(); * _loadingView.SetTitle("正在检查游戏版本..."); */ }
private void OnCDNVersionFileLoaded(object content) { _downloadList = VersionManager.ParseRemoteVersionFile(content as byte[]); _loadFileDic = new Dictionary <string, FileVerInfo>(); _totalCount = _downloadList.Count; if (_totalCount == 0) { VersionManager.localVersion = VersionManager.remoteVersion; VersionManager.SaveCacheVersionFile(false); StartGame(); } else { foreach (FileVerInfo info in _downloadList) { _downloadTotal += info.size; } uint downloadTotalKB = _downloadTotal / 1024; string sizeTips; if (downloadTotalKB > 1024) { sizeTips = (uint)(downloadTotalKB / 1024f) + "MB"; } else { sizeTips = downloadTotalKB + "KB"; } AlertUI.Show("发现新版本,本次更新将消耗" + sizeTips + "流量。", StartDownloadNewRes); _loadingView.SetPercent(0); } }
/// <summary> /// provide a static reference to the AlertUI that can be accessed from any script /// </summary> /// <returns></returns> public static AlertUI Instance() { if (!alertUI) { alertUI = FindObjectOfType(typeof(AlertUI)) as AlertUI; if (!alertUI) { Debug.LogError("There needs to be one active AlertUI script on a GameObject in your scene"); } } return(alertUI); }
public void Alert(string content, string title = "系统消息") { AlertUI alert = GetNewUI <AlertUI>(); RectTransform rtf = alert.transform as RectTransform; //设置UI容器大小 rtf.sizeDelta = new Vector2(Screen.width, Screen.height); rtf.anchorMin = Vector2.zero; rtf.anchorMax = Vector2.one; rtf.offsetMin = new Vector2(0, 0); rtf.offsetMax = new Vector2(0, 0); alert.SetData(content, title); }
private async Task BroadcastSelectionAsync(TestData selected, RectTransform parent) { if (selected != null) { await AlertUI .Initialize(alertUIPrefab, parent.gameObject, $"You have selected {selected.Name}. They have {selected.AmountOfDogs} dogs.") .WaitForDismissalAsync(); } else { await AlertUI .Initialize(alertUIPrefab, parent.gameObject, "You have cancelled the selection.") .WaitForDismissalAsync(); } }
public AlertUI Alert(string content = "", string title = "消息") { AlertUI malert = GetNewUI <AlertUI>(); RectTransform pref = malert.GetComponent <RectTransform>(); pref.SetParent(root); pref.localPosition = Vector3.zero; pref.sizeDelta = new Vector2(Screen.width, Screen.height); pref.offsetMin = new Vector2(0, 0); pref.offsetMax = new Vector2(0, 0); pref.sizeDelta = new Vector2(Screen.width, Screen.height); malert.SetData(content, title); pref.localScale = Vector3.one; return(malert); }
//====================================================================================================================// /*private void LoadNextLevel() * { * if (_currentLevelIndex + 1 > levelPrefabs.Length) * throw new NotImplementedException("Need to add end game functionality"); * * LoadLevelAtIndex(_currentLevelIndex + 1); * }*/ private void LoadMenu() { LevelCompleted?.Invoke(_currentLevelIndex); GameSettings.LevelsCompleted++; if (GameSettings.LevelsCompleted >= levelPrefabs.Length) { var response = finalBody.Replace("#NAME", GameSettings.PlayerName); AlertUI.ShowAlert(finalTitle, response); } else { var levelData = levelPrefabs[_currentLevelIndex]; var response = levelData.response.Replace("#NAME", GameSettings.PlayerName); AlertUI.ShowAlert(levelData.name, response); } }
//====================================================================================================================// private void Awake() { _instance = this; }
//从CDN上读取解析 IP port hotUpdateURL homeURL private IEnumerator DownloadConfigFromCDN() { Debug.Log("download config from cdn: " + cdnUrl + "Main" + AssetPathUtil.XML_SUFFIX); WWW www = new WWW(cdnUrl + "Main" + AssetPathUtil.XML_SUFFIX); yield return(www); if (www.error == null) { XmlDocument configDoc = new XmlDocument(); XmlElement elementXml; XmlNodeList nodeList; configDoc.LoadXml(www.text); nodeList = configDoc.SelectSingleNode("root").ChildNodes; for (int i = 0; i < nodeList.Count; i++) { elementXml = (XmlElement)nodeList[i]; if (elementXml.Name == "randomIP") { int randomLoginIPIndex = UnityEngine.Random.Range(0, elementXml.ChildNodes.Count); XmlElement node = (XmlElement)elementXml.ChildNodes[randomLoginIPIndex]; serverIP = node.GetAttribute("IP"); serverPort = node.GetAttribute("port"); } else if (elementXml.Name == "content") { VersionManager.remoteVersion = elementXml.GetAttribute("ver"); _isForceUpdate = elementXml.GetAttribute("isForceUpdate") == "1"; homeUrl = elementXml.GetAttribute("homeURL"); if (elementXml.HasAttribute(_channel)) { homeUrl = elementXml.GetAttribute(_channel); } if (elementXml.HasAttribute("microphone")) { isOpenMicrophone = elementXml.GetAttribute("microphone") == "1"; } if (elementXml.HasAttribute(_channel + "_ip")) { serverIP = elementXml.GetAttribute(_channel + "_ip"); serverPort = elementXml.GetAttribute(_channel + "_port"); } } else if (elementXml.Name == "notice") { noticeType = int.Parse(elementXml.GetAttribute("noticeType")); noticeTitle = elementXml.GetAttribute("noticeTitle"); noticeContent = elementXml.GetAttribute("noticeContent"); Debug.Log(noticeType + "," + noticeTitle + "," + noticeContent); } } Debug.Log("remote xml:" + serverIP + " " + serverPort + " " + Application.version + " home:" + homeUrl); Debug.Log("本地版本:" + VersionManager.localVersion + " 远程版本" + VersionManager.remoteVersion); //是否强更 if (_isForceUpdate || VersionManager.CheckNeedForceUpdate(VersionManager.localVersion, VersionManager.remoteVersion)) { Debug.Log("版本过旧"); AlertUI.Show("<color='#CC3333'>当前游戏不是最新版本</color>\n\n请点击【确认】按钮下载最新游戏客户端", GotoHomeURL); } else { //检查是否需要热更新 if (!closeHotUpdate && VersionManager.CheckVersionIsOld(VersionManager.localVersion, VersionManager.remoteVersion)) { //创建配置缓存目录 string configPath = AssetPathUtil.PersistentDataPath + AssetPathUtil.configPath; if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } //创建音效缓存目录 string audioPath = AssetPathUtil.PersistentDataPath + AssetPathUtil.audioPath + "/" + AssetPathUtil.PlatformString; if (!Directory.Exists(audioPath)) { Directory.CreateDirectory(audioPath); } //创建AB资源缓存目录 string abPath = AssetPathUtil.PersistentDataPath + AssetPathUtil.PlatformString; if (!Directory.Exists(abPath)) { Directory.CreateDirectory(abPath); } //加载资源服务器版本文件 LoaderManager.Load(cdnUrl + "asset/" + AssetPathUtil.PlatformString + "/" + _versionFileName, EnumResouceType.BINARY, OnCDNVersionFileLoaded); } else { StartGame(); } } } else { if (_cdnRetryTimes == 10) { Debug.LogError(www.error); } _cdnRetryTimes++; if (_cdnRetryTimes > 10) { _loadingView.SetTitle("网络无法连接,请检查您的网络设置..."); } Debug.Log("正在尝试重新请求CDN....次数:" + _cdnRetryTimes); StartCoroutine(DownloadConfigFromCDN()); } }