Forum rules - please read before posting.

Menu Help (How to build it and see changes maybe at runtime?)

edited August 2014 in Engine development
Hello,

so I'm starting to build the Menu I need for the game, but how do I see the menu I'm building it and testing it while doing so, do I have to run the game each time I made changes to see them? Can I make changes on RunTime to see the changes?

What is the best way to make the menu, I'm struggling with figuring this part out now.

I'm looking into the Demo default Menu, so I have questions such as, how do I change the "background" on the buttons by setting a color? how flexible can the menu be?


On that note, I have a custom thing in my game that already exists in the top right corner, how can I make it so that when that thing is pressed the "Menu" opens, therefore I don't even need to include a Menu button, I could just try calling it from a script, or maybe even PlayMaker ?


Thanks

Comments

  • Aaahhh,

    I see, I had my "Game" and the Game Editor tabs on the same layout, so I did not realize you can see the menu while the game is NOT playing and make changes to it, beauty !

    Still need to know how to turn on the menu manually / so what I did to achieve that was: Created an FSM Event if the thing is touched on the screen, send message "Interact" to an empty object with an action list: menu turn on...

    beauty !
  • Hey Kici,

    There is a section on the website with tutorials on how to make menus, maybe some of that will help. You can click the checkbox test in game window at the top of the menu manager to see your menu as it will be displayed in the game. This way you won't have to run the game each time you make a change.

    Almost all elements can have a background texture, that is the only way currently to give them a different color.

    Good luck and if you have more questions just ask.
  • Thanks appreciated!

    Here's a few questions then,

    In the Demo Menu there is a Speech Volume, Music Volume and SFX Volume,

    how does it actually make changes to the volume when those sliders are moved? or is that not setup yet 

    Now the tricky part, I have 999 levels on my game, and I'd like the player to be able to select a "levels' menu option, which then will open up basically 999 buttons example: Level 1, Level 2, Level 3 and so on,

    but how do I make it for example, only level 1 and 2 is unlocked therefore Level 1 and 2 should have green text and Level 3 red or any other color, also on clicking how do I check if the level is unlocked and then load that level.

    Another critical part I need is when its "saving" the game, can it save as the current level name?

    thanks in advance 
  • 1) if you look in the demo menu at the speech slider for instance, down below is a dropdown box that's called Slider Affects: and there you can choose which options property it uses, or if it uses a script or something else.

    2) Woah ha 999 level buttons are probably a pain to set up, I'm trying to think if there is a better way to do that. Maybe by making an array with all the level names and having a Unity GUI display those. Here is a simple example:



    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;

    public class ArrayExample : MonoBehaviour {

    List<string> levels = new List<string>();
    int sizeOfList;
    int i;
    void Start () {
    levels.Add("one");
    levels.Add("two");
    levels.Add("three");
    }
    void Update () {
    sizeOfList = levels.Count;
    }
    void OnGUI() {
    GUI.Box(new Rect(10,10,100,100), "Level Select");

    for (i=0; i < sizeOfList; i++) {
    GUI.Button(new Rect(20, 40+(i*20), 80, 20), levels[i]);
    }
    }
    }


    3) You mean you want the current level name as the name of the savegame? I'm not sure how to do that, though there is a way to query the current level name with the string Application.LoadedLevelName;
  • #1, oh sweet ! thank you very much, AC is so powerful that it takes time to learn where everything is... what an amazing asset ! I will practice on creating my "Custom Script"  it says that "MenuSystem.OnElementClick" will be run when this element is clicked, so if I had a custom script in my game that has a lot of things in there basically the "brain" of it all, how do I get that event to go off in my own script? how do I read it, once that happens I wan't to take the "value" from the change (music) For example and do my own thing in my own script.

    #2 Thanks indeed its a lot and thanks for the script appreciate that, I thought about something like that and just recently thought of another cooler way to do so, basically a camera top down overseeing all levels and it says it in 3D text or whatever way whichever level they are on, and AC will simply allow the player to touch/click and select which level it wants to go to :)
    I think I like this approach better, its more work but worth it, the effects are beneficial.

    #3 thanks appreciated again, we'll see what I could do with that, but I think i will NOT allow for the player to save. Each level will begin over from scratch :)

    thanks so much!
  • I;ve tried:

    Using AC;

        public static void OnElementClick (Menu _menuMenuElement _elementint _slotint _buttonPressed)
        {

            //
     This function is called whenever a clickable element has a click type of "Custom Script".
            Debug.Log (_menu);
            Debug.Log (_element);
            Debug.Log (_slot);
            Debug.Log (_buttonPressed);
            
        }

    nothing happens 
  • @kici: The "OnElementClick" function is only called when an element's type is specifically set to Custom Script.  e.g. if you want to override a buttons behaviour, change the Button's Click Type to Custom Script.
  • Chris,

    that is what I have it set up as, "Custom Script" so I was expecting it to let me know that once a cycle or a button or any other as a "custom" was going to be called in my script, but so far no responses, I have a feeling this has something to do with other issues I'm experiencing on this post: http://www.adventurecreator.org/forum/discussion/comment/2171#Comment_2171

    Once I get home I will provide you those screenshots, and what I will spend time on is to create a brand new GUI from scratch to see if I will experience the same problems!

    thanks 
  • Alright here we go: (start from bottom) (issue from this post also: http://www.adventurecreator.org/forum/discussion/comment/2171#Comment_2171 )
    image
    image
    image

  • Sorry I had to post in multiple posts for some reason your forum was telling me 
    • Body is 11213 characters too long.
     characters too long when all i had was the picture and this text !

    So the "Options2" menu simply doesnt get called because it tells me it doesnt exist but as you can see on the pictures it does, then the other thing from the other post the Custom Script doesn't get called and I don't know why this is what's in my script:


    & and mentioned above I have that Using AC; and the public static void OnElementClick thing 
  • edited August 2014
    I can't recreate the "Options2" menu problem - I tried it myself and it works fine.  If you switch back to crossfading "Options", does the problem persist?  If all else fails, you can set the button's click type to Run ActionList, and use the Menu: Change state Action to manually turn off/on the menus.

    Your problem with the Custom Script is that you're editing the wrong script - "MenuSystem.OnElementClick" refers to the OnElementClick function inside the MenuSystem script.

    Open up the MenuSystem.cs script (it's in AdventureCreator -> Scripts -> Menu), and you'll see the OnElementClick function all there ready for you to edit.  This script is not changed by me, so it's safe to tell Unity to not update it when you upgrade your copy of AC.


  • Ahh, okay sweet !

    I will change that menu script, thanks a lot for the explanation, I will be working on a new menu from scratch this weekend and see if I will run into similar problems again such as the Options2 switch menu,

    thanks again for taking the time to solve these issues much appreciated.

  • edited August 2014
    Alright so I've been working with the new menu now and so far I have no issues with "switching" to another menu,

    I just have a question now, I'm using this simple debug method to figure out which cycle choice it has landed upon:

                Debug.Log ("The menu we are using is: " + _menu);
                Debug.Log ("The element name: " + _element);
                Debug.Log ("A slot ?: " + _slot);
                Debug.Log (" The button pressed: " + _buttonPressed);

     I thought this would present me something like my own cycle element name, the choice is got switched to... or whichever choice was pressed, but no matter how many times i cycle the choice by clicking on it the debug values stay the same never change (4 choices in total) so how would I figure out which choice it has landed upon? do I have to manually track this?

    maybe I'm just doing all of this wrong... because I tried a slider and even the slider always gives me the same values, I thought it would be a value from 0 to 1 on it.

    thanks 
  • Don't forget you can always link a Cycle's value to a Variable, but if you need to do it through script, just cast it:

    MenuCycle _cycle = (MenuCycle) _element;
    Debug.Log ("Chosen option is " + _cycle.selected);
    Debug.Log ("The current text is " + _cycle.optionsArray [_cycle.selected]);

  • Works like a charm!

    Thank you very much, I don't think I would've figured out the brains on this on my own,

    much appreciated.
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.