MarkLight: Markup Extension Framework for Unity

MarkLight: Markup Extension Framework for Unity

What is MarkLight?

MarkLight is framework for Unity that offers XUML (eXtensible Unity Markup Language) a declarative design language similar in syntax to HTML but instead of defining the contents of a webpage it is used to design scenes in Unity.

XUML can be used to create views and define their relationship to the underlying game logic. Views are modular building blocks that can represent anything in the scene (UI widgets, meshes, lights, etc).

XUML and View Model

MainMenu.xml (XUML)

    <MainMenu>
        <Group Spacing="10px">
            <Button Text="Play" Click="StartGame" />
            <Button Text="Options" />
            <Button Text="Quit" />
        </Group>
    </MainMenu>

MainMenu.cs (View Model)

    public class MainMenu: UIView
    {
        public void StartGame()
        {
            // called when user clicks on "Play" button
            Debug.Log("StartGame() called");
        }
    }

The above example shows to create a simple main menu view that responds to user interaction.

Through this simple mechanism (called MVVM) you can build upon existing views and create advanced re-usable functionality with ease. It also serves to decouple presentation from game logic which help keep designer and developer responsibilities separate.

Data Binding

Data binding solves the problem of keeping your game data synchronized with its presentation. Here is an example of an highscore list generated from dynamic data using a custom template:

Highscore.xml (XUML)

    <List Items="{Highscores}">
        <ListItem IsTemplate="True">
            <Group Orientation="Horizontal">
                <Label Text="{#Item.PlayerName}" />
                <Label Text="{#Item.Score}" />
            </Group>
        </ListItem>
    </List>

Highscore.cs (View Model)

    public class HighscoreList : UIView
    {
        public ObservableList<Highscore> Highscores;

        public override void Initialize()
        {
            // populate highscores from data source
        }
    }

If you update the highscore list, e.g. add another entry, the view is automatically updated with no additional code required.

And Much More…

Some more key features includes multi binding, animations, theming & styling and state management. The framework comes with 40+ views in 3 different themes. It’s compatible with PC, Mac, iOS, Android, WebGL, Android and Windows Phone. Full source is included.

It’s a new elegant and intuitive way of designing and developing scenes in Unity. It speeds up development, it bridges the gap between designers and programmers through a common language, it allows designs to be more easily shared in the community. It’s intuitive, powerful and easy to use.

Webpage | Asset Store | Twitter | Subreddit | Slack Chat

Hi ExMakina,

We are doing some test with your asset. The worflow is interesting and “comfortable” :slight_smile:

I have some request/question:

  1. There is no demo about ScrollView: it is available? can you add a demo scene?
  2. How does it work the animation worflow?
  3. Does it support SpritePacker? I packed your sprite into demo folder, and unity doens’t batched the sprite with high risks about draw call.

Thanks,

Hi Unreal Vision

There is no ScrollView however the Panel view can be used if you want scrollable content. The Panel is demonstrated in the UIExamples demo scene.

The framework supports creating animations in XUML useful for basic transformation and transitions. I added a new tutorial recently: Creating Animations, that explains how animation works in MarkLight. I’ve not worked with Unity’s own animation workflow (mecanim) so I don’t know how well they play together.

I’ve not looked into SpritePacker specifically but the framework supports referencing sprites in sprite sheets / atlases. You can load a sprite from an atlas in XUML using the following syntax:

Warm regards,
Patrik

  1. Can you add a specific example how does scroll view works please? Would be very appreciate :slight_smile:
  2. Thanks for tutorial
  3. In the scene examples, you load script “psd” instead of subsprite. This is why sprite packer doesn’t work? Can you check and confirm please?
  1. This XUML creates a scene containing a panel that has scrollable content (4 square regions):
<ScrollExample xmlns="MarkLight">
    <UserInterface>
        <Panel Width="300px" Height="300px">
            <Region Width="600px" Height="600px">
                <Region Width="50%" Height="50%" Alignment="TopLeft" BackgroundColor="Gray70" />
                <Region Width="50%" Height="50%" Alignment="TopRight" BackgroundColor="Gray80" />
                <Region Width="50%" Height="50%" Alignment="BottomLeft" BackgroundColor="Gray80" />
                <Region Width="50%" Height="50%" Alignment="BottomRight" BackgroundColor="Gray70" />
            </Region>
        </Panel>
    </UserInterface>
    <EventSystem/>
</ScrollExample>
  1. I don’t have the Sprite Packer asset but I can help you troubleshoot. Most likely if you pack the sprites you need to change how they are accessed in the XUML. What errors are you getting?
  1. It is enough select all sprites, assign a unique “Package Tag” (Sprite Editor just to edit single sprite but it doesn’t pack), open Sprite Packer and click on left top “Pack”

2622867--184223--upload_2016-5-5_7-46-57.png

Are you able to reproduce?

I tried packing all the assets in the Toon theme (it created three atlas groups) and the draw calls was reduced from 15 to 10 in the UIExamples scene. I encountered no issues.

Very good looking framework! Thanks for free! Can’t wait to research!

Is it can update views in UnityEditor without switching from Visual Studio?

Wanna preview by save view xml file.

How can i get reference to parent object or other elements? (exm: For switching view from child components)