private void LoadOriginImg() { //加载原图 X.Res.LevelConfig levelConfig = LevelMgr.GetInstance().GetLevelConfig(levelID).Config; Debug.Log("levelID:" + levelID); int pitcureId = levelConfig.LevelPicture; string altasname = AltasMgr.GetInstance().GetConfigByID((uint)pitcureId).AltasName2; Debug.Log(altasname); UIAtlas ats = UIAtlasUtil.GetAtlas(altasname); ats.Sp = originImg; ats.SetSprite("p_" + levelConfig.LevelPicture.ToString()); }
private void LoadOriginImg() { //加载原图 Image img = gameObject.transform.Find("GameObject").transform.Find("Image").GetComponent <Image>(); int pitcureId = LevelMgr.GetInstance().GetLevelConfig(levelID).Config.LevelPicture; string altasname = AltasMgr.GetInstance().GetConfigByID((uint)pitcureId).AltasName2; Debug.Log(altasname); UIAtlas ats = UIAtlasUtil.GetAtlas(altasname); ats.Sp = img; ats.SetSprite("p_" + data.Config.LevelPicture.ToString()); //加载关卡名字 //menuText.text = LevelMgr.GetInstance().GetIndexByID(levelID); }
private void ModiMapAndInfo() { updateFlag = false; //修改图片和信息的显示 //获得表 int dayId = TimeUtil.getIntByDateTime(m_selectedDateTime); SignInConfig signInConfig = SignInMgr.GetInstance().GetConfigByID((uint)dayId); m_selectedLevelID = signInConfig.LevelId; LevelData levelData = LevelMgr.GetInstance().GetLevelConfig(m_selectedLevelID); LevelConfig levelConfig = levelData.Config; if (levelConfig == null) { Debug.LogError("获取不到关卡 " + m_selectedLevelID + " 的Config"); return; } //TODO:修改mapIcon的图标,需要通过读表获取对应的图集 AltasConfig altasConfig = AltasMgr.GetInstance().GetConfigByID(m_selectedLevelID); string altasname = altasConfig.AltasName2; UIAtlas ats = UIAtlasUtil.GetAtlas(altasname); if (ats != null) { ats.Sp = mapIcon; if (SignInMgr.GetInstance().IsSign(dayId - GameConfig.SignInDay)) { ats.SetSprite("p_" + levelConfig.LevelPicture.ToString()); } else { ats.SetSprite("s_" + levelConfig.LevelPicture.ToString()); } } //TODO:修改info,包括了编号、名字、剩余时间和按钮的状态、文字等 levelNumText.text = "#" + (SignInMgr.GetInstance().GetIndexByID((uint)dayId) + 1).ToString(); LanguageMgr.GetInstance().GetLangStrByID(levelNameText, signInConfig.DailylevelName); StartCoroutine(TimeLeftUpdate(m_selectedDateTime.AddDays(1))); ModiTryButton(); }
public override void Process() { UIAtlasUtil.GetAtlasAsync("level_s", (o) => { Callback(); }); }
private void LoadLevelBtn(UILevelBtn uiLevelBtn, uint id, string picture, int levelCnt, int themeCnt) { //加载关卡名字,缩略图; //uiLevelBtn.levelText.text = themeCnt.ToString() + "-" + (levelCnt + 1).ToString(); //string picname = "level_s";//string.Format("s_{0}", picture); string altasname = AltasMgr.GetInstance().GetConfigByID(id).AltasName; UIAtlas ats = UIAtlasUtil.GetAtlas(altasname); UIAtlas ats2 = UIAtlasUtil.GetAtlas("uncomplete"); ats.Sp = uiLevelBtn.levelImg; ats2.Sp = uiLevelBtn.levelImg; if (ats != null) { if (XPlayerPrefs.GetInt(id.ToString() + isCompleted) == 1) { ats.SetSprite("s_" + picture);//ats.SetSprite("p_"+picture); ats.Sp.rectTransform.localScale = Vector3.one; uiLevelBtn.star.SetActive(true); uiLevelBtn._new.SetActive(false); //uiLevelBtn.levelText.text = LevelMgr.GetInstance().GetLevelConfig(id).Config.LevelName; //uiLevelBtn.levelText.text = themeCnt.ToString() + "-" + (levelCnt + 1).ToString(); } else if (XPlayerPrefs.GetInt(id.ToString() + isUnlock) == -1) { //Debug.Log("isunlock"); ats2.SetSprite("unknown"); ats.Sp.rectTransform.localScale = new Vector3(0.8f, 0.8f, 0.8f); uiLevelBtn._new.SetActive(true); uiLevelBtn.star.SetActive(false); //uiLevelBtn.levelText.text = (levelCnt+1).ToString(); //uiLevelBtn.levelText.text = "? ? ?"; } else { uiLevelBtn.star.SetActive(false); uiLevelBtn._new.SetActive(false); uiLevelBtn.SetGray(); //Debug.Log("islock"); //未解锁 ats2.SetSprite("lock"); ats.Sp.rectTransform.localScale = new Vector3(0.8f, 0.8f, 0.8f); } } #region starandlock ////加载星星 //if (UnpackStarNum(XPlayerPrefs.GetInt(id.ToString() + numStar)) >= 1) //{ // int stars = UnpackStarNum(XPlayerPrefs.GetInt(id.ToString() + numStar)); // Debug.Log(stars); // for (int i = 0; i < 3; i++) // { // UIAtlas starAts = ResMgr.GetAtlas("levelStar"); // starAts.Sp = uiLevelBtn.stars[i]; // if (i < stars) // { // starAts.SetSprite("guanqiaxuanzexing1"); // } // else // { // starAts.SetSprite("guanqiaxuanzexing2"); // } // } //} //else //{ // for (int i = 0; i < 3; i++) // { // uiLevelBtn.stars[i].color = new Color(255, 255, 255, 0); // } //} ////设置解锁状态; //UIAtlas unlockAts = ResMgr.GetAtlas("unlock"); //unlockAts.Sp = uiLevelBtn.unlockBtn; //switch (LevelMgr.GetInstance().GetLevelConfig(id).Config.LevelUnlock) //{ // case 0: // XPlayerPrefs.SetInt(id.ToString() + isUnlock, -1); // Destroy(uiLevelBtn.unlockBtn.gameObject); // break; // case 1: // if(XPlayerPrefs.GetInt(id.ToString()+isUnlock)==-1) // { // Destroy(uiLevelBtn.unlockBtn.gameObject); // break; // } // XPlayerPrefs.SetInt(id.ToString() + isUnlock, 1); // unlockAts.SetSprite("guanggao"); // break; // case 2: // if (XPlayerPrefs.GetInt(id.ToString() + isUnlock) == -1) // { // Destroy(uiLevelBtn.unlockBtn.gameObject); // break; // } // XPlayerPrefs.SetInt(id.ToString() + isUnlock, 2); // unlockAts.SetSprite("zuanshi"); // break; //} #endregion }
private static void UpdateAtlas(DirectoryInfo dir) { FileInfo[] infos = dir.GetFiles(); bool haveInfo = false; List <string> list = new List <string>(); foreach (var item in infos) { if (item.FullName.Contains(".png") && !item.FullName.Contains(".png.meta")) { haveInfo = true; string str = ""; str = item.FullName; str = str.Replace(@"\", @"/"); str = str.Replace(Application.dataPath, "Assets"); list.Add(str); } } if (!haveInfo) { DirectoryInfo[] infos1 = dir.GetDirectories(); for (int i = 0; i < infos1.Length; i++) { GetNewAtlas(infos1[i]); } return; } List <Texture> texTures = new List <Texture>(); for (int i = 0; i < list.Count; i++) { UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(list[i], typeof(Texture)); FileImporterSetting.SetFileImporterSetting(EFileImporterSettingType.TextureForRGBA32, 1024, AssetDatabase.GetAssetPath(obj)); texTures.Add(obj as Texture); } string dirPath = dir.FullName.Replace(@"\", @"/"); dirPath = dirPath.Replace(Application.dataPath + "/BreakAtlasPic/", "Assets/TGameResources/"); string[] dirPaths = dirPath.Split('/'); dirPath = "Assets"; for (int i = 1; i < dirPaths.Length - 1; i++) { dirPath += "/"; dirPath += dirPaths[i]; } UnityEngine.Object obj1 = AssetDatabase.LoadAssetAtPath(dirPath + "/" + dirPaths[dirPaths.Length - 1] + ".prefab", typeof(UIAtlas)); ua = obj1 as UIAtlas; UIAtlasUtil.UncompressAtlas(dirPath + "/" + dirPaths[dirPaths.Length - 1] + ".prefab"); FileImporterSetting.SetFileImporterSetting(EFileImporterSettingType.TextureForRGBA32, 1024, AssetDatabase.GetAssetPath(ua.spriteMaterial.mainTexture)); spriteList = ua.spriteList; List <UIAtlasMaker.SpriteEntry> ui = UIAtlasMaker.CreateSprites(texTures); for (int i = 0; i < ui.Count; i++) { for (int j = 0; j < spriteList.Count; j++) { if (ui[i].name == spriteList[j].name) { ui[i].borderLeft = spriteList[j].borderLeft; ui[i].borderRight = spriteList[j].borderRight; ui[i].borderBottom = spriteList[j].borderBottom; ui[i].borderTop = spriteList[j].borderTop; } } } for (int i = 0; i < ui.Count; i++) { UIAtlasMaker.AddOrUpdate(ua, ui[i]); } UIAtlasUtil.CompressAtlas(dirPath + "/" + dirPaths[dirPaths.Length - 1] + ".prefab"); AssetDatabase.Refresh(); }