Example #1
0
        public Texture2D AddImage(string fileName)
        {
            if (fileName == null) {
                throw new ArgumentNullException("fileName");
            }

            fileName = Path.Combine(ImageRoot ?? string.Empty, fileName);

            Texture2D tex = null;

            lock (_lock) {
                if (_cache.ContainsKey(fileName)) {
                    tex = _cache[fileName];
                } else {
                    if (Path.GetExtension(fileName).ToLower() == ".pvr") {
                        tex = new Texture2D(fileName);
                    } else {
                        UIImage image = UIImage.FromFile(fileName);
                        if (image == null) {
                            throw new ArgumentException("Could not find image: " + fileName);
                        }

                        tex = new Texture2D(image);
                    }

                    _cache.Add(fileName, tex);
                }
            }

            return tex;
        }
Example #2
0
 public void SetText(string text)
 {
     if (_dimensions.IsEmpty) {
         Texture = new Texture2D(text, _fontName, _fontSize);
     } else {
         Texture = new Texture2D(text, _dimensions, UITextAlignment.Center, _fontName, _fontSize);
     }
 }
Example #3
0
 public Sprite(Texture2D tex)
 {
     Texture = tex;
 }