I'm trying to learn the UI part of Unity and the use case I want to achieve is to setup a windowed user interface which looks like Unity or Blender's one (simplified): with one or more 3D views in it + some canvas with 2D GUI.
What I've tried so far is to make it using a canvas with an image in it, which itself has a raw image component. The raw image has a render texture as 'texture'.
But doing that, the texture is stretched when the rect transform of the image is changing. So I don't know how to handle that if the size and position of the view is changing (I've seen the minimap tutorials but here the size is static).
Another way could be to limit one or several main cameras 'viewport rect'.
But so far I don't know which is the best approach in order to set it up efficiently and have no difficulties to handle camera's movements, centered in the view, etc.
What is the good way to do that?
Edit: following the advice of DMGregory, it works perfectly
The idea is to update the camera's rect with something like this:
var anchorMin = parenRectTransform.anchorMin; var anchorMax = parenRectTransform.anchorMax; Camera.rect = new Rect( anchorMin, anchorMax - anchorMin );
Here parentRectTransform is the rect transform of the parent of my 3D view, so that the anchor's position and size are relative to the global space (screen).
The other approach using a render texture is not possible as its size cannot be changed at run time (the only possibility was to recreate one each time).