MakeChannelPackedTexture
TextureUtilities.ChannelPackColors()
public static Texture2D MakeChannelPackedTexture(
Texture2D textureRGB,
Texture2D textureA,
TextureUtilities.PackingResizeIfNotSameResolution rescaleType = TextureUtilities.PackingResizeIfNotSameResolution.ScaleToFirstTexture
)
| Parameter | Type | Default | Description |
|---|---|---|---|
| textureRGB | Texture2D | RGB Texture containing 3 channels (Red, Green and Blue). Alpha is on the 2nd Texture parameter | |
| textureA | Texture2D | Alpha values | |
| rescaleType | TextureUtilities.PackingResizeIfNotSameResolution | TextureUtilities.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
)
| Parameter | Type | Default | Description |
|---|---|---|---|
| textureR | Texture2D | null | Red Texture |
| textureG | Texture2D | null | Green Texture |
| textureB | Texture2D | null | Blue Texture |
| textureA | Texture2D | null | Alpha Texture |
| defaultResXIfAllEmpty | int | 2048 | If no Texture is set at all, the default width of the texture |
| defaultResYIfAllEmpty | int | 2048 | If no Texture is set at all, the default height of the texture |
| rescaleType | TextureUtilities.PackingResizeIfNotSameResolution | TextureUtilities.PackingResizeIfNotSameResolution.ScaleToFirstTexture | What kind of rescale to apply in case one or more textures have different resolutions |
| isTransparentIfNoTextureR | bool | false | If the Red Texture is not set, should that texture be fully Clear or fully White? |
| isTransparentIfNoTextureG | bool | false | If the Green Texture is not set, should that texture be fully Clear or fully White? |
| isTransparentIfNoTextureB | bool | false | If the Blue Texture is not set, should that texture be fully Clear or fully White? |
| isTransparentIfNoTextureA | bool | false | If 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;
}
}