public void CreateAssetImmediate(string key, string parameter, string resource = null, int order = 0, Action callBack = null) { if (string.IsNullOrEmpty(key)) { return; } this.current = key; this.key = string.Empty; this.parameter = parameter; if (RenewablePool.Instance.Exist(cache, key + parameter, string.Empty)) { this.asset = RenewablePool.Instance.Pop <Object>(cache, key + parameter); this.key = key; Refresh(this.asset); callBack?.Invoke(); if (!RenewablePool.Instance.Recent(cache, key + parameter)) { this.key = string.Empty; Get(key, parameter, order, callBack); } } else { string path = Application.persistentDataPath + "/" + key; if (RenewableFile.Exists(path)) { byte[] buffer = RenewableFile.Read(path); bool recent = RenewableResourceUpdate.Instance.Validation(key, buffer); Create(new RenewableDownloadHandler(key, parameter, string.Empty, recent, buffer, null)); if (recent) { this.key = key; RenewableResourceUpdate.Instance.Remove(key); } else { Get(key, parameter, order, callBack); } } else { path = string.Format("{0}{1}", resource, parameter); if (TryLoad <Texture2D>(path, out Texture2D source)) { bool recent = RenewableResourceUpdate.Instance.Validation(key, null); Object _temp; if (RenewablePool.Instance.Exist(cache, key + parameter, string.Empty)) { _temp = RenewablePool.Instance.Pop <Object>(cache, key + parameter); } else { _temp = Instantiate(source); RenewablePool.Instance.Push(cache, key + parameter, string.Empty, recent, _temp); } Refresh(_temp); Resources.UnloadAsset(source); if (recent) { this.key = key; RenewableResourceUpdate.Instance.Remove(key); } else { Get(key, parameter, order, callBack); } } else { Get(key, parameter, order, callBack); } } } }
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); } } } }