Esempio n. 1
0
        public static AtlasRaw Pack(string targetFolder, IPackSprite[] textures, PackSetting setting)
        {
            EditorUtility.DisplayProgressBar("", "generate atlas...", 0.5f);
            var atlasPath = Path.Combine(targetFolder, PackConst.DefaultAtlasAssetName);

            atlasPath = AssetDatabase.GenerateUniqueAssetPath(atlasPath);
            var atlasRaw = new PackAtlas(setting, atlasPath, textures).GenerateAtlas();

            EditorUtility.ClearProgressBar();
            return(atlasRaw);
        }
Esempio n. 2
0
        public static AtlasRaw Repack(AtlasRaw atlasRaw, IPackSprite[] textures = null, PackSetting setting = null)
        {
            EditorUtility.DisplayProgressBar("", "repack atlas...", 0.5f);
            textures = textures ?? PackAtlasSprite.ListSprites(atlasRaw);
            setting  = setting ?? new PackSetting(atlasRaw.maxSize, atlasRaw.padding, atlasRaw.isPOT, atlasRaw.forceSquare);
            var atlasPath = AssetDatabase.GetAssetPath(atlasRaw);

            atlasRaw = new PackAtlas(setting, atlasPath, textures).GenerateAtlas();
            EditorUtility.ClearProgressBar();
            if (atlasRaw == null)
            {
                Debug.LogError("Pack failed.");
                return(null);
            }
            RefreshUI();
            return(atlasRaw);
        }