Forum rules - please read before posting.

vertical layout not updating when inventory interactions are not awailable

I'm trying to create an interaction menu that has the actions on top and inventory interaction items on bottom in a row.
Here's an image: https://imgur.com/a/yhgjbqb

Everything works fine otherwise - and the vertical layout group updates item squares when tried manually - so that enabled items are centered, but when AC turns off the items this doesn't happen. It appears as there would always be three items in the group.

Should I update this after some event or somethig?

Comments

  • In your InventoryBox element, set the When slot is empty property to Disable Object. That will disable the Button GameObjects linked to it in the UI prefab.

    If this is so, but the layout appears wrong - what is the state of the hierarchy vs what it needs to be to appear correct?

  • The problem here is that I'm using masks above the item images. All the items have cursor images that have the masking already in them so I could use them, but that would require some extra coding I suppose.

  • Do you have any ideas how to make this happen?

  • edited May 2022

    You'll need to share more detail about the situation - the above is not clear enough for me to offer any suggestion.

  • I added couple of pics in here:
    https://imgur.com/a/yhgjbqb

    So, the three inventory interaction items are shown in a row and they are provided by AC IventoryBox. But normal inventory shows Main graphic per item, but I would like to either show Cursor or to have a mask that rounds the image a bit and then adds a border on top of it. Latter approach would be preferable.

    Problem here is that AC doesn't disable the masks of the item buttons. One can see it in the bottom two images - all the masks are enabled, although only one item is.

  • You wouldn't be able to disable the Mask object itself, because that'll cause issues with the Image child.

    A brute-force approach would be to attach a script that updates its GameObject based on the enabled state of the Image child - this could either be by disabling a component on the object, or by attaching a Canvas Group and controlling its alpha value:

    using UnityEngine;
    using AC;
    
    public class AutoHideMask : MonoBehaviour
    {
    
        public GameObject imageObject;
        private CanvasGroup canvasGroup;
    
        void OnEnable ()
        {
            canvasGroup = GetComponent<CanvasGroup> ();
        }
    
        void Update ()
        {
            canvasGroup.alpha = imageObject.activeSelf ? 1f : 0f;
        }
    
    }
    
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.