Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How to control the FPS for a single type of monos?

Discussion in 'Scripting' started by llxwd008, Mar 30, 2022.

  1. llxwd008

    llxwd008

    Joined:
    Aug 7, 2015
    Posts:
    49
    Hi,
    In my current game, I use lots of Spines, Update() and LateUpdate() of SkeletonAnimation consumes a lot of CPU time. I need to optimize this. Set UnityEngine.Application.targetFrameRate works, but it reduced the quality of the entire game. I need a way to only reduce the call of SkeletonAnimation Update() and LateUpdate(), for 30FPS, and the whole game for 60FPS. How to do this? Maybe FixedUpdate() can replace Update(), but how to deal with LateUpdate()?
     
  2. Karrzun

    Karrzun

    Joined:
    Oct 26, 2017
    Posts:
    123
    You could include a counter in the scripts you only want to run on some of the calls. In every Update() you increase the counter. When it's still below the needed threshhold, you return; if the counter is high enough, you run your code and reset the counter.

    Produces some extra overhead obviously, but maybe it's sufficient.