I'm trying to use ODR in my game which doesn't use xcassets.
So, I've got a texture with a tag (e.g. "tutorial"), made it ODR in project settings and used the code below the get it downloaded:
NSBundleResourceRequest *resourceRequest = [[NSBundleResourceRequest alloc] initWithTags:tags];
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:^(BOOL resourcesAvailable) {
if (resourcesAvailable) {
// Upload the texture
}
else
{
[resourceRequest beginAccessingResourcesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to load assets pack");
}
else
{
// Upload the texture
}
}];
}
}];
The main bundle doesn't contain the texture in question (I've looked the bundle through in simulator folder). After calling the code above XCode and logs report that it was successfully downloaded and is ready to use.
Where the comment // Upload the texture
is I need to call my code for uploading the texture into video memory, but the problem is - I can't get exact location of the downloaded file to do so.
Is there any way to know the location of downloaded assets?
There is a bundle provided in NSBundleResourceRequest which you can use to get the resources. See Apple's Docs on NSBundleResourceRequest
来源:https://stackoverflow.com/questions/33824528/on-demand-resources-in-ios-9-how-to-find-out-exact-location-of-downloaded-reso