Skip to main content

MakeChannelPackedTexture

TextureUtilities.ChannelPackColors()

public static Texture2D MakeChannelPackedTexture(
Texture2D textureRGB,
Texture2D textureA,
TextureUtilities.PackingResizeIfNotSameResolution rescaleType = TextureUtilities.PackingResizeIfNotSameResolution.ScaleToFirstTexture
)
ParameterTypeDefaultDescription
textureRGBTexture2D RGB Texture containing 3 channels (Red, Green and Blue). Alpha is on the 2nd Texture parameter
textureATexture2DAlpha values
rescaleTypeTextureUtilities.PackingResizeIfNotSameResolutionTextureUtilities.PackingResizeIfNotSameResolution.ScaleToFirstTexture What kind of rescale to apply in case one or more textures have different resolutions

Returns: The Channel Packed Texture

Channel Pack 4 channels taken from up to 4 different textures (1 channel each).


public static Texture2D MakeChannelPackedTexture(
Texture2D textureR = null,
Texture2D textureG = null,
Texture2D textureB = null,
Texture2D textureA = null,
int defaultResXIfAllEmpty = 2048,
int defaultResYIfAllEmpty = 2048,
TextureUtilities.PackingResizeIfNotSameResolution rescaleType = TextureUtilities.PackingResizeIfNotSameResolution.ScaleToFirstTexture,
bool isTransparentIfNoTextureR = false,
bool isTransparentIfNoTextureG = false,
bool isTransparentIfNoTextureB = false,
bool isTransparentIfNoTextureA = false
)
ParameterTypeDefaultDescription
textureRTexture2DnullRed Texture
textureGTexture2DnullGreen Texture
textureBTexture2DnullBlue Texture
textureATexture2DnullAlpha Texture
defaultResXIfAllEmptyint2048If no Texture is set at all, the default width of the texture
defaultResYIfAllEmptyint2048If no Texture is set at all, the default height of the texture
rescaleTypeTextureUtilities.PackingResizeIfNotSameResolutionTextureUtilities.PackingResizeIfNotSameResolution.ScaleToFirstTextureWhat kind of rescale to apply in case one or more textures have different resolutions
isTransparentIfNoTextureRboolfalseIf the Red Texture is not set, should that texture be fully Clear or fully White?
isTransparentIfNoTextureGboolfalseIf the Green Texture is not set, should that texture be fully Clear or fully White?
isTransparentIfNoTextureBboolfalseIf the Blue Texture is not set, should that texture be fully Clear or fully White?
isTransparentIfNoTextureAboolfalseIf the Alpha Texture is not set, should that texture be fully Clear or fully White?

Returns: The Channel Packed Texture

Channel Pack 4 channels taken from up to 4 different textures (1 channel each).


Example Usage

using UnityEngine;
using MikeDaBird.EZRecolor.Utilities;

class RotateTexture : MonoBehavior{
public Texture2D textureColor;
public Texture2D textureGrayscale;

// Rotate a texture by a rotation, both set within the Component
public Texture2D PackTextures(){
texture = TextureUtilities.MakeChannelPackedTexture(textureColor, textureGrayscale);
return texture;
}
}