[ad_1]
The remark that you just discovered is correct. Unity was developed as a sport engine, designed to run video games which can be animating on-screen parts constantly. In that context, including logic to detect when one thing has modified and re-render solely on demand would truly enhance value, since you spend further CPU time doing this validation, when 90%+ of the time the reply is “sure, re-rendering is required”.
Unity is sort of versatile and does offer you management to render whenever you need, however since minimizing re-rendering just isn’t a core engine function, it could be your duty to trace when it is advisable to render and change rendering on & off.
Here’s a fast proof of idea script that demonstrates this:
public class RenderControl : MonoBehaviour
{
new public Camera digital camera;
float _renderFor = 0.1f;
int _continuousRenderRequests = 0;
public void RenderFor(float length = float.Epsilon) {
_renderFor = Mathf.Max(_renderFor, length);
}
public void StartRenderingContinuously() {
_continuousRenderRequests++;
}
public void StopRenderingContinuously() {
_continuousRenderRequests--;
}
void LateUpdate()
}
This disables the digital camera from rendering after it is had an opportunity to show the preliminary state of the scene. After this, rendering may be enabled for a set length or till stopped by calling one of many public strategies on this script.
While the digital camera is disabled, no new drawing instructions will likely be issued, and no matter you final drew to the display stays there. But sport logic (just like the replace loop that handles consumer enter and checks whether or not it is time to re-enable the digital camera) nonetheless ticks each body.
Note that within the Unity Editor view, you will see a warning overlaid on the sport window “Display 1: No cameras are rendering” to warn you to this, as a result of it is often an indication of an error if it occurs in a sport. But this warning just isn’t current within the constructed executable.
If you employ the UI system, you will need to set the canvas mode to “Screen Space – Camera” in order that the rendering of the UI is tied to the enabled state of the digital camera. With “Screen Space – Overlay”, the UI will nonetheless render constantly over the frozen 3D scene.
You might take this additional by computing the display rectangle bounding the modified space, then change the digital camera’s rework and viewport parameters to restrict rendering to simply that rectangle.
However, you will probably discover this extra laborious than it is value. You’ll save the work of rendering your chat window, which is probably going fairly light-weight, however nonetheless be paying the prices of updating all Unity’s different sport techniques – in addition to the obtain value of a full-featured sport engine. So the effectivity won’t match frameworks which can be purpose-built for making this sort of cell app.
Your use case might be higher served by utilizing a devoted framework designed for constructing mobile-conscious apps, after which operating your minigames both as WebGL apps in an internet view, or chaining management to a separate executable for these elements.
[ad_2]