From 390bb282dd221a110a7382ece9ee234b90a326e2 Mon Sep 17 00:00:00 2001 From: Elijah James Date: Sat, 19 Oct 2024 02:03:03 +0800 Subject: [PATCH] Add icon path to custom file types. --- .../NativeFilePicker/Editor/NativeFilePickerCustomTypes.cs | 2 ++ .../Editor/NativeFilePickerPostProcessBuild.cs | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/Plugins/NativeFilePicker/Editor/NativeFilePickerCustomTypes.cs b/Plugins/NativeFilePicker/Editor/NativeFilePickerCustomTypes.cs index 19ffdc3..2e66f45 100644 --- a/Plugins/NativeFilePicker/Editor/NativeFilePickerCustomTypes.cs +++ b/Plugins/NativeFilePicker/Editor/NativeFilePickerCustomTypes.cs @@ -20,6 +20,8 @@ public class TypeHolder public string[] conformsTo; [Tooltip( "Extension(s) associated with this type (don't include the period; i.e. use myextension instead of .myextension)" )] public string[] extensions; + [Tooltip( "Path to icon file in your XCode project. (Optional)" )] + public string[] iconPath; } private const string INITIAL_SAVE_PATH = "Assets/Plugins/NativeFilePicker/NativeFilePickerCustomTypes.asset"; diff --git a/Plugins/NativeFilePicker/Editor/NativeFilePickerPostProcessBuild.cs b/Plugins/NativeFilePicker/Editor/NativeFilePickerPostProcessBuild.cs index edd6532..4f2c8b7 100644 --- a/Plugins/NativeFilePicker/Editor/NativeFilePickerPostProcessBuild.cs +++ b/Plugins/NativeFilePicker/Editor/NativeFilePickerPostProcessBuild.cs @@ -127,6 +127,13 @@ public static void OnPostprocessBuild( BuildTarget target, string buildPath ) customTypeDict.SetString( "UTTypeIdentifier", customType.identifier ); customTypeDict.SetString( "UTTypeDescription", customType.description ); + if(customTypes[i].iconPath != null && customTypes[i].iconPath.Length > 0) + { + PlistElementArray icons = customTypeDict.CreateArray( "UTTypeIconFiles" ); + for( int j = 0; j < customType.iconPath.Length; j++ ) + icons.AddString( customType.iconPath[j] ); + } + PlistElementArray conformsTo = customTypeDict.CreateArray( "UTTypeConformsTo" ); for( int j = 0; j < customType.conformsTo.Length; j++ ) conformsTo.AddString( customType.conformsTo[j] );