Forum rules - please read before posting.

Trouble with If MenuButton.ProcessClick then statements

I have special scripts on each unit. Anytime a Unit is selected, in my case MarkAsSelected, then a special KSpellcard menu shows up.

This menu uses AC, but has scripts that read from a Scriptable Object to change the content on the menu. The menus are unique to each character based on which one is selected. I am trying to get the three buttons on my general menu interface that stays up permanently, called InGameBattleUI, to trigger a casting animation. 
 
   public override void MarkAsSelected() //Unit is selected
    {

        Menu KSpellcard = PlayerMenus.GetMenuWithName("KSpellcard");//Gathering KSpellcard menu and texts/images are changing based on which character is selected
        KSpellcard.TurnOn();//Menu successfully turns on/displays

        
        MenuElement C1 = PlayerMenus.GetElementWithName("BattleInGameUI", "C1"); //Getting the C1 button in the BattleInGameUI menu and calling it C1
        Menu BattleInGameUI = PlayerMenus.GetMenuWithName("BattleInGameUI");//Getting BattleInGameUI Menu
        MenuButton B1 = (MenuButton)C1;//Getting C1 button and calling it B1
        B1.ProcessClick(BattleInGameUI, 19, MouseState.DoubleClick);// here's where I get lost

            
        
    }

It won't compile at all but here is where I think my disconnect is.

I found this online:
override void AC.MenuButton.ProcessClick(AC.Menu _menu,
int _slot,
MouseState _mouseState 
)
virtual

Performs what should happen when the element is clicked on.

Parameters
_menuThe element's parent Menu
_slotIgnored by this subclass
_mouseStateThe state of the mouse button

Reimplemented from AC.MenuElement.


It says it Performs what should happen when element is clicked on but I dont understand how to use it. 

I want something along the lines of 

if (B1.ProcessClick(BattleInGameUI, 19, MouseState.DoubleClick) //if B1 button is pressed then..
{
    animator.SetTrigger("Cast1")//trigger the cast 1 animation
    //dodamage or ability here etc
}
if (B2.ProcessClick(BattleInGameUI, 20, MouseState.DoubleClick) //if B2 button is pressed then..
{
    animator.SetTrigger("Cast2")//trigger the cast 1 animation
    //dodamage or ability here etc
}
if (B3.ProcessClick(BattleInGameUI, 21, MouseState.DoubleClick) //if B3 button is pressed then..
{
    animator.SetTrigger("Cast3")//trigger the cast 3 animation
    //dodamage or ability here etc
}

Any pointers would be greatly appreciated, I feel like it comes down to me not using the .ProcessClick correctly.

Comments

  • Welcome to the community, @Khjunxx.  What are your AC/Unity version numbers?

    The code snippet you've posted doesn't look like it should prevent compilation - what exactly is the compilation error?

    ProcessClick does indeed handle the behaviour of an element once clicked, but there's a few other additional processes in place that get skipped if you call it directly.  As per the Manual's "Menu scripting" chapter, the recommended way to simulate an element click is:


    However, from your description of what it is you want, I'm not sure that simulating the click is what you want.  From the sounds of it, you just want to perform additional effects / run additional code once the button is clicked naturally by the player.

    To achieve that, you can hook into the OnMenuElementClick custom event - which allow you to run additional code when the player has clicked an element.

    Example:

  • Apologize for the late reply. The example you provided in the link and with the custom events I was able to accomplish what I wanted. Thank you!!! Seeing the example code helped explain it all to me
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.