For use the library you need:
1.- copy the folder GUIForms to your project.
2.- Create a script with the definition of the form
example:
TestControlsForm.cs
using System;
using UnityEngine;
using GUIForms;
public partial class TestControlsForm : Form
{
// define the controls of the form
private Button ButtonClose;
private Button ButtonShowMessage;
private Label LabelTooltip;
private Box Box1;
private Button Button1;
private Label Label1;
private TextArea TextArea1;
private TextField TextField1;
private PasswordField PasswordField1;
private Toggle Toggle1;
private VerticalSlider VerticalSlider1;
private HorizontalSlider HorizontalSlider1;
// initialize the form
public override void Initialize()
{
// set form variables
// the title
Text = "Test Controls";
// if is or not draggable
Draggable = true;
// if use window or not
WindowMode = WindowModes.Window;
// the size
Size = new Size(500, 400);
// location of the form
Location = FormsUtility.CenterScreen(this);
// create the first control a label to show tooltips and messages
LabelTooltip = (Label)AddControl(new Label());
// the size
LabelTooltip.Size = new Size(400, 20);
// the location
LabelTooltip.Location = new Point(5, 5);
// create an button control
ButtonClose = (Button)AddControl(new Button());
// the caption
ButtonClose.Text = "Close";
// the tooltip message
ButtonClose.ToolTip = "Press here to close this window";
ButtonClose.Size = new Size(100, 20);
ButtonClose.Location =
FormsUtility.AlignControl
(
Point.Empty, ButtonClose.Size, ViewSize,
HorizontalAlignment.Left, VerticalAlignment.Botton,
5, 5, 5, 5
);
// assign event handlers
ButtonClose.ButtonClick += ButtonClose_OnClick;
ButtonClose.MouseOver += Control_MouseOver;
ButtonClose.MouseOut += Control_MouseOut;
// the others controls are in the same maner
ButtonShowMessage = (Button)AddControl(new Button());
ButtonShowMessage.Text = "Show Message";
ButtonShowMessage.ToolTip = "Press here to test MessageBox";
ButtonShowMessage.Size = new Size(100, 20);
ButtonShowMessage.Location =
FormsUtility.AlignControl
(
Point.Empty, ButtonClose.Size, ViewSize,
HorizontalAlignment.Left, VerticalAlignment.Botton,
5, 5, 5, 40
);
ButtonShowMessage.ButtonClick += ButtonShowMessage_OnClick;
ButtonShowMessage.MouseOver += Control_MouseOver;
ButtonShowMessage.MouseOut += Control_MouseOut;
Box1 = (Box)AddControl(new Box());
Box1.Text = "Box";
Box1.ToolTip = "Box";
Box1.Size = new Size(70, 50);
Box1.Location = new Point(5, 30);
Box1.MouseOver += Control_MouseOver;
Box1.MouseOut += Control_MouseOut;
Button1 = (Button)AddControl(new Button());
Button1.Text = "Button";
Button1.ToolTip = "Button";
Button1.Size = new Size(70, 20);
Button1.Location = new Point(80, 30);
Button1.MouseOver += Control_MouseOver;
Button1.MouseOut += Control_MouseOut;
Label1 = (Label)AddControl(new Label());
Label1.Text = "Label";
Label1.ToolTip = "Label";
Label1.Size = new Size(70, 20);
Label1.Location = new Point(80, 60);
Label1.MouseOver += Control_MouseOver;
Label1.MouseOut += Control_MouseOut;
TextArea1 = (TextArea)AddControl(new TextArea());
TextArea1.Text = "TextArea";
TextArea1.ToolTip = "TextArea";
TextArea1.Size = new Size(100, 50);
TextArea1.Location = new Point(150, 30);
TextArea1.MouseOver += Control_MouseOver;
TextArea1.MouseOut += Control_MouseOut;
TextField1 = (TextField)AddControl(new TextField());
TextField1.Text = "TextField";
TextField1.ToolTip = "TextField";
TextField1.Size = new Size(100, 20);
TextField1.Location = new Point(255, 30);
TextField1.MouseOver += Control_MouseOver;
TextField1.MouseOut += Control_MouseOut;
PasswordField1 = (PasswordField) AddControl(new PasswordField());
PasswordField1.ToolTip = "PasswordField";
PasswordField1.Size = new Size(100, 20);
PasswordField1.Location = new Point(255, 60);
PasswordField1.MouseOver += Control_MouseOver;
PasswordField1.MouseOut += Control_MouseOut;
Toggle1 = (Toggle) AddControl (new Toggle());
Toggle1.Text = "Toggle";
Toggle1.ToolTip = "Toggle";
Toggle1.Size = new Size(100, 20);
Toggle1.Location = new Point(360, 30);
Toggle1.MouseOver += Control_MouseOver;
Toggle1.MouseOut += Control_MouseOut;
VerticalSlider1 = (VerticalSlider)AddControl(new VerticalSlider());
VerticalSlider1.Max = 20;
VerticalSlider1.Max = 50;
VerticalSlider1.ValueType = GUIForms.ValueType.Float;
VerticalSlider1.Size = new Size(20, 100);
VerticalSlider1.Location = new Point(5, 120);
VerticalSlider1.MouseOver += Control_MouseOver;
VerticalSlider1.MouseOut += Control_MouseOut;
VerticalSlider1.ValueChanged += new ValueChangedEventHandler(VerticalSlider1_ValueChanged);
HorizontalSlider1 = (HorizontalSlider)AddControl(new HorizontalSlider());
HorizontalSlider1.Min = 0;
HorizontalSlider1.Max = 10;
HorizontalSlider1.ValueType = GUIForms.ValueType.Integer;
HorizontalSlider1.Size = new Size(100, 20);
HorizontalSlider1.Location = new Point(5, 100);
HorizontalSlider1.MouseOver += Control_MouseOver;
HorizontalSlider1.MouseOut += Control_MouseOut;
HorizontalSlider1.ValueChanged += new ValueChangedEventHandler(HorizontalSlider1_ValueChanged);
}
// event handler for the slider, if wee change the value, this event is hired
void VerticalSlider1_ValueChanged(object sender, ValueChangedEventArgs e)
{
LabelTooltip.Text = string.Format("VerticalSlider1={0}", e.Value);
}
private void HorizontalSlider1_ValueChanged(object sender, ValueChangedEventArgs e)
{
LabelTooltip.Text = string.Format("HorizontalSlider1={0}", e.Value);
}
// the event for the button, when the user click the button this event is hired
private void ButtonClose_OnClick(object source, MouseClickEventArgs e)
{
if (e.MouseButton == MouseButtons.Left)
{
Close();
}
}
private void ButtonShowMessage_OnClick(object source, MouseClickEventArgs e)
{
// show a messagebox (popup modal form)
MessageBox.Show(gameObject, "Title Message", "this is a test this is a test this is a test", DefaultSkin);
}
// the mouseover and mouseout events shows the tooltip on the labeltooltip
private void Control_MouseOver(object source, EventArgs e)
{
LabelTooltip.Text = ((Control)source).ToolTip;
}
private void Control_MouseOut(object source, EventArgs e)
{
LabelTooltip.Text = "";
}
}
3.- Call your form
example:
TestControls.cs
using System;
using UnityEngine;
using GUIForms;
// put this script on a component of your scene
public class TestControls : MonoBehaviour
{
public GUISkin Skin;
private TestControlsForm Form;
public void Awake()
{
// instantiate the form
Form = (TestControlsForm)FormsManager.LoadForm(gameObject, typeof(TestControlsForm), Skin);
// set the title
Form.Text = "Test Controls";
// and display it
Form.Show(); // this is if you want a modeless form
//Form.ShowModal(); // this is if you want a modal form
}
}