<MainMenu>
<Group Spacing="10px">
<Button Text="Play" Click="StartGame" />
<Button Text="Options" />
<Button Text="Quit" />
</Group>
</MainMenu>
public class MainMenu : UIView
{
public void StartGame()
{
// called when user clicks on "Play" button
}
}
<AnotherView>
<MainMenu Width="50%" Alignment="Left" />
<MainMenu Width="50%" Alignment="Right" />
</AnotherView>
<MainMenu>
<Group Spacing="10px">
<Button Text="Play" />
<Button Text="Options" />
<Button Text="Quit" />
</Group>
</MainMenu>
View Field | Description |
---|---|
Width | Width of the view that can be specified in pixels or percentage. Set to 100% by default |
Height | Height of the view that can be specified in pixels or percentage. Set to 100% by default. |
Alignment | Alignment of the view: TopLeft, Top, TopRight, Left, Center, Right, BottomLeft, Bottom, BottomRight. Set to Center by default. |
Margin | Specifies the view's margin from left, top, right and bottom. Default value: "0,0,0,0". |
Offset | Specifies the view's offset from left, top, right and bottom. Default value: "0,0,0,0". |
BackgroundColor | Background color overlay or tint of the view. Color values can be specified by name (Red, Blue, Coral, etc), hexcode (#aarrggbb or #rrggbb) or rgb/rgba value (1.0,0.0,0.5 or 1,1,1,0.5). Default value: (not set). |
BackgroundImage | The background image of the view. The value is the path to the sprite asset, e.g. "Assets/MySprites/Sprite.psd". Default value: (not set) |
BackgroundImageType | The image type of the background image: Simple, Sliced, Tiled or Filled. Default value: "Simple". |
using MarkLight.Views.UI;
public class MainMenu : UIView
{
}
<MainMenuScene>
<UserInterface>
<MainMenu />
</UserInterface>
<EventSystem />
</MainMenuScene>
using MarkLight;
public class MainMenuScene : View
{
}
public class MainMenu : UIView
{
public void StartGame()
{
Debug.Log("StartGame() called.");
}
public void Options()
{
Debug.Log("Options() called.");
}
public void Quit()
{
Debug.Log("Quit() called.");
}
}
<MainMenu>
<Group Spacing="10px">
<Button Text="Play" Click="StartGame" />
<Button Text="Options" Click="Options" />
<Button Text="Quit" Click="Quit" />
</Group>
</MainMenu>
<MainMenu>
<Region Width="25%" Alignment="Left" Margin="30,30,15,30"
BackgroundColor="#ef706a">
<Group Spacing="10px" Alignment="Top">
<Button Text="Play" Click="StartGame" />
<Button Text="Options" Click="Options" />
<Button Text="Quit" Click="Quit" />
</Group>
</Region>
<Region Width="75%" Alignment="Right" Margin="15,30,30,30"
BackgroundColor="#949494">
<!-- content area -->
</Region>
</MainMenu>
<MainMenu>
<Region Width="25%" Alignment="Left" Margin="30,30,15,30">
<Group Spacing="10px" Alignment="Top">
<Button Text="Play" Click="StartGame" />
<Button Text="Options" Click="Options" />
<Button Text="Quit" Click="Quit" />
</Group>
</Region>
<Region Width="75%" Alignment="Right" Margin="15,30,30,30">
<ViewSwitcher Id="ContentViewSwitcher">
<Region />
<Region BackgroundColor="Red" />
<Region BackgroundColor="Blue" />
</ViewSwitcher>
</Region>
</MainMenu>
public class MainMenu : UIView
{
public ViewSwitcher ContentViewSwitcher;
public void StartGame()
{
ContentViewSwitcher.SwitchTo(1);
}
public void Options()
{
ContentViewSwitcher.SwitchTo(2);
}
public void Quit()
{
Application.Quit();
}
}
public class Options : UIView
{
public float Volume;
public bool EasyMode;
public string PlayerName;
}
<Options>
<Group Spacing="20px" Alignment="TopLeft" ContentAlignment="Left">
<Label Text="Volume: " />
<Slider Value="{Volume}" Min="0" Max="100" Width="400px" />
<CheckBox Text="Easy Mode" IsChecked="{EasyMode}" />
<Label Text="Player: " />
<InputField Text="{PlayerName}" />
</Group>
</Options>
<Slider Value="{Volume}" />
...
<ViewSwitcher Id="ContentViewSwitcher">
<Region />
<Region BackgroundColor="Red" />
<Options Volume="75" PlayerName="Player" EasyMode="True" />
</ViewSwitcher>
...
...
<ViewSwitcher Id="ContentViewSwitcher" TransitionIn="FadeIn">
<Region />
<Region BackgroundColor="Red" />
<Options Volume="75" PlayerName="Player" EasyMode="True" />
</ViewSwitcher>
</Region>
<ViewAnimation Id="FadeIn">
<Animate Field="Alpha" From="0" To="1" Duration="0.2s"
EasingFunction="QuadraticEaseIn" />
</ViewAnimation>
</MainMenu>
...
<Label Text="Player: " />
<InputField Text="{PlayerName}" />
<Button Text="Reset Defaults" Click="ResetDefaults" Width="250px" />
</Group>
</Options>
public class Options : UIView
{
public float Volume;
public bool EasyMode;
public string PlayerName = "";
public void ResetDefaults()
{
SetValue(() => Volume, 75.0f); // Volume = 75.0f
SetValue(() => EasyMode, true); // EasyMode = true
SetValue(() => PlayerName, "Player"); // PlayerName = "Player"
}
}
public class Options : UIView
{
public _float Volume;
public _bool EasyMode;
public _string PlayerName;
public void ResetDefaults()
{
Volume.Value = 75.0f;
EasyMode.Value = true;
PlayerName.Value = "Player";
}
}
View | Description |
---|---|
Button | Clickable region with text. Can be set to toggle and can have content. |
CheckBox | A box that can be ticked with a label. |
ComboBox | Presents dynamic or static list of items in a drop-down list. |
DataGrid | A content view that arranges static or dynamic content in a grid. |
Group | A content view that arranges its content vertically or horizontally with a set spacing between. |
HyperLink | Displays clickable text. |
InputField | Input field where the user can type text. |
Label | Displays text. Supports rich text and embedded views. |
List | Arranges static or dynamic content as a selectable list. |
Panel | Content view that provides functionality for scrolling content. |
RadialMenu | Arranges its content in a circle that can be opened/closed with optional animation. |
RadioButton | For presenting one-of-many selection. |
Region | Content view used to spacially arrange views. |
Slider | Slider with a handle that can be moved with the mouse. |
TabPanel | A content view that arranges its content in a series of tabs that can be switched between. |
ViewSwitcher | Content view that provides functionality for switching its content. |
Window | Arranges content in a window that can be movable and closable. |
Be notified when new themes, views, tutorials and updates are available