Forum rules - please read before posting.

check container is full?

Hi Chris, is there any way to check if the container is full or not? Thanks.

Comments

  • Not built-in, but it's a good suggestion.

    Here's a custom Action (ActionContainerCheckFull) that should do it:

    using UnityEngine;
    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionContainerCheckFull : ActionCheck
        {
    
            public Container container;
            public int containerID;
            private Container runtimeContainer;
            public bool useActive;
    
            public override ActionCategory Category { get { return ActionCategory.Container; }}
            public override string Title { get { return "Is full"; }}
    
            public override void AssignValues (List<ActionParameter> parameters)
            {
                if (useActive)
                {
                    runtimeContainer = KickStarter.playerInput.activeContainer;
                }
                else
                {
                    runtimeContainer = AssignFile <Container> (constantID, container);
                }
            }
    
    
            public override bool CheckCondition ()
            {
                return runtimeContainer && runtimeContainer.IsFull;
            }
    
    
            #if UNITY_EDITOR
    
            public override void ShowGUI ()
            {
                useActive = EditorGUILayout.Toggle ("Check active container?", useActive);
                if (!useActive)
                {
                    ComponentField ("Container:", ref container, ref constantID);
                }
            }
    
            #endif
    
        }
    
    }
    
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.