Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support easy loading of textures from an asset catalog #150

Open
JohnSundell opened this issue Jan 15, 2018 · 4 comments
Open

Support easy loading of textures from an asset catalog #150

JohnSundell opened this issue Jan 15, 2018 · 4 comments

Comments

@JohnSundell
Copy link
Owner

Since Imagine Engine doesn't rely on the default system image loading mechanism (using UIImage(named:) on iOS) loading textures from an asset catalog is not super easy. While possible it requires you to create Animation or Texture instances using Image, like this:

let image = Image(named: "player")!
actor.animation = Animation(image: image)

It would be nicer if Imagine Engine could automatically search the app's asset catalog for an image with a given name, so that you could simply use:

actor.animation = Animation(textureNamed: "player")
@jussi80
Copy link
Contributor

jussi80 commented Jan 26, 2018

I can get down with this. 🙂

@jussi80
Copy link
Contributor

jussi80 commented Jan 27, 2018

Looks like we have run out of luck with this one: asset catalog is compiled as Assets.car file. That file is Apple's proprietary format which could be opened with CUICatalog, which is private class. If we use private class, it is very likely that apps with this will not be passed through AppStore review process. 🧐

@JohnSundell
Copy link
Owner Author

@jussi80 I don't think we should attempt to parse the asset catalogs ourselves. There's the NSDataAsset class which provides programmatic access to an asset catalog, it should be able to be used to access the data we need to load a texture 🙂

@jussi80
Copy link
Contributor

jussi80 commented Jan 27, 2018

@JohnSundell NSDataAsset seems to read everything else than image data which is rather strange. Taken from NSDataSet file

/// Data assets are not in the same class of stored content as images, so you cannot use a data asset to get image data for an image.

I added images and some random json filled files to .xcassets and images can't be opened, but those json files are no problem with the NSDataAsset. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants