Last active
November 15, 2024 11:48
-
-
Save 4liceD/29e0879eb5383c90a56f537bf0562c5a to your computer and use it in GitHub Desktop.
Unity Editor Sync Texture Overrides from Android to iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Written By Sonnet 3.5 | |
//I take no responsibility if this script breaks your project or causes data loss | |
//This script copies all Android Texture Override Settings if exists and applies them to the iOS Texture Override Settings in your Assets Folder | |
using UnityEngine; | |
using UnityEditor; | |
using System.IO; | |
public class TextureOverrideSync : EditorWindow | |
{ | |
[MenuItem("Tools/Textures/Sync Android to iOS Texture Overrides")] | |
static void SyncOverrides() | |
{ | |
string[] guids = AssetDatabase.FindAssets("t:Texture", new[] { "Assets" }); | |
foreach (string guid in guids) | |
{ | |
string path = AssetDatabase.GUIDToAssetPath(guid); | |
TextureImporter importer = AssetImporter.GetAtPath(path) as TextureImporter; | |
if (importer != null) | |
{ | |
TextureImporterPlatformSettings androidSettings = importer.GetPlatformTextureSettings("Android"); | |
if (androidSettings.overridden) | |
{ | |
TextureImporterPlatformSettings iosSettings = importer.GetPlatformTextureSettings("iPhone"); | |
iosSettings.overridden = true; | |
iosSettings.maxTextureSize = androidSettings.maxTextureSize; | |
iosSettings.resizeAlgorithm = androidSettings.resizeAlgorithm; | |
iosSettings.format = androidSettings.format; | |
iosSettings.textureCompression = androidSettings.textureCompression; | |
iosSettings.compressionQuality = androidSettings.compressionQuality; | |
iosSettings.crunchedCompression = androidSettings.crunchedCompression; | |
iosSettings.allowsAlphaSplitting = androidSettings.allowsAlphaSplitting; | |
iosSettings.androidETC2FallbackOverride = androidSettings.androidETC2FallbackOverride; | |
importer.SetPlatformTextureSettings(iosSettings); | |
EditorUtility.SetDirty(importer); | |
importer.SaveAndReimport(); | |
Debug.Log($"Updated iOS settings for: {path}"); | |
} | |
} | |
} | |
AssetDatabase.Refresh(); | |
Debug.Log("Texture override sync completed!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment