Forum rules - please read before posting.

more than one Custom Script in MenuSystem

edited June 2014 in Technical Q&A
How can I create more than one custom script on MenuSytem.cs to call it on a button menu?


  • Do you mean that you want to have several buttons with custom scripts? If the button's type is "custom script", your code has to be in the OnElementClick function. But you can separate logic for several menu elements like this:

    public static void OnElementClick (Menu _menu, MenuElement _element, int _slot, int _buttonPressed)
    if (_element.title.Equals("ElementName1")) {
    Debug.Log ("Logic for ElementName1 here");
    } else if (_element.title.Equals("ElementName2")) {
    Debug.Log ("Logic for ElementName2 here");
  • Thanks Guran,
    it just works perfectly.

    I did this:

    public static void OnElementClick (Menu _menuMenuElement _elementint _slotint _buttonPressed)
     This function is called whenever a clickable element has a click type of "Custom Script".
                if (_element.title.Equals("Accedi")) {
                    FacebookMainWrapper.instance.initFacebook ();
                    FacebookMainWrapper.instanceCallFBLogin ();
                } else if (_element.title.Equals("Condividi")) {
                    FacebookMainWrapper.instanceTakeScreenshotWithMessage("Una brutta sorpresa in spiaggia - Scarica l'App htt://");        


    Do you think I can insert a function to Turn Off a certain menu?
    Because I can't find the code.
  • edited June 2014
    I would do it like this:

    Menu myMenu = PlayerMenus.GetMenuWithName("My Menu");

    If it's the menu that the button element is on you can just use _menu.TurnOff(false). 

    If you want the menu to fade you should send in true instead of false.
    NOTE: This will only work if the menu's Appear Type is set to Manual and OnInputKey.
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.