Resize Pro is the fastest texture resize/scale tool for Unity. Works in Editor and Run-time.
In Editor textures can be resized directly from Project window or by using batch converter (new texture is saved in PNG or JPG formats). Run-time API adds ResizePro() extension method to the Texture2D class.
v2018.4
• Updated for Unity 2017.4 and Unity 2018.2
v2018.3
• Fixed ‘black texture’ problem on mobile devices.
v2018.2
• Updated for Unity 2018.1
• Compatible with Linear color space
• Improved Resize adjustment. AspectRatio can be locked by Width, Height or Max Resolution.
v1.32
• Correct handing original texture extension (lowercase or uppercase).
v1.3 - v1.31
• Resized textures inside editor now can be saved as TGA files too (requires Encode To TGA plugin).
• Generated textures now will have correct import settings.
v1.2
• Editor converter now can detect Bump textures and resize them correctly.
v1.1
• Run-time API updated. Now textures with any format can be resized, even if they are not readable.
using UnityEngine;
//ResizePro
using VacuumShaders.TextureExtensions;
public class NewBehaviourScript : MonoBehaviour
{
public Texture2D texture;
int width;
int height;
void Start ()
{
//ResizePro
texture.ResizePro(width, height);
}
}
Cannot seem to find a ResizePro function that have those arguments within the namespace VacuumShaders.TextureAdjustments or VacuumShaders.TextureExtensions. Can only find TextureResizePro.ResizePro(Texture texture, int width, int height) and TextureResizePro.ResizePro(Texture texture, int width, int height, TextureFormat format, bool hasMipMap)
I just find it odd that you proclaim that your plugin can handle “all type of textures.” when there are exceptions. Anyway if you can point me in the direction of the mentioned function that would be great!
[EDIT] I just bought the ResizePro plugin directly, and this gives me the function with the parameters you mentioned, so there is a mismatch between the “original” and the one included in Texture Adjustments.
Unfortunately it did not work, here is a code example which will give the error:
WWW www = new WWW("http://kanda.dk/TestLargeImage/PANO_Field.jpg");
while (!www.isDone)
{
yield return null;
}
Texture2D texture = www.texture;
//Max texture size on iOS
int textureHeightLimit = 4096;
int textureWidthLimit = 4096;
//File.WriteAllBytes(Application.dataPath+"/../SavedScreenBefore.png",texture.EncodeToPNG());
if (texture.height > textureHeightLimit || texture.width > textureWidthLimit)
{
#if UNITY_IOS || UNITY_EDITOR_OSX
//TextureScale.Bilinear(texture, textureHeightLimit, textureWidthLimit);
Texture2D theOtherTexture = new Texture2D(texture.width/2, texture.height/2);
texture.ResizePro(texture.width/2, texture.height/2, out theOtherTexture);
texture = theOtherTexture;
#endif
}
//File.WriteAllBytes(Application.dataPath+"/../SavedScreenAfter.png",texture.EncodeToPNG());
// continue and use the texture
I also just tested, and found out that it works if I have Standalone set as build target, but it does not work when changing to iOS or Android as build target. I thought it might just be an editor thing, but it doesn’t work on devices as well. Does it only work on standalone? I do not see any platform limitations mentioned anywhere? Could also be some settings that I need?
Sure lets find out, I have sent a mail friday last week, lets take that there.
What you mean by ‘doesn’t work’ ? Some errors, warnings, exceptions, crashes ? More details will be helpful.
Also make sure target device supports RenderTextures - it is the only requirement.
The problem was that I did not get any errors, so was hard for me to find the problem. However, I did find that the problem is not ResizePro, but rather the limitation of the system that was the problem. I tried with 8k texture on iOS which does not support over 4k and this also limits the plugin.
However I did find a workaround, though it might not be pretty, it works (so far). I split the texture in 2 halfs, then resize each half and then combine them again. So having a texture of 8192 x 4096 I split in left and right each 4096 x 4096. Then resize left and right to 2048x2048. Then combine left and right to a single 4096 x 2048 image.