Topic: Is there a way to set the Preloading Time in code?

I noticed that when I test my game on low powered devices my game crashes. It seems that when I increase the Preloading Time in the Preload Option window, it helps.

I'd like to be able to able to change Preloading Time in the code after the game detects that the device has low Ram.

I can write code to detect low Ram, but I need help on adjusting Preloading Time.

Does UFE.config.preloadOptions  help?

Share

Thumbs up Thumbs down

Re: Is there a way to set the Preloading Time in code?

Try this

UFE.config._preloadingTime = 6;

Share

Thumbs up +1 Thumbs down

Re: Is there a way to set the Preloading Time in code?

Thank you very much! I'll try it!

Share

Thumbs up Thumbs down

4 (edited by apollo 2022-10-15 03:30:02)

Re: Is there a way to set the Preloading Time in code?

The code doesn't work.

UFE.config._preloadingTime = 6 caused an error

I want to preloadingTime to be 2 seconds.

Does UFE.config._preloadingTime need to be a float?

Share

Thumbs up Thumbs down

Re: Is there a way to set the Preloading Time in code?

Post the code your using and what the error says.

Share

Thumbs up Thumbs down

Re: Is there a way to set the Preloading Time in code?

It works fine now. I got the problem when I created a game object and created a new script. Now I added your code in UFE.cs

Now my code is something like this:

public int deviceMem;
public int deviceMemNeeded;
 
public Awake()
{
deviceMemNeeded = 2048;
deviceMem = SystemInfo.systemMemorySize;
deviceMem = SystemInfo.graphicsMemorySize;
}
 
public int returnMem(){
int mem;
mem =  SystemInfo.systemMemorySize;
mem =  SystemInfo.graphicsMemorySize;
return mem;
}
 
public void callMethod(){
 
if(returnMem() < deviceMemNeeded ){
UFE.config._preloadingTime = 3;
 
return;
 
}else{
UFE.config._preloadingTime = 1;
}
}

Share

Thumbs up +1 Thumbs down