Esempio n. 1
0
        private void LoadSpritesInternal()
        {
            Debug.LogWarning("Loading sprites");

            foreach (XmlNode childNode in root)
            {
                if (childNode.Name != "SpriteAtlas")
                {
                    continue;
                }

                var atlasName = XmlUtil.GetStringAttribute(childNode, "name");
                if (spriteAtlases.ContainsKey(atlasName))
                {
                    throw new ParseException(String.Format("Duplicate atlas name \"{0}\"", atlasName), childNode);
                }

                Debug.LogWarningFormat("Generating atlas \"{0}\"", atlasName);

                var atlasPacker = new AtlasPacker();

                int count = 0;
                foreach (XmlNode spriteNode in childNode.ChildNodes)
                {
                    var path = spriteNode.InnerText;
                    if (fileWatcher != null)
                    {
                        fileWatcher.WatchFile(path);
                    }

                    var name = XmlUtil.GetStringAttribute(spriteNode, "name");
                    Debug.LogWarningFormat("Found definition for sprite \"{0}\" in atlas \"{1}\"", name, atlasName);

                    var fullPath = Path.Combine(_sapphirePath, path);

                    if (!File.Exists(fullPath))
                    {
                        throw new FileNotFoundException(String.Format("Sprite at path \"{0}\" not found!", fullPath), fullPath);
                    }

                    atlasPacker.AddSprite(name, fullPath);
                    count++;
                }

                Debug.LogWarningFormat("Added {0} sprites to atlas \"{1}\"", count, atlasName);

                try
                {
                    spriteAtlases[atlasName] = atlasPacker.GenerateAtlas(atlasName);
                }
                catch (AtlasPacker.TooManySprites)
                {
                    ErrorLogger.LogError("Too many sprites in atlas \"" + atlasName + "\", move some sprites to a new atlas!");
                    break;
                }

                Debug.LogWarningFormat("Atlas \"{0}\" generated", atlasName);
            }
        }
Esempio n. 2
0
        public static UITextureAtlas GetQuartzAtlas()
        {
            if (_atlas == null)
            {
                var atlasPacker = new AtlasPacker();
                atlasPacker.AddSprite("QuartzIcon", GetTextureResource("QuartzIcon.png"));
                atlasPacker.AddSprite("QuartzIconHover", GetTextureResource("QuartzIconHover.png"));
                atlasPacker.AddSprite("QuartzIconPressed", GetTextureResource("QuartzIconPressed.png"));
                atlasPacker.AddSprite("DefaultPanelBackground", GetTextureResource("DefaultPanelBackground.png"));
                _atlas = atlasPacker.GenerateAtlas("QuartzIconsAtlas");
            }

            return(_atlas);
        }
		public static UITextureAtlas GetQuartzAtlas()
        {
            if (_atlas == null)
            {
                var atlasPacker = new AtlasPacker();
				atlasPacker.AddSprite("QuartzIcon", GetTextureResource("QuartzIcon.png"));
				atlasPacker.AddSprite("QuartzIconHover", GetTextureResource("QuartzIconHover.png"));
				atlasPacker.AddSprite("QuartzIconPressed", GetTextureResource("QuartzIconPressed.png"));
                atlasPacker.AddSprite("DefaultPanelBackground", GetTextureResource("DefaultPanelBackground.png"));
				_atlas = atlasPacker.GenerateAtlas("QuartzIconsAtlas");
            }

            return _atlas;
        }
Esempio n. 4
0
        private void LoadSpritesInternal()
        {
            Debug.LogWarning("Loading sprites");

            foreach (XmlNode childNode in root)
            {
                if (childNode.Name != "SpriteAtlas")
                {
                    continue;
                }

                var atlasName = XmlUtil.GetStringAttribute(childNode, "name");
                if (spriteAtlases.ContainsKey(atlasName))
                {
                    throw new ParseException(String.Format("Duplicate atlas name \"{0}\"", atlasName), childNode);
                }

                Debug.LogWarningFormat("Generating atlas \"{0}\"", atlasName);

                var atlasPacker = new AtlasPacker();

                int count = 0;
                foreach (XmlNode spriteNode in childNode.ChildNodes)
                {
                    var path = spriteNode.InnerText;
                    if (fileWatcher != null)
                    {
                        fileWatcher.WatchFile(path);
                    }

                    var name = XmlUtil.GetStringAttribute(spriteNode, "name");
                    Debug.LogWarningFormat("Found definition for sprite \"{0}\" in atlas \"{1}\"", name, atlasName);

                    var fullPath = Path.Combine(_sapphirePath, path);

                    if (!File.Exists(fullPath))
                    {
                        throw new FileNotFoundException(String.Format("Sprite at path \"{0}\" not found!", fullPath), fullPath);
                    }

                    atlasPacker.AddSprite(name, fullPath);
                    count++;
                }

                Debug.LogWarningFormat("Added {0} sprites to atlas \"{1}\"", count, atlasName);
                
                try
                {
                    spriteAtlases[atlasName] = atlasPacker.GenerateAtlas(atlasName);
                }
                catch (AtlasPacker.TooManySprites)
                {
                    ErrorLogger.LogError("Too many sprites in atlas \"" + atlasName + "\", move some sprites to a new atlas!");
                    break;
                }

                Debug.LogWarningFormat("Atlas \"{0}\" generated", atlasName);
            }
        }