Merge pull request #4 from aliakseikalosha/splashpack
Update texture import settings
This commit is contained in:
@@ -125,6 +125,7 @@ namespace SplashEdit.RuntimeCode
|
|||||||
public static PSXTexture2D CreateFromTexture2D(Texture2D inputTexture, PSXBPP bitDepth)
|
public static PSXTexture2D CreateFromTexture2D(Texture2D inputTexture, PSXBPP bitDepth)
|
||||||
{
|
{
|
||||||
PSXTexture2D psxTex = new PSXTexture2D();
|
PSXTexture2D psxTex = new PSXTexture2D();
|
||||||
|
Utils.SetTextureImporterFormat(inputTexture, true);
|
||||||
|
|
||||||
psxTex.Width = inputTexture.width;
|
psxTex.Width = inputTexture.width;
|
||||||
psxTex.QuantizedWidth = bitDepth == PSXBPP.TEX_4BIT ? inputTexture.width / 4 :
|
psxTex.QuantizedWidth = bitDepth == PSXBPP.TEX_4BIT ? inputTexture.width / 4 :
|
||||||
|
|||||||
@@ -308,6 +308,8 @@ namespace SplashEdit.RuntimeCode
|
|||||||
|
|
||||||
public static class Utils
|
public static class Utils
|
||||||
{
|
{
|
||||||
|
private static int MaxTextureSize => 256;
|
||||||
|
|
||||||
public static (Rect, Rect) BufferForResolution(Vector2 selectedResolution, bool verticalLayout, Vector2 offset = default)
|
public static (Rect, Rect) BufferForResolution(Vector2 selectedResolution, bool verticalLayout, Vector2 offset = default)
|
||||||
{
|
{
|
||||||
if (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 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user