Forum rules - please read before posting.

When a menu stopped showing or start showin

Good morning community,

Quick question regarding menus:
a) is there a way to know (by scripting) when a menu has been called? The idea is to delay, for example the pause. If I know I pressed Escape and will pause and Pause Menu will show, I want to delay that call for a 1 second. The AL for when turning it on doesn't delay the menu. Particularly the manu is the Pause menu because the inventory just shuts it off immediately and can't run a nice animation (we are using Unity UI). It's just a smooth eye candy thing we are building.

b) similar to the before question, is there a way to know when a certain menu (a dialogue menu for player character) finished? I found a way to call it and use it midways but don't know when to know when it finished playing the line. All of this by scripting, since some stuff happens within the script, and the second reason is because the dialogue will change and don't want to call it within the action list for every single interaction.

Unity: 2020.3.27f1
AC: 1.74.5

Thanks a lot.

Comments

  • Let me rephrase A as I found part of the question:
    AC.KickStarter.playerMenus.ArePauseMenusOn()

    The problem is when I want to call any other menu by a string name. I found on the manual this: PlayerMenus.GetMenuWithName (string menuName) but doesn't work anymore (page 405 of v1.74.5). I don't need to delay the pause anymore, but know if I can call and delay menus by their string name (or at least call them). Let me give you an example: you click on the inventory menu, but until something happens, it doesn't turn on. Simple as that hahaha.

    As for B) the "finished" is "finished appearing on the screen". When the character stopped talking and the menu disappeared. That moment but generically for those menus.

  • edited March 2022

    PlayerMenus.GetMenuWithName is still valid - if you're getting an error, share the code and error and I can tell you the issue.

    If you want to insert a delay, however, it's better to manually turn the Menu on/off after a set time - rather than trying to "inject" a delay once the command to turn the menu on/off has been issued.

    The default Pause menu turns on instantly because its Appear type is set to On Input Key. If you want to alter this by using a delay first, you can switch to Manual and use Active Inputs to handle the transition in an ActionList.

    Active Inputs allow you to run ActionList when a given input has been pressed under certain conditions (e.g. during gameplay). Such an ActionList could include an Engine: Wait Action followed by a Menu: Change state Action to manually turn on your Menu.

    To run custom code as a menu turns on or off, you'll want to hook into AC's custom event system, which provides hooks for script injection when performing common tasks. A tutorial can be found here.

    The following exampe script, when placed in the scene, will fire Console logs when turning menus on and off, as well as when a speech line completes:

    using UnityEngine;
    using AC;
    
    public class CustomEventExamples : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnMenuTurnOn += OnMenuTurnOn;
            EventManager.OnMenuTurnOff += OnMenuTurnOff;
            EventManager.OnStopSpeech_Alt += OnStopSpeech;
        }
    
        private void OnDisable ()
        {
            EventManager.OnMenuTurnOn -= OnMenuTurnOn;
            EventManager.OnMenuTurnOff -= OnMenuTurnOff;
            EventManager.OnStopSpeech_Alt -= OnStopSpeech;
        }
    
        private void OnMenuTurnOn (AC.Menu menu, bool isInstant)
        {
            Debug.Log ("Menu " + menu.title + " turned on");
        }
    
        private void OnMenuTurnOff (AC.Menu menu, bool isInstant)
        {
            Debug.Log ("Menu " + menu.title + " turned off");
        }
    
        private void OnStopSpeech (Speech speech)
        {
            Debug.Log ("Character " + speech.GetSpeakingCharacter () + " stopped speaking");
        }
    
    }
    
  • WOOOW! It can be done then!! Awesome! You solved me a headache I was having and it was so simple.

    The code works great as well but the idea would be to do something only when certain menus appear. It's a mix between the PlayerMenus.GetMenuWithName and the OnMenuTurnOn and Off. Here's the screenshot.

    https://imgur.com/a/NgHiT6K

    The code is just testing stuff for now. Don't take it seriously please. I try things, see what works better and then do a new one with everything there.
    Thanks a lot

  • GetMenuWithName is a static function - you need to call it using the syntax described in the Manual, i.e.

    PlayerMenus.GetMenuWithName
    

    and not:

    KickStarter.playerMenus.GetMenuWithName
    
  • Silly me! Thanks a lot. Now it works :)

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.