Forum rules - please read before posting.

Menu Elements: Sliders

edited September 2014 in Technical Q&A
Hello.

Currently i am making a menu and require the menu to reflect numerical values along with the slider, such as if i am turning the volume down in the options menu i need that to show a numerical percent value for the current level so that people dont have to guess at the level to chick the sliders are at.

The same could go for if i am editing graphics options, and i only want 25, 50, 75, and 100%, so 4 in total, how would i go about making a slider that reflects the current state?

Please let me know if i need to clarify

Comments

  • I can add the ability for Sliders to only take certain values, but you could always places this in a Cycle instead: then you could have e.g. Graphics quality: Low, Medium, High, Very High.

    As for adding a numbe beside it, just create a separate label.  If your Slider's Slider affects property is set to Float Variable, then you can simply add that Variable's token text as the label's text.

    The token text is a token that simply displays the Variable's value, and can be found within the properties of any Variable declared in the Variables Manager.  It takes the form [var:ID], where ID is the unique identifier number.
  • So how would this be set up if i were changing the Music, SFX, etc. I made a global variable, named it music, set it as a float, and attached that to the Music slider. Also made a Mucis label and attached that variable to the label type and it doest control the music, and it only displays in 1 - 0.0 not 100 - 0.

    Also i was loooking at the documentation for help with the Cycle method so that i can change the praphics options and for some reason all i come across is MenuSystem.cs script.

    So i assume you would need to program that to affect the graphic quality in unity and reflect that in the menu cycle button?

    Idk this is all very confusing as im not a programmer, just an artist that uses playmaker.
  • The changing of Music, SFX and Speech volumes are all built-into AC's Slider element.  Look at the default Demo_MenuManager asset: The Options menu has sliders that affect all three without the need for Global Variables.  These values are all decimals, not percentages, so their values can only be 0 - 1.

    If you're using PlayMaker, know that you can also link AC's Global Variables to PlayMaker Global Variables.  So if you update an AC variable using a Slider, it's assocated PlayMaker variable will also update.  Just go to the Variable's properties and Link to to Playmaker Global Variable.

  • I think you are confused. I know that there are presets already in place for those. I need to know HOW it is done as it is not explained in the documentation as far as i know, so i cannot emulate it for other things i need done.

    As for Playmaker, i dont understand why i would need to use that to control my graphics/ controls/ audio/ gameplay options, id rather do all that in AC.

    I just need to be pointed into the direction so that i can get things linked to my options menu so it can be functional.
  • The volume levels are stored in the PlayerPrefs by way of the Options script.  Whenever a Slider that affects one is moved, it'll re-save the PlayerPrefs with the new value.  You can store a Global Variable's value in the PlayerPrefs in the same way by setting Link to to Options Data.  This will ensure that changes made to that Variable (e.g. due to a Slider change) are independent of save game files.  When you want to read the Variable's value, use the following code:

    float graphicQuality = GlobalVariables.GetFloatValue (ID);

    Where ID is the ID number of the Variable in question.  I appreciate you're not a coder, but this is as simple as it can be made.
  • edited September 2014
    Ok variables are foreign to me so i appreciate your help with understanding.

    So what am i doing with "float graphicQuality = GlobalVariables.GetFloatValue (ID);"
    Where do i put that? Do i make a script and link it in the menu element?

    See when you just put a line of code i dont know where it goes or what im doing with it so i just end up sitting here breaking things trying to understand what you are "hinting" at.

    Your tutorials are great, and im not asking for one on how to script cause i understand it cant be covered like that, but the docs show me nothing on how to do these things. So then i come here and have to wait 2 days in order to get help mostly every time i post, and anyone else.

    I mean i hate to be rude but i have a fully functional game, i understand all of your mechanics and i love the kit, but i need steps to follow when it comes to these kinds of things.

    Thank you for the support.

  • It's impossible for anyone else to know what you don't know.

    Clearly you are not a coder. Neither am I since I stopped using BASIC.

    If you don't understand a single thing about how coding/scripting works then you are not going to be able to carry out the fine detail customisation that you want to do.

    You say you are not asking for a tutorial on how to script but actually your request then follows that you are.  You appear not to realise that you are.

    If you want a very basic understanding of variables and how they apply in Unity in general see here:


    I think if you are expecting a forum request to deliver custom code for you to 'cut and paste' for any given problem then you need to moderate your expectations a bit or hire a C# coder. 
  • "It's impossible for anyone else to know what you don't know." Can i ask why you opened this thread, if not only to point out obvious statements such as this.

    In response to your reply, i have watched videos on how to code and still do, but it is a hard concept to grasp as i dont know the terminology that i need for certain cases.

    I never once asked for a cut and paste i simply asked to be shown what needs to be done specifically, not vaguely.

    Your condescending remarks and lackluster reading should not permit you to reply to a thread in which you are not being constructive.

    Have a good one.
  • edited September 2014
    If you think that I was being unhelpful or unconstructive then I'll refrain from offering advice. My point about it being impossible to know what you don't know was intended to say " I don't know if what I am about to say is something you already know".

    You are being rude yes. 
  • edited September 2014
    So you still insist on posting more useless comments, yet again.
  • edited September 2014
    It's true that a knowledge of coding is still necessary.  I didn't be more specific about what to do with the line of code, because it's up to you!  However, let's assume you want changes to take effect once you've clicked an "Apply" button in the same menu as your slider, as that's a common scenario.

    Section 10.3 of the Manual covers the concept of "Menu scripting", which, again, assumes a knowledge of scripting.  But we can at least get you started: create a new Button and set it's Click type to Custom Script.  Then, open up the MenuSystem.cs script and prepare to make changes.  (Be mindful that, when upgrading AC, you'll need to make a backup of this file, and replace it afterwards).

    Look for the function OnElementClick.  This function will be run when your new Button is clicked on.  However, it'll also be run when any Button set to Custom Script is clicked on, so first you need to check that we've clicked the correct button.  Assuming our new Button is called "ApplyButton", enter in this code:

    if (_element.title == "ApplyButton")
    {
      float graphicQuality = GlobalVariables.GetFloatValue (ID);


      if (graphicQuality < 0.5f)
      {
        // Low quality
      }
      else
      {
        // High quality
      }
    }

    Again, where ID is your "Graphic Option" Variable's ID number.  The comment statements would obviously need to be replaced with code that actually makes graphical changes, but that'd be the point where AC "ends" and more general Unity code begins, and I'd suggest posting on the official Unity forums for tips on adjusting the graphical quality through script.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.