utility to sync android tex import settings with ios
lmfao it got my amethyst matcap
This commit is contained in:
parent
1f779f9297
commit
b475edd583
6 changed files with 203 additions and 3 deletions
|
|
@ -108,14 +108,14 @@ TextureImporter:
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
buildTarget: iPhone
|
buildTarget: iPhone
|
||||||
maxTextureSize: 2048
|
maxTextureSize: 32
|
||||||
resizeAlgorithm: 0
|
resizeAlgorithm: 0
|
||||||
textureFormat: -1
|
textureFormat: 50
|
||||||
textureCompression: 1
|
textureCompression: 1
|
||||||
compressionQuality: 50
|
compressionQuality: 50
|
||||||
crunchedCompression: 0
|
crunchedCompression: 0
|
||||||
allowsAlphaSplitting: 0
|
allowsAlphaSplitting: 0
|
||||||
overridden: 0
|
overridden: 1
|
||||||
ignorePlatformSupport: 0
|
ignorePlatformSupport: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
|
|
||||||
8
Editor.meta
Normal file
8
Editor.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 49fa841ab327ed841a03737032f5ffb7
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
17
Editor/TexturePlatformSync.asmdef
Normal file
17
Editor/TexturePlatformSync.asmdef
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "TexturePlatformSync",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
|
|
||||||
7
Editor/TexturePlatformSync.asmdef.meta
Normal file
7
Editor/TexturePlatformSync.asmdef.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2bf8ed176c3ce294c93c71ac2a292b1a
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
157
Editor/TexturePlatformSync.cs
Normal file
157
Editor/TexturePlatformSync.cs
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class TexturePlatformSync
|
||||||
|
{
|
||||||
|
[MenuItem("LillithRosePup/Sync Texture Platforms (Android -> iOS)")]
|
||||||
|
public static void SyncTexturePlatforms()
|
||||||
|
{
|
||||||
|
var proceed = EditorUtility.DisplayDialog(
|
||||||
|
"Sync Texture Platforms",
|
||||||
|
"This will find all textures in the project and copy Android import settings to iOS if they differ.\n\nThis may take a while for large projects. Continue?",
|
||||||
|
"Continue",
|
||||||
|
"Cancel"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!proceed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncAllTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SyncAllTextures()
|
||||||
|
{
|
||||||
|
// Find all texture assets in the project
|
||||||
|
string[] textureGuids = AssetDatabase.FindAssets("t:Texture2D");
|
||||||
|
|
||||||
|
int totalTextures = textureGuids.Length;
|
||||||
|
int syncedCount = 0;
|
||||||
|
int skippedCount = 0;
|
||||||
|
int errorCount = 0;
|
||||||
|
bool wasCancelled = false;
|
||||||
|
|
||||||
|
Debug.Log($"Found {totalTextures} textures. Starting sync...");
|
||||||
|
|
||||||
|
// Start batching asset imports to pause reimporting until complete
|
||||||
|
AssetDatabase.StartAssetEditing();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0; i < textureGuids.Length; i++)
|
||||||
|
{
|
||||||
|
string guid = textureGuids[i];
|
||||||
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||||
|
|
||||||
|
// Update progress bar
|
||||||
|
if (EditorUtility.DisplayCancelableProgressBar(
|
||||||
|
"Syncing Texture Platforms",
|
||||||
|
$"Processing: {System.IO.Path.GetFileName(path)} ({i + 1}/{totalTextures})",
|
||||||
|
(float)i / totalTextures))
|
||||||
|
{
|
||||||
|
wasCancelled = true;
|
||||||
|
Debug.LogWarning("Texture platform sync cancelled by user.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter;
|
||||||
|
if (importer == null)
|
||||||
|
{
|
||||||
|
skippedCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Android and iOS platform settings
|
||||||
|
TextureImporterPlatformSettings androidSettings = importer.GetPlatformTextureSettings("Android");
|
||||||
|
TextureImporterPlatformSettings iosSettings = importer.GetPlatformTextureSettings("iOS");
|
||||||
|
|
||||||
|
// Check if settings differ
|
||||||
|
if (SettingsDiffer(androidSettings, iosSettings))
|
||||||
|
{
|
||||||
|
// Copy Android settings to iOS
|
||||||
|
TextureImporterPlatformSettings newIosSettings = new TextureImporterPlatformSettings
|
||||||
|
{
|
||||||
|
name = "iOS",
|
||||||
|
overridden = androidSettings.overridden,
|
||||||
|
maxTextureSize = androidSettings.maxTextureSize,
|
||||||
|
textureCompression = androidSettings.textureCompression,
|
||||||
|
compressionQuality = androidSettings.compressionQuality,
|
||||||
|
allowsAlphaSplitting = androidSettings.allowsAlphaSplitting,
|
||||||
|
format = androidSettings.format,
|
||||||
|
crunchedCompression = androidSettings.crunchedCompression
|
||||||
|
};
|
||||||
|
|
||||||
|
importer.SetPlatformTextureSettings(newIosSettings);
|
||||||
|
// Import within the batch session - imports will be queued until StopAssetEditing
|
||||||
|
AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
|
||||||
|
syncedCount++;
|
||||||
|
Debug.Log($"Synced: {path}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skippedCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
errorCount++;
|
||||||
|
Debug.LogError($"Error processing {path}: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// Stop batching - this will trigger all queued imports at once
|
||||||
|
AssetDatabase.StopAssetEditing();
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorUtility.ClearProgressBar();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
|
||||||
|
// Show completion dialog with statistics (even if cancelled)
|
||||||
|
string title = wasCancelled ? "Sync Cancelled" : "Sync Complete";
|
||||||
|
string message = wasCancelled
|
||||||
|
? $"Texture platform sync was cancelled.\n\n" +
|
||||||
|
$"Total textures: {totalTextures}\n" +
|
||||||
|
$"Processed: {syncedCount + skippedCount + errorCount}\n" +
|
||||||
|
$"Synced: {syncedCount}\n" +
|
||||||
|
$"Skipped (already matching): {skippedCount}\n" +
|
||||||
|
$"Errors: {errorCount}"
|
||||||
|
: $"Texture platform sync completed!\n\n" +
|
||||||
|
$"Total textures: {totalTextures}\n" +
|
||||||
|
$"Synced: {syncedCount}\n" +
|
||||||
|
$"Skipped (already matching): {skippedCount}\n" +
|
||||||
|
$"Errors: {errorCount}";
|
||||||
|
|
||||||
|
EditorUtility.DisplayDialog(title, message, "OK");
|
||||||
|
|
||||||
|
string logMessage = wasCancelled
|
||||||
|
? $"Texture platform sync cancelled. Processed: {syncedCount + skippedCount + errorCount}, Synced: {syncedCount}, Skipped: {skippedCount}, Errors: {errorCount}"
|
||||||
|
: $"Texture platform sync complete. Synced: {syncedCount}, Skipped: {skippedCount}, Errors: {errorCount}";
|
||||||
|
Debug.Log(logMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool SettingsDiffer(TextureImporterPlatformSettings android, TextureImporterPlatformSettings ios)
|
||||||
|
{
|
||||||
|
// If Android settings are not overridden, they match by default
|
||||||
|
if (!android.overridden)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare all relevant settings
|
||||||
|
return android.maxTextureSize != ios.maxTextureSize ||
|
||||||
|
android.textureCompression != ios.textureCompression ||
|
||||||
|
android.compressionQuality != ios.compressionQuality ||
|
||||||
|
android.allowsAlphaSplitting != ios.allowsAlphaSplitting ||
|
||||||
|
android.format != ios.format ||
|
||||||
|
android.crunchedCompression != ios.crunchedCompression ||
|
||||||
|
android.overridden != ios.overridden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
11
Editor/TexturePlatformSync.cs.meta
Normal file
11
Editor/TexturePlatformSync.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 715622ca2b23bdd429874933f244cd10
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
Add table
Add a link
Reference in a new issue