Forum rules - please read before posting.

UI Immune to Action Lists?

I have a scene where I use an Action List to toggle when certain Game Objects are visible in my scene. This mostly works, however, I have a WorldSpace UI object (In this case the screen of a laptop) that I also don't want visible at the start of my scene. Using my Action List to turn it off like all the other Game Objects (Object > Visbility >Invisible >Affect Children) doesn't seem to work. It just sits there indefinitely.

Do Action List commands not work on UI? Is there a command that does?


  • edited August 2020

    The Object: Visibility Action is intended for Renderer components - not Canvases.

    Though, I can look into extending it to enable/disable to do this.

    In the meantime, there's two ways you can control the enabled state of a world-space UI Canvas:

    1) Hook it up to the Menu Manager as a Menu with its Source set to Unity Ui In Scene, so that you can use the Menu: Change state Action to control it.

    2) Attach a simple script to it so that you can use the Object: Send message Action to pass Turn On and Turn Off messages to it:

    using UnityEngine;
    public class SetCanvasState : MonoBehaviour
        public void TurnOn ()
            GetComponent <Canvas>().enabled = true;
        public void TurnOff ()
            GetComponent <Canvas>().enabled = false;
  • edited August 2020

    I just tried this and the issue is that you have to put this on the overall canvas container first, which, while not an issue now would be a problem later. I didn't try the first method since, due to weird issues I've had for another reason, I'm avoiding touching the menus for now unless necessary.

    However, this does bring me a related question: Can ActionLists directly interact with Scripts?

    For example, how do they connect with a GameObject Script? Can they toggle bools, ints, or triggers for example (outside of animations)? Can they send messages to certain script processes? I did try to do this with the method you described, as it did work with that specific Turn On/Off call baked into AC, but it didn't seem to work for anything else even if I call custom methods similarly or try toggling variables.

    For certain parts of my game, I'd like to have certain components trigger in other scripts, but I'm a bit confused as to how since much of AC seems Object Based.

    As an example, I have several UI systems, similar but different to the original UI I was asking about, that are only supposed to appear at certain points in the game. However, in one case I have a custom UI minigame that actually has a bool which controls when it becomes active. Is there a way I could tell my Action List to turn on that Bool in that UI object? Is there a way I can even tell my confirm button to trigger a new Action List or maybe pause an Action List when my UI is triggered until it receives a message/event from that confirm button?

  • edited August 2020

    The Object: Send message Action uses Unity's SendMessage system to trigger functions by name. It's mainly a convenience tool to allow a quick-firing of custom script functions, or AC components that have TurnOn / TurnOff functions written into them.

    For more elaborate integration, you can write custom Actions, which can be set up to do whatever you like - e.g. update certain variables within a custom component type.

    Though, if you're mainly looking to just update variables, you may want to look into instead attaching a Variables component to the separate GameObject. You can then use AC's standard Variable: Check and Variable: Set Actions to read/write any e.g. Bool variables you define on it, and you can also do the same from a separate script - either by reading their values directly, or by creating a link to them. See the Manual's "Variable linking" chapter for more on this topic.

    To run an ActionList manually through code, you just need to call its Interact function.

    The other thing to be aware of is that ActionLists themselves are also largely optional. Actions are mainly used to call functions within other AC components, and it is possible to write equivalent code. Though, with Actions you have the ability to "wait" for operations to complete before calling the next one - so in code you'd have to rely on coroutines. A tutorial on this topic can be found here.

  • I too am looking for a Canvas Visibility function for AC, was one ever implemented?

    Object > Canvas Visibility >Invisible >Affect Children

    Although I could also hook up AC to Canvas through menus, I would need to create many, many menus.

  • I'd say the best approach would be to rely on Animation to control the visibility of different sections of your menu.

    An Animator attached to the Canvas root could have a layer with such animations, with transitions to each based on a parameter, and then the Object: Animate Action used to control that parameter's value.

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.