Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
738 stars 185 forks source link

feat: Added support for horizontal flip sourceTexture #971

Closed MaximKurbanov closed 9 months ago

MaximKurbanov commented 9 months ago

When I added support for "VUZIX M400 SMART GLASSES" to the project, the picture from the glasses was diagonally flipped. So I added the horizontal and diagonal flip.

videoStreamTrack = new VideoStreamTrack(webCamTexture, false, true); //Flip horizontaly
sourceRawImage.uvRect = new Rect(1, 1, -1, -1); //Flip diagonally for display
karasusan commented 9 months ago

@MaximKurbanov

I couldn't imagine the usage what you want when I designed this constructor. This PR makes sense to me but I want to create a new constructor instead of this.

public VideoStreamTrack(Texture texture, Vector2 scale, Vector2 offset) 
MaximKurbanov commented 9 months ago

Old:

videoStreamTrack = new VideoStreamTrack(webCamTexture, false, true); //Flip horizontaly
sourceRawImage.uvRect = new Rect(1, 1, -1, -1); //Flip diagonally for display

Now:

videoStreamTrack = new VideoStreamTrack(webCamTexture, CopyTextureHelper.DiagonalFlipCopy);
sourceImage.uvRect = new Rect(1, 1, -1, -1); //Flip diagonally for display
karasusan commented 9 months ago

@MaximKurbanov It looks good to me.