update texture import settings

This commit is contained in:
aliaksei.kalosha
2025-04-06 18:09:46 +02:00
parent 59e6b1693f
commit 840d46c20c
2 changed files with 25 additions and 2 deletions

View File

@@ -308,6 +308,8 @@ namespace SplashEdit.RuntimeCode
public static class Utils
{
private static int MaxTextureSize => 256;
public static (Rect, Rect) BufferForResolution(Vector2 selectedResolution, bool verticalLayout, Vector2 offset = default)
{
if (offset == default)
@@ -331,8 +333,28 @@ namespace SplashEdit.RuntimeCode
};
}
public static byte Clamp0255(float v) => (byte)(Mathf.Clamp(v, 0, 255));
public static void SetTextureImporterFormat(Texture2D texture, bool isReadable)
{
if (texture == null)
{
return;
}
string assetPath = AssetDatabase.GetAssetPath(texture);
var tImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
if (tImporter != null)
{
if (tImporter.maxTextureSize > MaxTextureSize)
{
tImporter.maxTextureSize = MaxTextureSize;
}
tImporter.isReadable = isReadable;
AssetDatabase.ImportAsset(assetPath);
AssetDatabase.Refresh();
}
}
}
}