Git Product home page Git Product logo

uitoolkitmenucreator's Introduction

UIToolkitMenuCreator

UI Toolkit Menu Creator is a class and UXML/Stylesheet you can extend from to easily create Runtime Unity Game Menus from C# code without having to edit UXML.

Dependencies

UI Toolkit Menu Creator uses DOTween for fading menus:

DOTween License here

Demo

Demo

The demo scene is in Assets\MenuCreatorDemo\MenuCreatorDemo.scene. Its main file is **Assets\MenuCreatorDemo\MenuDemo.cs and shows how to use Menu Creator.

This is how the first demo menu is set up in code:

    public void CreateFirstDemoMenu()
    {
        StartBasicMenu("Main Menu");
        AddTwoButtonsWhenPossible(
            new MenuButton("First Button", () => {Debug.Log("Pressed First Button");}, ButtonColors.ButtonGrey),
            new MenuButton("Second Button", () => {Debug.Log("Pressed Second Button");}, ButtonColors.ButtonBlueAlt)
            );
        
        AddSpacer();
        var addedLabel = AddBigLabel("This label changes with the text field/slider values!");
        AddSpacer();
        AddTextField("Text Field", evt => { addedLabel.text = $"Text Field is: {evt.newValue}";},"Default Text Field Text");
        AddSpacer();
        AddSliderInt("Slider",0,0,10, evt => { addedLabel.text = $"Slider is set to {evt.newValue}";});
        AddSpacer();
        AddButton(new MenuButton("Other Menu", () =>
        {
            ChangeToMenu(CreateOtherMenu);
        }));
    }

Usage

  • Extend your menu file from MenuCreator
  • Add a UIDocument to the scene with MenuCreatorUXML as its source asset.
  • Add your menu file as a component to the same gameobject.
  • Refer to the Menu Demo on what methods to call to setup your menu.

uitoolkitmenucreator's People

Contributors

danielsnd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.