public void Refresh() { if (!renderImage || !renderCamera) return; var rect = renderImage.rectTransform.rect; var w = (int)rect.width; var h = (int)rect.height; if (w == 0) w = Screen.width; if (h == 0) h = Screen.height; _renderTexture = RenderTexture.GetTemporary(w, h, 16, RenderTextureFormat.Default); // if (size == 0) // { // size = 0.5f * h / DesignHeight; // } // // renderCamera.orthographicSize = size; renderImage.color = Color.white; renderCamera.backgroundColor = default; renderCamera.targetTexture = _renderTexture; renderImage.texture = _renderTexture; renderCamera.enabled = true; }
将摄像机找到的taggetTexture取出来,设置到renderImg上即可,这样就可以方便解决2DUI和3D物体的渲染顺序问题 标签:renderImage,renderTexture,RawImg,Unity,var,renderCamera,照再,rect,size From: https://www.cnblogs.com/XieBoss-blogs1/p/18460005