Friday, September 2, 2022
HomeGame DevelopmentDesynchronizing MonoBehavior's "Replace" from the general app or UI Toolkit graphic output...

Desynchronizing MonoBehavior’s “Replace” from the general app or UI Toolkit graphic output rendering in Unity?


Is it attainable to desynchronize Software.targetFrameRate and Monobehavior’s Replace() from the graphics output rendering charge of a UI Doc, Panel, Sport Object holding it, or international Unity app?

For instance you have got a UI Doc on a recreation object. For instance you might be monitoring through customized code for when there may be really any change within the visible show that should happen.

For instance you ABSOLUTELY KNOW NOTHING ANYWHERE IS CHANGING within the show (both domestically on the UI Doc / Sport Object / Panel stage and even Globally on the software stage – no visible modifications in any respect). It’s a utterly static show at the moment.

Are you able to throttle down the rendering charge of the UI Toolkit / Sport Object / Panel / Challenge (even proper all the way down to zero) with out altering Software.targetFrameRate?

I can throttle Software.targetFrameRate down fairly low to round 15 fps when no visible modifications are occurring and bump it again up when extra is going on. However I can not throttle it down additional or I will not catch replace occasions effectively like new clicks/releases.

Then again, once I know there isn’t any visible change, I might throttle the RENDERING charge all the way down to zero hypothetically, since no new show rendering must happen.

Is there any method to do that? Or does it not make sense? I do not know the way UI Toolkit or Unity renders the ultimate app visible output.

Background Questions:

In the event you make a non-changing visible factor primarily based show after which go away it idling on a display at 120 fps:

  • What’s updating each body?
  • Is it re-calculating the flexing for the panel each body?
  • Is it re-drawing all the weather each body?
  • Is it continually checking all its fields each body fps for updates and solely re-drawing if one is discovered?

If such a code may be achieved to throttle rendering with out throttling the app’s international charge, a take a look at instance for instance could be say hypothetically:

VisualElement ve;
float frameRate = 120;

void Awake(){
   Software.targetFrameRate = frameRate;
   ve = new VisualElement();
   GetComponent<UIDocument>().rootVisualElement.Add(ve);
   StartCoroutine(updateTest());
}

IEnumerator updateTest(){

   //request a random change to look of visible factor on display at body charge
   ve.fashion.Shade =  new Shade(UnityEngine.Random.Vary(0,1), UnityEngine.Random.Vary(0,1), UnityEngine.Random.Vary(0,1));
   ve.fashion.width = ve.fashion.top =  UnityEngine.Random.Vary(2,500);

   Debug.Log(1/Time.deltaTime); // ought to proceed to output round frameRate

   yield return null;
}

void Replace(){
if (Enter.GetMouseButtonDown(0)){
   runFunctionToThrottleRendering(); //hypothetical operate that may then throttle the rendering pipeline
}

Is there any method to command within the panel or Unity background code that may permit me to activate/off updates or change the speed of updates to the Panel/UI Doc/rendering pipeline from the UI Toolkit so you’d not see the random modifications (even whereas the instructions proceed within the background on the charge of Replace())?

ie. So if I have been to set off this command, the updateTest() can maintain operating at 120 fps however it should not render any new modifications to the visible output and the show will stay static?

(Clearly I might throttle or activate/off the coroutine’s operate internally however this isn’t what I am asking – the code is only a hypothetical illustrative instance.)

There are lengthy intervals when somebody may be studying or an unchanging display in an app, and as I mentioned, I can throttle the Software.targetFrameRate fairly low in these instances. However ideally, I might even shut off any visible updates occurring to the display in any respect (or background checks contained in the UI Toolkit code) since I do know completely none must happen at these instances.

I’m even in strategies I must entry by Reflection. I do not thoughts. I might even be excited about strategies that may do it only for UI toolkit or a panel and even globally for all of Unity.

Any ideas are appreciated.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments