Code Monkey home page Code Monkey logo

quill's Introduction

quill

Quill is just a small wrapper based on pure UnityUI. You can create UI by using its c# api, programmatically.

Quill also comes with lua api support(experimental). That means you can run lua code from StreamingAssets and make ui in unity.

Documentation

Components

Label

var label = Quill.CreateLabel("hello world");
label.element.SetSize(100, 30);
label.element.SetPosition(100, 100);

Button

var button = Quill.CreateButton("hello button!");
button.onClick.AddListener(SomeMethod);
button.interactable = false;

button sample

Box

var panelParent = Quill.CreateEmpty();
panelParent.SetSize(300, 80);

var box = Quill.CreateBox(Color.red);
var label = Quill.CreateLabel("Score: ");
label.alignment = TextAnchor.MiddleCenter;
label.fontSize = 32;

panelParent.Add(box);
panelParent.Add(label);

label.element.StretchToParentContainer();
box.element.StretchToParentContainer();

panel sample

quill lua api

To enable lua feature, initialize and update the api like below. Quill will look into StreamingAssets/LUA directory for main.lua file.

private void Start()
{
    Quill.Init();
    QuillLua.Run(); 
}

private void Update()
{
    QuillLua.Update();
}

private void OnDestroy()
{
    QuillLua.Exit();
}

Here is the structure of the StreamingAssets/LUA/main.lua

function OnInit()

end

function OnUpdate(dt)

end

function OnExit()

end

Lua example

local timePassed = 0
local timeLabel = nil

function OnInit()

    local root = quill.empty()

    color = {}
    color.r = 0.4
    color.g = 0.8
    color.b = 0.3

    local box = quill.box()
    box:setColor(color.r, color.g, color.b)
    box:setSize(300, 100)
    root:addChild(box)

    timeLabel = quill.label("time")
    timeLabel:setSize(300, 100)
    
    root:addChild(timeLabel)
end

function OnUpdate(dt)
    timePassed = timePassed + dt
    timeLabel:setText("time: " .. string.format("%.2f", timePassed))

end

sample

This project is heavily WIP.

For more detail

Here is the first devlog: introduction to quill

references

Moonsharp

quill's People

Contributors

cemuka 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.