Astra Child

How to toggle a UIContainer (show or hide)

Estimated reading: 1 minute 0 views

Example

A UIContainer can be toggled between show and hide, from code, if you have a reference to it. Below is a code example on how to do it.

using Doozy.Runtime.UIManager.Containers;
using UnityEngine;
namespace Sandbox
{
    public class TestClass : MonoBehaviour
    {
        public UIContainer MyContainer;
        private void OnEnable()
        {
            // Animated Toggle
            // If Visible or IsShowing calls Hide.
            // If Hidden or IsHiding calls Show.
            MyContainer.Toggle();

            //or

            // Instant Toggle (no animation)
            // If Visible or IsShowing calls InstantHide.
            // If Hidden or IsHiding calls InstantShow.
            MyContainer.InstantToggle();
        }
    }
}Code language: PHP (php)
Share this Doc
CONTENTS
Scroll to Top