diff --git a/.github/README.md b/.github/README.md index 1af98b1..8168700 100644 --- a/.github/README.md +++ b/.github/README.md @@ -12,13 +12,7 @@ This plugin helps you save/load textures and perform simple operations on them, ### iOS Setup -iOS setup is normally handled automatically via a post processor script but, if you wish, you can execute the following steps to set up the plugin manually: - -- set the value of **ENABLED** to *false* in *TOPostProcessBuild.cs* -- build your project -- insert `-framework MobileCoreServices -framework ImageIO` to the **Other Linker Flags** of *Unity-iPhone Target* (and *UnityFramework Target* on Unity 2019.3 or newer): - -![OtherLinkerFlags](screenshots/2.png) +iOS setup is handled automatically via a post processor script. If you rather want to set up the plugin manually, see: https://github.com/yasirkula/UnityTextureOps/wiki/Manual-Setup-for-iOS ## INSTALLATION diff --git a/Plugins/TextureOps/Editor/TOPostProcessBuild.cs b/Plugins/TextureOps/Editor/TOPostProcessBuild.cs index 42058d7..955762e 100644 --- a/Plugins/TextureOps/Editor/TOPostProcessBuild.cs +++ b/Plugins/TextureOps/Editor/TOPostProcessBuild.cs @@ -8,7 +8,68 @@ public class TOPostProcessBuild { - private const bool ENABLED = true; + [System.Serializable] + public class Settings + { + private const string SAVE_PATH = "ProjectSettings/TextureOps.json"; + + public bool AutomatedSetup = true; + + private static Settings m_instance = null; + public static Settings Instance + { + get + { + if( m_instance == null ) + { + try + { + if( File.Exists( SAVE_PATH ) ) + m_instance = JsonUtility.FromJson( File.ReadAllText( SAVE_PATH ) ); + else + m_instance = new Settings(); + } + catch( System.Exception e ) + { + Debug.LogException( e ); + m_instance = new Settings(); + } + } + + return m_instance; + } + } + + public void Save() + { + File.WriteAllText( SAVE_PATH, JsonUtility.ToJson( this, true ) ); + } + +#if UNITY_2018_3_OR_NEWER + [SettingsProvider] + public static SettingsProvider CreatePreferencesGUI() + { + return new SettingsProvider( "Project/yasirkula/Texture Ops", SettingsScope.Project ) + { + guiHandler = ( searchContext ) => PreferencesGUI(), + keywords = new System.Collections.Generic.HashSet() { "Texture", "Ops" } + }; + } +#endif + +#if !UNITY_2018_3_OR_NEWER + [PreferenceItem( "Texture Ops" )] +#endif + public static void PreferencesGUI() + { + EditorGUI.BeginChangeCheck(); + + Instance.AutomatedSetup = EditorGUILayout.Toggle( "Automated Setup", Instance.AutomatedSetup ); + + if( EditorGUI.EndChangeCheck() ) + Instance.Save(); + } + } [InitializeOnLoadMethod] public static void ValidatePlugin() @@ -22,11 +83,10 @@ public static void ValidatePlugin() } #if UNITY_IOS -#pragma warning disable 0162 [PostProcessBuild] public static void OnPostprocessBuild( BuildTarget target, string buildPath ) { - if( !ENABLED ) + if( !Settings.Instance.AutomatedSetup ) return; if( target == BuildTarget.iOS ) @@ -48,6 +108,5 @@ public static void OnPostprocessBuild( BuildTarget target, string buildPath ) File.WriteAllText( pbxProjectPath, pbxProject.WriteToString() ); } } -#pragma warning restore 0162 #endif } \ No newline at end of file diff --git a/Plugins/TextureOps/README.txt b/Plugins/TextureOps/README.txt index e35c833..9a35108 100644 --- a/Plugins/TextureOps/README.txt +++ b/Plugins/TextureOps/README.txt @@ -3,16 +3,19 @@ Online documentation & example code available at: https://github.com/yasirkula/UnityTextureOps E-mail: yasirkula@gmail.com + 1. ABOUT This plugin helps you save/load textures and perform simple operations on them, like scale and slice. + 2. iOS SETUP iOS setup is normally handled automatically via a post processor script but, if you wish, you can execute the following steps to set up the plugin manually: -- set the value of ENABLED to false in TOPostProcessBuild.cs +- set the value of 'Automated Setup' to false at 'Project Settings/yasirkula/Texture Ops' - build your project - insert "-framework MobileCoreServices -framework ImageIO" to the "Other Linker Flags" of Unity-iPhone Target (and UnityFramework Target on Unity 2019.3 or newer) + 3. SCRIPTING API Please see the online documentation for a more in-depth documentation of the Scripting API: https://github.com/yasirkula/UnityTextureOps diff --git a/package.json b/package.json index c73bec2..09c13f3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.textureops", "displayName": "Texture Ops", - "version": "1.1.3", + "version": "1.1.4", "documentationUrl": "https://github.com/yasirkula/UnityTextureOps", "changelogUrl": "https://github.com/yasirkula/UnityTextureOps/releases", "licensesUrl": "https://github.com/yasirkula/UnityTextureOps/blob/master/LICENSE.txt",