Skip to content

A simple unity asset to use less CPU/GPU power by dynamically limiting some unity features when it is not needed.

License

Notifications You must be signed in to change notification settings

HKhunayn/StateOptimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

1 Asset store covers

A simple unity asset to use less CPU/GPU power by dynamically limiting some unity features when it is not needed.

Screenshots

2 State 3 profiles
4 Dynamic render scale 5 Customize

How it works

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!

How to use

There are 2 ways:

1- Add the “StateOptimizer” prefab OR 2- Add “StateOptimizer” script to any
how_to_add_1 1 how_to_add_1 2 how_to_add_2 1 how_to_add_2 2

Profiles

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.

Custom profile

To create your own: add_profile

Right click at project window then

Create -> StateOptimizer -> StateProfile

CODE EXAMPLE

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");
  }
}

About

A simple unity asset to use less CPU/GPU power by dynamically limiting some unity features when it is not needed.

Resources

License

Stars

Watchers

Forks

Languages