Hi, I’ve been working on the xbox suspend issue. It requires the game to respond to suspend within 1 second. And now there is some heavy operations in some update() calls in some manager class, which is not easy to break down to coroutines.
I have a flag called ‘needSuspend’, and it’s value will be true when the game got the event to suspend. I need to call the XboxOnePLM.AmReadyToSuspendNow() to finish the suspend operation. In my test, it will effect after all scripts’ update(). I put the ‘if (needSuspend)’ check between the heavy operations codes. When the condition is true, is there any way to stop the current update() function of Monobehaviour immediately and abort all the code below to execute.
I have an idea to approach this effect, but it’s not good to cause an error…
if (needSuspend)
{
XboxOnePLM.AmReadyToSuspendNow();
int zero = 0;
int forceBreakOut = 10 / zero;
}
Throwing an exception is a very poor way to stop a function from executing. Just use a return statement: if (needSuspend) { XboxOnePLM.AmReadyToSuspendNow(); return; }
– bobisgod234Ahh, okay. Umm... in that case, I'm afraid I can't offer more specific personal advice at the moment, then. Until I finish my current project, I'm still on Unity 2018, before URP and HDRP variants were implemented. At any rate, when an object does turn pink like that, it's the result of a shader either being broken or effectively broken (I assume URP limits functionality in shaders in a manner that the "Standard" shader no longer functions under it as-is).
– Eno-Khaon