Exemplo n.º 1
0
        public static Texture GetTexture(string filename, string folder = "Textures/")
        {
            if (!textures.TryGetValue(filename, out Texture texture))
            {
                texture = Texture.Load(filename, folder);
                textures.Add(filename, texture);
            }

            return(texture);
        }
Exemplo n.º 2
0
        public static Texture GetTexture(string filename, bool shouldStoreData = false, bool shouldCache = true,
                                         string folder = "Textures/")
        {
            Debug.Assert(!string.IsNullOrEmpty(filename), "Texture filename can't be empty or null.");
            Debug.Assert(!string.IsNullOrEmpty(folder), "Texture folder can't be empty or null.");

            if (!textures.TryGetValue(filename, out Texture texture))
            {
                texture = Texture.Load(filename, folder, shouldStoreData);

                // It's possible for this flag to be false even though the texture is already cached (i.e. was
                // previously loaded and cached). This scenario shouldn't occur in practice, but also doesn't really
                // matter if it does.
                if (shouldCache)
                {
                    textures.Add(filename, texture);
                }
            }

            return(texture);
        }