• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by azmilarash96 · Jan 14, 2012 at 01:14 AM · fps

Changing quality setting bases on FPS ?

I want to make something automatically lowering its quality setting when they're FPS really low and increase quality setting when on a fast computer with higher FPS.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by syclamoth · Jan 14, 2012 at 01:35 AM

Well, the Quality Settings provide functionality for this! It's a really simple script, and I've already written it. Here you go!

 public class QualityAutomater : MonoBehaviour {

     // The min and max frameRate determines at what point it will switch up or down
     public double maxFrameRate;
     public double minFrameRate;

     // Sometimes, there are lag spikes that happen over one or two frames,
     // but are not necessarily related to the quality settings. The 
     // switchThreshold is the number of frames in a row that must be too
     // slow or fast before a switch occurs.
     public int switchThreshold;
     
     int upCounter;
     int downCounter;
     
     void Update () {
         if((1 / Time.smoothDeltaTime) > maxFrameRate)
         {
             upCounter++;
             if(upCounter > switchThreshold)
             {
                 QualitySettings.IncreaseLevel();
                 upCounter = -3;
             }
         } else {
             upCounter = 0;
         }
         //Debug.Log(upCounter);
         
         if((1 / Time.smoothDeltaTime) < minFrameRate)
         {
             downCounter++;
             if(downCounter > switchThreshold)
             {
                 QualitySettings.DecreaseLevel();
                 downCounter = -3;
             }
         } else {
             downCounter = 0;
         }
     }
 }
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image azmilarash96 · Jan 14, 2012 at 01:38 AM 0
Share

I don't know c# plz!! i'm using javascript! .__.

avatar image syclamoth · Jan 14, 2012 at 01:40 AM 3
Share

Well, that's too bad. You should learn to translate scripts- not only is it a useful skill to have, you'll learn more about how things fit together if you can swap and change between them.

$$anonymous$$oreover, this is a really simple translation. There's nothing in here that should give you any trouble whatsoever.

avatar image jahroy · Jan 14, 2012 at 03:21 AM 0
Share

Agreed. If you're unable to translate it into your language of preference, then you need to learn more about your language of preference.

In this case you probably only need to make a few very small changes.

avatar image syclamoth · Jan 14, 2012 at 08:23 AM 0
Share

I'll give you a hint- there are literally only 6 lines that need to change, and 5 of the changes are simply swapping around word order in the variable declarations.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I stop the fps controller jumping up slopes? 1 Answer

unlocking weapon (fps) 1 Answer

Items falling through floor? 2 Answers

Aiming down a gun 4 Answers

Character Respawn 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges