UnityNativeFilePicker icon indicating copy to clipboard operation
UnityNativeFilePicker copied to clipboard

Add icon path to custom file types.

Open uniquecorn opened this issue 1 year ago • 8 comments

Allows you to specify a path to add a custom icon to your document type.

It seems to be broken in XCode, but if it is specified in the plist file, it will work. Screenshot 2024-10-19 at 2 07 06 AM

Icons working shown here: IMG_9CFE85BEEF01-1

uniquecorn avatar Oct 18 '24 18:10 uniquecorn

May I ask why it's a string array (not just a single string) and if the path is project-relative or absolute?

yasirkula avatar Oct 19 '24 17:10 yasirkula

Hey, I just made it an array cuz xcode allows you to add multiple icon files (which is just an array of string icon paths). Not even sure why you would need multiple icon files, but the parameter requires it to be an array. The path is project relative. For my icon, it's literally just the icon name + extension because I copy the file to the xcode project root directory. I did not implement the copying of the file in this because I'm assuming a user who does anything xcode related would have their own tools to do xcode project management.

uniquecorn avatar Oct 20 '24 10:10 uniquecorn

Also just to note, as of even the latest Xcode 16, adding the file via Xcode is still broken, but what it's supposed to do is just add the icon path into the plist file. Even after adding the path to the plist file, the icon does not show up in Xcode as assigned, but when you build the project everything works.

uniquecorn avatar Oct 20 '24 10:10 uniquecorn

After some research, my conclusion is that the array's purpose is to upload the icon in different resolutions. Did you try it with an arbitrary resolution like 300x500? Does it work? Or does it require power-of-2 resolutions?

I need this feature to be as user-friendly as possible before merging it. To achieve that, the iconPath should be changed to a Texture2D so that icons can be assigned from the project via drag&drop. You can get the Unity-project-relative path of the icon via AssetDatabase.GetAssetPath. The icon should also be copied to the build folder automatically. If its resolution has limitations (power-of-2?), then either the icon should be resized automatically before copying to the build folder, or an error dialog should be displayed.

For reference, my LocalizedAppTitle plugin adds files to Xcode project programmatically and resizes images programmatically. Its implementation might be helpful here, too.

yasirkula avatar Oct 20 '24 12:10 yasirkula

Hmm, I use an icns file though, with all the resolutions I need. If I did that, then I would not be able to use the icns file.

uniquecorn avatar Oct 20 '24 19:10 uniquecorn

I do add the file to Xcode programatically, but I just have my own solution where I have a folder (Assets/Editor/Xcode) that auto copies the contents into any Xcode project. Lemme think about it, I think it's technically possible to do a shell script to create the icns file with the user defined sprites, but it's just gonna be slow vs creating it yourself and never having to touch it again. I also haven't tested using pngs directly, but i'll assume that the sprites need to be named with the conventions. You'd also need to allow the user to use specific overrides of sprite sizes, making it even more complicated. And with retina, you need the options for 2x 144 dpi sprites.

uniquecorn avatar Oct 20 '24 19:10 uniquecorn

I didn't know about icns. You can create all different-sized icons from a single image using the method I've proposed. Some users would prefer assigning all resolutions by hand but hey, they can do it manually from Xcode.

yasirkula avatar Oct 21 '24 20:10 yasirkula

Okay, I will work on this and update when I am done.

uniquecorn avatar Oct 22 '24 21:10 uniquecorn