A simple unity asset to use less CPU/GPU power by dynamically limiting some unity features when it is not needed.
The idea is simple, The State Profile has 3 modes: Active, Idle, and Sleep. Each mode has 6 settings: FPS, buffer manager, physics auto simulate, physics iterations, render scale, and mode event.
Active mode: called when the player is active (detected by keyboard/mouse input)
Idle mode: called when the player is not giving any input for 10 sec (can be changed)
Sleep mode: called when the player is outside/minimized the game/application!
There are 2 ways:
1- Add the “StateOptimizer” prefab OR | 2- Add “StateOptimizer” script to any |
---|---|
There are 3 predefined profiles: Application Profile, Default Profile, and No Idle Profile
Default Profile: Recommended for most games.
Application Profile: Recommended for Application like games.
No Idle Profile: with no idle state.
Right click at project window then
While coding isn't required, this serves as an illustrative example.
using UnityEngine;
using SOptimizer;
public class StateOptimizerExample : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
// Get The current mode
Debug.Log("current mode is " + StateOptimizer.GetMode());
// Set The mode for the optimizer
StateOptimizer.SetMode(StateMode.Active);
// call a function when mode state change
StateOptimizer.ModeEvent(StateMode.Idle).AddListener(IdleFunction);
}
void IdleFunction()
{
Debug.Log("its idle now");
}
}