public WWW Load(string url) { if (!File.Exists(path + url.GetHashCode())) { //如果之前不存在缓存文件 var file = remoteFileLoader.Load(url); if (file != null) { File.WriteAllBytes(path + url.GetHashCode(), file.bytes); } return(file); } else { return(localFileLoader.Load(url)); } }
public IObservable <WWW> Load(string url) { var hashCodeUrl = Path + url.GetHashCode(); //如果之前不存在缓存文件 if (!File.Exists(hashCodeUrl)) { var www = remoteFileLoader.Load(url); www.Subscribe(file => { if (file != null) { var encodeBytes = FileEncode?.Invoke(file); File.WriteAllBytes(hashCodeUrl, encodeBytes); } }); return(www); } else { return(localFileLoader.Load(hashCodeUrl)); } }