i am trying to merge two textures into one in unity
the first texture is from a webcamTexture
the second is from a sprite using : gameobject.getComponent().sprite.texture as Texture2D
I’m having problem in writing the function this is what i did so far :
public static Texture2D CombineTextures(GameObject obj, Texture2D background, Texture2D TodrawLogo)
{
Vector3 v = obj.transform.position;// obj is TodrawLogo gameobject
int width = TodrawLogo.width;
int height = TodrawLogo.height;
for (int x =(int)v.x; x < width; x++){
background.SetPixel(x,(int)v.y,TodrawLogo.GetPixel(x,(int)v.y));
}
background.Apply();
return background;
}
this what i am trying to do :
WebcamTexture
the result Texture should be like this
The webcamTexture is a 3d Plane
and the logo is a single sprite
but sadly my function doesn’t work
does anyone know how to fix this
I know that i should find the exact coordinate of the todraw image
and set the pixels but i can’t figure out how
Much appreciation