public void SetImageImmediate(string key, string resource = null, int order = 0, Action callBack = null)
{
if (string.IsNullOrEmpty(key))
{
return;
}
this.current = key;
this.key = string.Empty;
if (RenewablePool.Instance.Exist(cache, key, string.Empty))
{
m_texture = RenewablePool.Instance.Pop <Texture2D>(cache, key);
this.key = key; callBack?.Invoke();
SetTexture(m_texture);
if (!RenewablePool.Instance.Recent(cache, key))
{
this.key = string.Empty; Get(key, null, order, callBack);
}
}
else
{
string path = string.Format("{0}/{1}", Application.persistentDataPath, key);
if (RenewableFile.Exists(path))
{
byte[] buffer = RenewableFile.Read(path);
bool recent = RenewableResourceUpdate.Instance.Validation(key, buffer);
Create(new RenewableDownloadHandler(key, string.Empty, string.Empty, recent, buffer, null));
if (recent)
{
this.key = key;
RenewableResourceUpdate.Instance.Remove(key);
}
else
{
Get(key, null, order, callBack);
}
}
else
{
path = string.Format("{0}{1}", resource, key);
if (TryLoad <Texture2D>(path, out Texture2D source))
{
bool recent = RenewableResourceUpdate.Instance.Validation(key, null);
Create(new RenewableDownloadHandler(key, string.Empty, string.Empty, recent, null, Instantiate(source)));
Resources.UnloadAsset(source);
if (recent)
{
this.key = key;
RenewableResourceUpdate.Instance.Remove(key);
}
else
{
Get(key, null, order, callBack);
}
}
else
{
Get(key, null, order, callBack);
}
}
}
}