public static void WritePrefabPathToCSharp() { Debug.Log(string.Join(",", Packer.atlasNames)); Texture2D[] texts = Packer.GetTexturesForAtlas("1"); Sprite sprite0 = Resources.Load <Sprite>("Sprites/car02"); Sprite sprite1 = Resources.Load <Sprite>("Sprites/car0_scaled"); Vector2[] points0 = SpriteUtility.GetSpriteUVs(sprite0, true); Vector2[] points1 = SpriteUtility.GetSpriteUVs(sprite1, true); Debug.Log("tEXT"); }
static void SetSelectAtlas(int idx) { texture = null; selected = idx; string atlasName = infoNamesArray[idx]; Texture2D[] texturesForAtlas = Packer.GetTexturesForAtlas(atlasName); if (texturesForAtlas.Length <= 0) { return; } texture = texturesForAtlas[0]; }
private void LoadAtalsNames() { _atlasToggleStates.Clear(); _alAtlases.Clear(); var atlasNames = Packer.atlasNames; for (int i = 0; i < atlasNames.Length; i++) { string atlasName = atlasNames[i]; Texture2D[] texture = Packer.GetTexturesForAtlas(atlasName); ALAtlas alAtlas = new ALAtlas(atlasName, texture.Length); _alAtlases.Add(alAtlas); _atlasToggleStates.Add(false); } }
private void RefreshState() { // Check if atlas name list changed string[] atlasNames = Packer.atlasNames; if (!atlasNames.SequenceEqual(m_AtlasNames)) { if (atlasNames.Length == 0) { Reset(); return; } else { OnAtlasNameListChanged(); } } if (m_AtlasNames.Length == 0) { SetNewTexture(null); return; } // Validate selections if (m_SelectedAtlas >= m_AtlasNames.Length) { m_SelectedAtlas = 0; } string curAtlasName = m_AtlasNames[m_SelectedAtlas]; Texture2D[] textures = Packer.GetTexturesForAtlas(curAtlasName); if (m_SelectedPage >= textures.Length) { m_SelectedPage = 0; } SetNewTexture(textures[m_SelectedPage]); // check if the atlas has alpha as an external texture (as in ETC1 atlases with alpha) Texture2D[] alphaTextures = Packer.GetAlphaTexturesForAtlas(curAtlasName); Texture2D selectedAlphaTexture = (m_SelectedPage < alphaTextures.Length) ? alphaTextures[m_SelectedPage] : null; SetAlphaTextureOverride(selectedAlphaTexture); }
public static void CreateTextureGo() { //读取配置表信息 InitConfig(); if (UGUIPackerPolicy.atlasDict.Count == 0) { Debug.LogWarning("没有图集生成"); return; } //获取texture string[] dirInfos = System.IO.Directory.GetDirectories(_atlasPrefab_path, "*", System.IO.SearchOption.AllDirectories); foreach (string atlasName in UGUIPackerPolicy.atlasDict.Keys) { Texture2D[] textures = Packer.GetTexturesForAtlas(atlasName); if (textures.Length != 1) { Debug.LogError(textures.Length + "图集生成失败!!!" + atlasName); break; } Texture2D texture = textures[0]; List <string> pathList = UGUIPackerPolicy.atlasDict[atlasName]; //创建灰度图 CreateGrayTexture(texture, _mat_path, atlasName); //创建mat文件 string grayPath = _mat_path + "/" + atlasName + "/" + atlasName + _grayNameRule; CreateGrayMat(_mat_path, atlasName, grayPath); //创建预设体 CreateAssetGo(_atlasPrefab_path, atlasName, pathList); } Debug.Log("生成成功!!!"); }
void OnSelectionChange() { if (Selection.activeObject == null) { return; } Sprite selectedSprite = Selection.activeObject as Sprite; if (selectedSprite != m_SelectedSprite) { if (selectedSprite != null) { string selAtlasName; Texture2D selAtlasTexture; Packer.GetAtlasDataForSprite(selectedSprite, out selAtlasName, out selAtlasTexture); int selAtlasIndex = m_AtlasNames.ToList().FindIndex(delegate(string s) { return(selAtlasName == s); }); if (selAtlasIndex == -1) { return; } int selAtlasPage = Packer.GetTexturesForAtlas(selAtlasName).ToList().FindIndex(delegate(Texture2D t) { return(selAtlasTexture == t); }); if (selAtlasPage == -1) { return; } m_SelectedAtlas = selAtlasIndex; m_SelectedPage = selAtlasPage; RefreshAtlasPageList(); } m_SelectedSprite = selectedSprite; Repaint(); } }
private void RefreshAtlasPageList() { if (m_AtlasNames.Length > 0) { string atlas = m_AtlasNames[m_SelectedAtlas]; Texture2D[] textures = Packer.GetTexturesForAtlas(atlas); m_PageNames = new string[textures.Length]; for (int i = 0; i < textures.Length; ++i) { m_PageNames[i] = string.Format(PackerWindowStyle.pageContentLabel.text, i + 1); } } else { m_PageNames = s_PageNamesEmpty; } // Validate if (m_SelectedPage >= m_PageNames.Length) { m_SelectedPage = 0; } }
private void RefreshAtlasNameList() { m_AtlasNames = Packer.atlasNames; m_AtlasInfos.Clear(); for (var i = 0; i < m_AtlasNames.Length; i++) { var atlasName = m_AtlasNames[i]; List <AtlasInfo> infos = new List <AtlasInfo>(); Texture2D[] textures = Packer.GetTexturesForAtlas(atlasName); foreach (var texture in textures) { AtlasInfo info = new AtlasInfo { texture = texture, format = texture.format.ToString(), size = string.Format("{0}x{1}", texture.width, texture.height) }; infos.Add(info); } m_AtlasInfos.Add(infos); } }