-
Notifications
You must be signed in to change notification settings - Fork 0
C# Api
Cem Ugur Karacam edited this page Oct 5, 2021
·
2 revisions
Setting up is dead easy.
public class AppStartup : MonoBehaviour
{
private void Start()
{
Quill.Init();
}
}
Quill does not require any resource or prefab. It initialize its canvas and checks for EventSystem
. Any default object will be a child of this canvas.
Type | Name | get | set |
---|---|---|---|
Canvas | mainCanvas | yes | no |
QuillElement | mainCanvasElement | yes | no |
Message | message | yes | no |
Font | defaultFont | yes | yes |
public static void Init()
public static QuillElement CreateEmpty()
public static QuillLabel CreateLabel(string text)
public static QuillBox CreateBox(Color color)
public static QuillButton CreateButton(string text)
public static Vector2 MousePosition()
Every quill component actually a thin layer of its original unity class. That way you'll get the advantage of the base functionality.
Empty object.
var empty = Quill.CreateEmpty();
empty.SetSize(100, 100);
empty.SetAnchoredPosition(300, 300);
QuillElement
and ElementRoot
are base components of the quill. It's more like MonoBehaviour
and Transform
if you familiar with unity. Since RectTransform
is a sealead class ElementRoot
come in handy.
public class QuillElement : MonoBehaviour, IQuillElement
{
public ElementRoot root { get; set; }
...
}
public class ElementRoot
{
public RectTransform rectTransform;
public void AddChild(IQuillElement element)
{
// make the target as child of the rectTransform
// element is child
// recTransform is parent
}
}
Text object. Unity Manual
var label = Quill.CreateLabel("my label");
label.fontSize = 20;
public class QuillLabel : Text, IQuillElement
{
...
}
Image object. Unity Manual
var box = Quill.CreateBox(Color.green);
box.SetSize(300, 300);
box.SetAnchoredPosition(200, 200);
public class QuillBox : Image, IQuillElement
{
...
}
Button object. Unity Manual
var button = Quill.CreateButton("my awesome button");
button.box.color = Color.blue;
button.label.color = Color.yellow;
public class QuillButton : Button, IQuillElement
{
...
public QuillLabel label;
public QuillBox box;
...
}
Provides a signal hub functionality.
// dispatch message
var data = new MessageData("ON_SCORE_EVENT");
data.container.Add("score", 3);
data.container.Add("player", "cemuka");
Quill.message.Post(data);
// listen message
private void OnEnable()
{
Quill.message.Register(OnScore);
}
private void OnDestroy()
{
Quill.message.Unregister(OnScore);
}
private void OnScore(MessageData data)
{
Debug.Log(data.id);
if(data.id == "ON_SCORE_EVENT")
{
// handle score
}
}