47 lines
841 B
C#
47 lines
841 B
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class TexturePool
|
||
|
|
{
|
||
|
|
public static Dictionary<string, Texture2D> dicTextures;
|
||
|
|
|
||
|
|
static List<string> removeKeys;
|
||
|
|
|
||
|
|
static TexturePool()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void ClearTexture()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
static int MaxTextureCount;
|
||
|
|
|
||
|
|
public static Texture2D GetTexture(string key)
|
||
|
|
{
|
||
|
|
Texture2D tex = null;
|
||
|
|
if (dicTextures.ContainsKey(key))
|
||
|
|
{
|
||
|
|
tex = dicTextures[key];
|
||
|
|
removeKeys.Remove(key);
|
||
|
|
}
|
||
|
|
return tex;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void SaveTexture(string key, Texture2D txt)
|
||
|
|
{
|
||
|
|
if (!dicTextures.ContainsKey(key))
|
||
|
|
{
|
||
|
|
dicTextures.Add(key, txt);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void RemoveTexture(string key)
|
||
|
|
{
|
||
|
|
removeKeys.Add(key);
|
||
|
|
}
|
||
|
|
}
|