Skip to content

Commit

Permalink
Moved iOS build post-processor settings to 'Project Settings/yasirkul…
Browse files Browse the repository at this point in the history
…a/Texture Ops'
  • Loading branch information
yasirkula committed Jul 5, 2021
1 parent 4282345 commit 1e169eb
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 13 deletions.
8 changes: 1 addition & 7 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
67 changes: 63 additions & 4 deletions Plugins/TextureOps/Editor/TOPostProcessBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Settings>( 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<string>() { "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()
Expand All @@ -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 )
Expand All @@ -48,6 +108,5 @@ public static void OnPostprocessBuild( BuildTarget target, string buildPath )
File.WriteAllText( pbxProjectPath, pbxProject.WriteToString() );
}
}
#pragma warning restore 0162
#endif
}
5 changes: 4 additions & 1 deletion Plugins/TextureOps/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
Online documentation & example code available at: https://github.com/yasirkula/UnityTextureOps
E-mail: [email protected]


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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 1e169eb

Please sign in to comment.