UIDrawer

Code examples to open, close, toggle and perform various interactions with the UIDrawer

Close Drawer

Close a target UIDrawer

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.Close();
    }
}

Close Drawer – instantly (without animation)

Close a target UIDrawer instantly without an animation.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.Close(true);
    }
}

Open Drawer

Open a target UIDrawer

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.Open();
    }
}

Open Drawer – instantly (without animation)

Open a target UIDrawer instantly without an animation.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.Open(true);
    }
}

Toggle Drawer

Toggle a target UIDrawer’s opened/closed state. If it’s open it will close and vice versa.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.Toggle();
    }
}

Toggle Drawer – instantly (without animation)

Toggle a target UIDrawer’s opened/closed state instantly without an animation. If it’s open it will close and vice versa.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.Toggle(true);
    }
}

Disable Gesture Detection

Disable gesture detection for a target UIDrawer.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.DisableGestureDetection();
    }
}

Enable Gesture Detection

Enable gesture detection for a target UIDrawer.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.EnableGestureDetection();
    }
}

Toggle Gesture Detection

Toggle gesture detection for a target UIDrawer.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.ToggleGestureDetection();
    }
}

Update Arrow Container

Update the UIDrawerArrow Arrow by copying the UIDrawerContainer Container RectTransform properties to it

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    
    private void Start()
    {
        MyDrawer.UpdateArrowContainer();
    }
}

Update Container

Update the UIDrawerContainer Container to the set settings

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;

    private void Start()
    {
        MyDrawer.UpdateContainer(); 
    }
}

Update Container Size

Update the size of the UIDrawerContainer Container to the current settings

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;

    private void Start()
    {
        MyDrawer.UpdateContainerSize();
    }
}

Update Container Size – Fixed Size

Update the size of the UIDrawerContainer Container to a set FixedSize, with the given percentageOfScreen and minimumSize

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    public float DrawerFixedSize = 200f;

    private void Start()
    {
        MyDrawer.UpdateContainerSize(DrawerFixedSize);
    }
}

Update Container Size – Percentage of Screen

Update the size of the UIDrawerContainer Container to a set PercentageOfScreen, with the given percentageOfScreen and minimumSize

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    public float PercentageOfScreen = 0.5f; // 50%
    public float MinimumSize = 200f;

    private void Start()
    {
        MyDrawer.UpdateContainerSize(PercentageOfScreen, MinimumSize);
    }
}

Update Drawer Close Direction

Update a target UIDrawer’s close direction. The close direction is the direction the drawer will slide to in order to close.

using Doozy.Engine.Touchy;
using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIDrawer MyDrawer;
    public SimpleSwipe HideDirection = SimpleSwipe.Right;

    private void Start()
    {
        MyDrawer.UpdateDrawerCloseDirection(HideDirection);
    }
}

GLOBAL – Close Drawer

Close the UIDrawer, with the given drawer name, that exists in the UIDrawer Database

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public string DrawerName = "Left";

    private void Start()
    {
        UIDrawer.Close(DrawerName);
    }
}

GLOBAL – Open Drawer

Open the UIDrawer, with the given drawer name, that exists in the UIDrawer Database

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public string DrawerName = "Left";

    private void Start()
    {
        UIDrawer.Open(DrawerName);
    }
}

GLOBAL – Toggle Drawer

Toggle the open/close state of an UIDrawer, with the given drawer name, that exists in the UIDrawer Database. If the drawer is opened it will close and vice versa.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public string DrawerName = "Left";

    private void Start()
    {
        UIDrawer.Toggle(DrawerName);
    }
}

GLOBAL – Get Drawer

Get a reference to the first UIDrawer, with the given drawer name, found in the UIDrawer Database. Returns null if an UIDrawer is not found.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public string DrawerName = "Left";

    private void Start()
    {
        UIDrawer drawer = UIDrawer.Get(DrawerName);

        if (drawer != null)
        {
            Debug.Log("A drawer, with the '" + DrawerName + "' drawer name, has been found in the UIDrawer.Database");
        }
        else
        {
            Debug.Log("There is no drawer, with the '" + DrawerName + "' drawer name, in the UIDrawer.Database");
        }
    }
}

GLOBAL – Is Any Drawer Opened

Returns TRUE if at least one UIDrawer is opened

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    private void Start()
    {
        bool isOpened = UIDrawer.AnyDrawerOpened;
        
        Debug.Log(isOpened ? "A drawer is opened" : "No drawer is opened");
    }
}

GLOBAL – Get Opened Drawer

Returns the currently opened UIDrawer. There can be only one UIDrawer opened at a time.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    private void Start()
    {
        UIDrawer drawer = UIDrawer.OpenedDrawer;
    }
}